Pages: [1]   Go Down
Author Topic: Serial interupt (SOLVED)  (Read 321 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello,
I'm working with UNO32, and I would like to use serial communication but through interrupt. For example, if a serial data arrived, an interrupt is trigger, and I process the data.
Thanks
« Last Edit: February 12, 2013, 11:56:56 am by michastro » Logged

Massachusetts, USA
Offline Offline
Tesla Member
***
Karma: 208
Posts: 8822
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The chipKIT "UNO32" is not an Arduino and does not have an ATmega processor so you're going to have trouble getting help here for it.  I would start reading the datasheet for the PIC32MX320F128 to see how to work with the hardware serial port.  Good luck!
Logged

Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 611
Posts: 49092
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Serial data delivery is already interrupt based. Why is not checking Serial.available() in loop() sufficient?
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

For example with the timer2, I use:
void __ISR(_TIMER_2_VECTOR,IPL3AUTO) comms2_handler(void)
{
}
perhaps something like:
void __ISR(_UART_1_VECTOR,IPL3AUTO) comms2_handler(void)
{
}
?????

Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 611
Posts: 49092
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

S   e   r   i   a   l      d   a   t   a      a   r   r   i   v   e   s      s   l   o   w  l   y.

I still don't see why the arrival of one byte needs to interrupt the Arduino. What else is it doing?
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I need this interrupt because in the same time I have several timers, and I want to manage special priorities order.
I have found the solution:

#include <plib.h> /* this gives the i/o definitions */

boolean received;

void setup()
{
 received=false;
 Serial.begin(38400);
}

void loop()
{
 if (received)
 {
  Serial.println("RECEIVED!!!");
  received=false;
 }
}

extern "C" {
void __ISR(_UART_1_VECTOR, ipl4) U1_ISR(void)
{
  if(mU1RXGetIntFlag())
  {
    // Clear the RX interrupt Flag
    mU1RXClearIntFlag();
 
    // Handle Character
    received=true;
  }
}
}
 and now I can choose the IPL I want!

Thanks
Logged

Pages: [1]   Go Up
Jump to: