While going through the tutorials and digging around in various files I noticed there were two PEEK statements available, XC and ASM.
Which look very handy, especially during testing and hardware debug, which lead to the question of how to use both them in a program, and promptly put up a roadblock to further study.
Although I have done some coding in C and assembler, I have never used inline assembly before, and of course XC is new. Therefore I have many questions but not sure which to ask first.
I have included a stripped down program for a XS1-L2 that works. All it does is toggle the defined 'out' ports hi and lo to produce the conditions of both on, both off, and XOR.
If not too much trouble could someone add both peeks to the code with perhaps a brief explanation as to why it is done that way. Maybe then I can form an intelligent question.
Code: Select all
/* PEEK
* July 2012
* Xcore member: Obtuse
*/
#include <xs1.h>
#include <platform.h>
#define TIMESLICE 50000000
on stdcore [1] : port in ACTIVE = XS1_PORT_1A;
on stdcore [1] : port in SEND = XS1_PORT_1B;
on stdcore [1] : port in READY = XS1_PORT_1C;
on stdcore [1] : port in SELECT = XS1_PORT_1D;
on stdcore [0] : port out CHECK = XS1_PORT_1K;
on stdcore [1] : port out TEST = XS1_PORT_1E;
on stdcore [1] : port in OKAY = XS1_PORT_1F;
void checktest (out port hilo, int timeslice);
int main (void) {
par {
on stdcore [0] : checktest (CHECK, TIMESLICE);
on stdcore [1] : checktest (TEST, (TIMESLICE*3));
}
return 0;
}
void checktest (out port hilo, int timeslice)
{
timer tst;
unsigned cnt;
while (1)
{
hilo <: 1;
tst :> cnt;
tst when timerafter (cnt+ timeslice ) :> void;
hilo <: 0x0;
tst :> cnt;
tst when timerafter (cnt+ timeslice ) :> void;
}
}
Len