I have hacked out a rough start for a shutter control project. There's some details here:
http://xcore.com/projects/xmos-fast-shutter-control
I have a couple of questions that I hope you might enlighten me on.
From the openShutter function in the code block below, a couple of questions:
- * For an unsigned int, clock counters are limited to maximum lengths of ~42 seconds, right? How can I get timers longer than that?
* What is the difference between waiting for a clock value usingand telling an operation to occur at a particular clock value usingCode: Select all
tmr when timerafter ( time ) :> void ; shutter <: 1;
Code: Select all
shutter @ time <: 1
Code: Select all
void openShutter(out port shutter, in port notscan, unsigned int stime)
{
timer tmr;
// an unsigned int for the time should allow for exposure times up to
// 42.94 seconds - 4,294,967,295 cycles * 10 ns/cycle
unsigned int time;
//notscan when pinseq(1) :> void;
tmr :> time;
// sleep for preset delay
time += SETUP_DELAY;
// open shutter for setting.stime by turning on shutter port
tmr when timerafter ( time ) :> void ;
shutter <: 1;
time += stime;
tmr when timerafter ( time ) :> void ;
shutter <: 0;
//
}
Code: Select all
unsigned int rxInt(in port rxd)
{
unsigned int rlt, time;
// Wait for start bit
rxd when pinseq (0) :> void @ time;
time += BIT_TIME / 2;
// Input data bits
for (int i = 0; i < 32; i++) {
time += BIT_TIME;
rxd @ time :> >> rlt;
}
// Input stop bit
time += BIT_TIME;
rxd @ time :> void;
return rlt;
}