ISR VECCTOR

Hello all,

I will appreciate if you can help.

I have the following setup and the USART ISR is not executed.

I can not get nothing out of it. I checked with the scope and I have an input signal, but, nothing in the output.

#include <avr/interrupt.h> 
#include <stdint.h>
#define F_CPU 16000000UL
#define USART_BAUDRATE_0 9600 
#define BAUD_PRESCALE_0 (((F_CPU / (USART_BAUDRATE_0 * 16UL))) - 1)

volatile uint8_t received_byte;

void setup() {

Serial.begin(9600); //just to check if the ISR is executed.

UBRR0L=BAUD_PRESCALE_0;   //Load the lower 8 bits of baud rate value into low byte 
UBRR0H=(BAUD_PRESCALE_0>>8); // load the upper 8 bits of the baud rate value  
UCSR0B =(1<<TXEN0)|(1<<RXEN0); 							// turn the tranmition on
UCSR0C |=(0<<USBS0)|(3<<UCSZ00);  //S 
UCSR0B |= (1 << RXCIE0); // Enable the USART Recieve Complete interrupt (USART_RXC)  
sei();
interrupts();
}


void loop()
 {
}


ISR(USART_RXC_vect)
{ 
     volatile uint8_t received_byte; 
     received_byte = UDR0; // Fetch the recieved byte value into the variable "received_byte" 
    UDR0 =received_byte; // Echo back the received byte back to the computer
   Serial.println("A"); //to test if it executes the ISR 
}

You're basically stepping all over the Serial library's toes with that code. It already goes through and defines the receive ISR, as well as sets up and enables the USARTs. So the question is, why are you then trying to do the same all over again?

Maybe your use of the USART registers conflicts with the Serial library's use of those same registers.

Try changing your code to light the LED on pin 13 when you get a character. That will allow you to remove the use of Serial.

Thanks for your answers.

I just want to use the UART with Interrupts, because I have a lot of data coming in and want to screen it out and used only the data I am interested. the spare time I need to do other stuff. Considering this how I do set up the UARt in order to use ISR. I almost do not know nothing about C , but I know a bit of assembly, so, I thought it was the best way to do it.

Thanks.
Manuel

[quote author=Manuel Silva link=topic=65826.msg482325#msg482325 date=1309969330] Thanks for your answers.

I just want to use the UART with Interrupts, because I have a lot of data coming in and want to screen it out and used only the data I am interested. the spare time I need to do other stuff. Considering this how I do set up the UARt in order to use ISR. I almost do not know nothing about C , but I know a bit of assembly, so, I thought it was the best way to do it.

Thanks. Manuel [/quote]

The standard arduino hardware serial library already uses interrupts to store incoming characters into a local buffer ready for your sketch to test if there is something new ready to read using the serial.avalible command. Why reinvent the wheel?

Lefty