Witam!
Mam problem z USART-em mianowicie nie chce wysyłać tego co chce i wysyła jakieś bzdety.
Mam problem z USART-em mianowicie nie chce wysyłać tego co chce i wysyła jakieś bzdety.
#define F_CPU 1000000ul
#include <avr/io.h>
#include <util/delay.h>
#include <avr/signal.h>
#define FOSC 1000000
#define CZYT 50
#define BAUD 9600
#define MYUBRR FOSC/16/BAUD-1
void USART_Init( unsigned int ubrr){
/* Set baud rate */
UBRRH = (unsigned char)(ubrr>>8);
UBRRL = (unsigned char)ubrr;
UCSRB|=_BV(RXEN)|_BV(TXEN)|_BV(RXCIE);
UCSRC|=_BV(URSEL)|_BV(UCSZ1)|_BV(UCSZ0);
//sei();
}
void USART_Transmit( unsigned char data ){
/* Wait for empty transmit buffer */
while ( !( UCSRA & (1<<UDRE)) );
/* Put data into buffer, sends the data */
UDR=data;
}
unsigned int USART_Receive( void )
{
unsigned char status, resh, resl;
/* Wait for data to be received */
while ( !(UCSRA & (1<<RXC)) )
;
return UDR;
}
int main ()
{
USART_Init (MYUBRR);
while(1)
{
USART_Transmit('z');
}
return 0;
}