I'm new at the XMOS community, I read the programming guide and manipulate the tcp/ip example every thing is fine but since I tried to implement a stupid PWM I'm going crazy.
This is my minimum example for the Startkit the LED flash but not as long as i suspected
Code: Select all
/*
* Stupid.xc
*
*/
#include <xs1.h>
#include <timer.h>
out port d1 = XS1_PORT_1A;
void dimm(out port p)
{
timer tmr;
unsigned int timestamp;
unsigned int delay = 100000000;
unsigned int dimmvalue = delay*0.5;
unsigned int portstamp;
tmr :> timestamp;
p <: 0 @ portstamp;
while(1)
{
select
{
case tmr when timerafter(timestamp) :> void:
p <: 1 @ portstamp;
portstamp += dimmvalue;
p @ portstamp <: 0;
timestamp += delay;
break;
}
}
}
int main()
{
par
{
dimm(d1);
}
return 0;
}