channel interrupts

If you have a simple question and just want an answer.
babazaroni
Experienced Member
Posts: 94
Joined: Sun Feb 10, 2013 4:47 am

channel interrupts

Post by babazaroni »

What is the preferred method to implement channel interrupts in XC?

The usb audio firmware uses a macro called set_interrupt_handler defined in interrupt.h.  Interrupt.h seems to be found only in the audio firmware.  I was unable to get it to work in a non-audio project on a U6 processor.

Is there another, documented way for a handler to be run when a chanend receives a message?



User avatar
sethu_jangala
XCore Expert
Posts: 589
Joined: Wed Feb 29, 2012 10:03 am

Post by sethu_jangala »

The best way to wait for events on a channel is by using the select statement. You can wait on channel to read the date from the channel but this blocks until there is some data in the channel.

Have a look at he following examples for more details:

while(1)

{

  select 

  {

    case c:> data:

      //do something

       break;

    //wait for some other events

  }

}

 

while(1)

{

  c:> data; //blocks until there is some data available in the channel

}