I was using USART interrupts to handle data transfer from PC to uC so that I could send that data to another remote PC using nRF24L01. Everything worked just fine with ATMega88, but on one side i had to switch to ATMega168 and then...
everything stop working ...
So I tried to debug it... one thing at the time...
USART communication is working when I send some data from PC to uC and back... But when i try to do that using USART interrupt problem occurs... When I enter any character from terminal it goes crazy .... starts printing some symbols and blinking dash goes left to right all the time (pretty fast)... I go back again to ATMega88 and everything works...
Usart init and 2 functions that i used for communication ....
unsigned int USART_BAUDRATE = 9600;
unsigned int ubrr = (((F_CPU / (USART_BAUDRATE * 16UL))) - 1);
UBRR0H = (unsigned char)(ubrr>>8);
UBRR0L = (unsigned char)ubrr;
UCSR0B = (1<<RXEN0)|(1<<TXEN0);
UCSR0C = (1<<USBS0)|(3<<UCSZ00);
void usart_transmit(uint8_t data)
while ( !( UCSR0A & (1<<UDRE0)) );
UDR0 = data;
uint8_t usart_receive( void )
Enable usart interrupt
UCSR0B |= (1<<RXCIE0);
I tried printing something at the beginning of the ISR to see if it goes inside but that never happens.
Anyone have a idea what could be the issue here ? I feel i just go round and round in circles....