go away spammer

Author Topic: interrupts in ATmega128  (Read 2815 times)

0 Members and 1 Guest are viewing this topic.

Offline joystickTopic starter

  • Beginner
  • *
  • Posts: 4
  • Helpful? 0
interrupts in ATmega128
« on: July 01, 2011, 07:56:11 AM »
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
« Last Edit: July 01, 2011, 10:15:12 AM by joystick »

 


Get Your Ad Here