I have lifted the following code from this post, but it doesn't compile.
Should this code work? Has anybody tested it? Can anybody post a working solution for the XC-1A board?
Note sure what to try next, any help greatly appreciated
Chendy
Code: Select all
/*
============================================================================
Name : xc1a-concurrent-led.xc
Description : Illuminate multiple LEDs concurrently on the XC-1A board
============================================================================
*/
#include <platform.h>
#define PERIOD 100000000
#define PERIODA 20000000
#define PERIODB 300000000
#define PERIODC 400000000
on stdcore [0] : out port cled0 = PORT_CLOCKLED_0;
on stdcore [1] : out port cled1 = PORT_CLOCKLED_1;
on stdcore [2] : out port cled2 = PORT_CLOCKLED_2;
on stdcore [3] : out port cled3 = PORT_CLOCKLED_3;
on stdcore [0] : out port cledG = PORT_CLOCKLED_SELG;
on stdcore [0] : out port cledR = PORT_CLOCKLED_SELR;
void flashLED (out port led, int timeout){
timer tmr;
unsigned t;
unsigned isOn = 0b01110000;
while(1){
tmr :> t;
led <: isOn;
t += timeout;
tmr when timerafter (t) :> void;
isOn = !isOn;
}
}
int main (void) {
par {
on stdcore [0]: { cledR <: 1;
flashLED (cled0 , PERIOD);
}
on stdcore [1]: flashLED (cled1, PERIODA);
on stdcore [2]: flashLED (cled2, PERIODB);
on stdcore [3]: flashLED (cled3, PERIODC);
}
return 0;
}