I've posted some code below that illustrates my problem - is anybody able to glance at this and see what I have misunderstood?
Many thanks
Jonny.
Code: Select all
out port p_led = on tile[0]:XS1_PORT_4F;
clock clk = XS1_CLKBLK_1;
int main()
{
int count, i;
#if 1
// Experimenting with clocked port
printf("clocked port\n");
configure_clock_ref(clk, 0);
configure_out_port(p_led, clk, 0);
start_clock(clk);
p_led <: 0x1 @ count;
while(1)
{
// I would expect this to give an equal mark-to-space ratio, but it doesn't
for (i = 0; i < 5000; i++)
{
count += 1000000;
p_led @ count <: 0x2;
}
for (i = 0; i < 500; i++)
{
count += 10000000;
p_led @ count <: 0xC;
}
}
#else
// Experimenting with timer, instead
timer t;
printf("timer\n");
t :> count;
while(1)
{
// This gives an equal mark-to-space ratio as I would expect
for (i = 0; i < 50; i++)
{
count += 1000000;
t when timerafter(count) :> void;
p_led <: 0x2;
}
for (i = 0; i < 10; i++)
{
count += 5000000;
t when timerafter(count) :> void;
p_led <: 0xC;
}
}
#endif
return 0;
}