bignoob
Newbie level 2
- Joined
- Aug 18, 2014
- Messages
- 2
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1
- Activity points
- 21
Hello,
I had used USART interrupts on ATMega88 to handle sending data from PC to uC so that data can be transmitted using nRF24L01... Something like virtual serial bridge between 2 PCs. But than i had to switch on one side from ATMega88 to ATMega168 and than problem started...
Baud rate is set on both uC and it's the same.
Usart init:
Also i have enabled usart interrupt:
Basically, i just now need to echo back to terminal chars that came from terminal just to debug it... (since nRF module don't send anything... )
Here's where problem occurs... When I enter anything in terminal it goes crazy... Starts printing some symbols all the time (blinking dash goes left to right all the time in the same line...)
I have tried to print out anything when interrupt is handled.. first line in ISR just say "entered"... but that never happens ? i switch back to atmega88 and everything works just fine?!?
Could anyone have a idea what could be the issue ? I feel i just go round and round in circles....
I had used USART interrupts on ATMega88 to handle sending data from PC to uC so that data can be transmitted using nRF24L01... Something like virtual serial bridge between 2 PCs. But than i had to switch on one side from ATMega88 to ATMega168 and than problem started...
Baud rate is set on both uC and it's the same.
Usart init:
Code:
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);
Also i have enabled usart interrupt:
Code:
UCSR0B |= (1<<RXCIE0);
Basically, i just now need to echo back to terminal chars that came from terminal just to debug it... (since nRF module don't send anything... )
Code:
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('#');
}
void usart_transmit(uint8_t data)
{
while ( !( UCSR0A & (1<<UDRE0)) );
UDR0 = data;
}
uint8_t usart_receive( void )
{
return UDR0;
}
Here's where problem occurs... When I enter anything in terminal it goes crazy... Starts printing some symbols all the time (blinking dash goes left to right all the time in the same line...)
I have tried to print out anything when interrupt is handled.. first line in ISR just say "entered"... but that never happens ? i switch back to atmega88 and everything works just fine?!?
Could anyone have a idea what could be the issue ? I feel i just go round and round in circles....