i am newbie trying to use usart by interrupts in the echo program.
i us atmega 328 and c language.
i have successfully implemented the echo program without using interrupts.
while using interrupt, microcontroller echoes back no character.
here's my program
please help sorting out the problem .
thanks in advance
i us atmega 328 and c language.
i have successfully implemented the echo program without using interrupts.
while using interrupt, microcontroller echoes back no character.
here's my program
Rich (BB code):
// program to echo using interrupts
#include<avr/io.h>
#include<util/delay.h>
#include<interrupt.h>
#define BAUD_RATE 9600
#define BAUD_PRESCALE (((F_CPU / (BAUD_RATE * 16UL))) - 1)
void initialise_serial(); //initialise USART
char c;
main()
{
initialise_serial();
sei();
UCSR0B |=(1<<RXCIE0);//enabling recieve complete interrupt
while(1);
}
void initialise_serial()
{
UCSR0B |=(1<<RXEN0)|(1<<TXEN0);
UCSR0C |=(1<<UCSZ01)|(1<<UCSZ00);
UBRR0H |=(BAUD_PRESCALE>>8);
UBRR0L |=BAUD_PRESCALE;
}
ISR(USART_RXC_vect)
{
c = UDR0;
UDR0 =c;
}
thanks in advance
Last edited by a moderator: