Code: Select all
#include <xs1.h>
#define DELAY 10000000
out port ld1 = XS1_PORT_1A; // Declare use of 1 bit port A as output
int main(void) {
timer t; // Declare a timer resource
int time; // Declare something to store timer output
t :> time; // get current timer value
while(1) { // loop forever
ld1 <: 0; // LED off
t when timerafter(time+DELAY) :> time; // Wait 10*DELAY nSecs
ld1 <: 1; // LED on
t when timerafter(time+DELAY) :> time; // Wait 10*DELAY nSecs
}
return 0;
}
(StartKit has 2 LEDs connecetd to 1 bit ports)
P.S. Although this example works it might not be a very Xmos way of doing it, a while select loop with timerafter case would be better but introduces even more unfamiliar features.
regards
Al