How to trigger an interrupt routine with serial port?

Hi all,

I would like to know how to trigger an internal interrupt function with an incoming data from serial port?
Thanks & have a nice day
Sebastien

On page 57 of the 328 data sheet you will see a list of vectors.
Vector number 19 and 21 can be called when a byte is received or sent.

However the normal arduino system makes use of these so you will have to over ride them, and than a whole bunch of other stuff won’t work.

SEBASS:
I would like to know how to trigger an internal interrupt function with an incoming data from serial port?

Someone else wanted to do that recently. I don't suppose you are working on MIDI? My answer here still stands:

Mike,
Effectively, I can see the both vector 19 & 21 in the tab

19 0x012 USART, RX USART Rx Complete
21 0x014 USART, TX USART, Tx Complete

I will use the vector 19 in my case because i need to trigger interrupt when i receive the data

I don't suppose you are working on MIDI? My answer here still stands:

You are right Nick! I didn't work on midi!
I send a byte trame on TX signal from my computer to the Rx of the µ328. I'm working on RealTerm (very nice freeware)

Nick,
I'm not sure to understand how to use this code from hardwareserial.cpp in the arduino code?

I extracted the complete code:

SIGNAL(USART_RX_vect)
{
#if defined(UDR0)
unsigned char c = UDR0;
#elif defined(UDR)
unsigned char c = UDR; // atmega8535
#else
#error UDR not defined
#endif
store_char(c, &rx_buffer);
}

I have to include the hardwareserial.h file ?

thanks

You would have to modify it. So make a copy of the whole IDE for this project. Then you would need to add something, eg.

SIGNAL(USART_RX_vect)
  {
  #if defined(UDR0)
    unsigned char c  =  UDR0;
  #elif defined(UDR)
    unsigned char c  =  UDR;  //  atmega8535
  #else
    #error UDR not defined
  #endif
    store_char(c, &rx_buffer);

    my_interrupt_routine (c);   // call my interrupt
  }