There are four Timer modes that allow you to measure the number of clock cycles between consecutive rising or falling edges. Two 16 bit, and two 32 bit. Using these modes is just a matter of performing all the basic steps we've described:
1) Enable a Timer:
AddRequest(ID, LJ_ioPUT_CONFIG, LJ_chNUMBER_TIMERS_ENABLED, 1, 0, 0)
2) Set the mode:
AddRequest(ID, LJ_ioPUT_TIMER_MODE, 0, LJ_tmRISINGEDGE32, 0, 0)
The four modes are:
LJ_tmRISINGEDGES32
LJ_tmFALLINGEDGES32
LJ_tmRISINGEDGES16
LJ_tmFALLINGEDGES16
Note the plural form of Edge!
3) Set the clock frequency and divisor:
// use system clock so works on U3 and UE9:
AddRequest(ID, LJ_ioPUT_CONFIG, LJ_chTIMER_CLOCK_BASE, LJ_tcSYS, 0, 0)
AddRequest(ID, LJ_ioPUT_CONFIG, LJ_chTIMER_CLOCK_DIVISOR, 48, 0, 0)
4) GoOne() to actually execute the commands:
GoOne(ID)
5) Create a channel to read the Timer. I/O Type is Timer, Channel # is the timer #, in this case 0.
The difference between the rising and falling edge versions of these modes is self explanatory. The 32 bit versions allow you to measure longer lengths with higher clock frequencies, and thus higher resolution for long periods, but are subject to small errors because it is interrupt driven. If your lengths are short enough that the edges will always occur within 65535 clock cycles, you should use the 16 bit versions as they are not subject to the interrupt errors.
If you want to read the timer from script, you can use LJ_ioGET_TIMER:
private datain
eGet(ID, LJ_ioGET_TIMER, 0, @datain, 0)