Guest thebignoob Posted August 21, 2014 Report Share Posted August 21, 2014 Hello, 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 .... void usart_init(void) { 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 ) { return UDR0; } Enable usart interrupt UCSR0B |= (1<<RXCIE0); ISR ISR(USART_RX_vect) { uint8_t W_buffer[8]; int i; for (i=0;i<8;i++) { W_buffer[i]=usart_receive(); usart_transmit(W_buffer[i]); } usart_transmit('#'); } 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.... :( Quote Link to comment Share on other sites More sharing options...
Guest liquibyte Posted August 21, 2014 Report Share Posted August 21, 2014 Have you tried an AVR forum? I suspect the difference from working to not will be in the differences between the chips themselves. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.