I would like to test the presence of a new data or token in a channel within a while(1) loop from C langage, and not using XC select.
From my understand and testing, sending a data or token over a channel stores the value in a buffer (some sort of fifo) and this doesn't block the sender unless the buffer is full.
On the receiver side, reading a channel with in or inct will block the program until a data or token is present, same for testct.
I d like to avoid that situation for an asynchronous transfer.
But looking into the ISA documentation, I didn't find any instruction to access the event status of a given resource. am I wrong ?
the only way I can imagine would be to implement a test sub routine with following code:
Code: Select all
int void testchannel(unsigned c) {
SETV res[c], Label //initialise event vector with address pointing to Label below
EEU res[c] //enable events for this channel
LDC R0,0
SETSR 1 //this will now enable event handling in the thread and possibly jump immediately to vector Label
NOP
EDU res[c] //disable events for this channel
SUB R0,R0,1
Label:
ADD R0,R0,1
SETSR 0 //disable event handling in the thread
CLRE
return R0 }
otherwise an event will be triggered when enabling them in the thread status register (with SETSR 1) and then the SUB R0,R0,1 will not be executed, the result of the routine will be 1.
Any other idea, feedback or thought welcome, thanks !