I am trying to build a robotic arm using servos ... I want user to input the position (s)he wants the servo shaft to attain .. for that I want to use interrupts (in ATmega128) ... I wrote a code to check if the receive complete interrupt would work ...but to my surprise its just a simple code but still the interrupt is not generated when I write in UART (HyperTerminal in win7) i.e. the UDR1 (of ATmega128) is not receiving any character that I am inputting through keyboard . The code being....
#include<avr/io.h>
#include<util/delay.h>
#include "uart.h"
#include<avr/interrupt.h>
volatile unsigned int r=0;
volatile unsigned char alpha;
int main(void)
{
UART_init(103); // uart initialization
sei(); //enable global interrupts
UCSR1B|= (1<<RXCIE); //receive complete interrupt enable
DDRC=255;
PORTC=0;
_delay_ms(1000);
while(1)
{
PORTC=255;
while(r==0); //stay in loop till interrupt is generated
r=0; //set r as '0'
}
}
ISR(USART1_RX_vect)
{
sei();
alpha=UDR1;
UDR1=alpha;
r=1;
}
Thanks