2005-01-16 11:19 PM
Calculating a delay/timer for 100 microseconds
2005-01-16 06:41 PM
Hello i am using a st7lite29 and need a delay of 100 microsecond. Is this possible with the autoreloadtimer? I mean the 8-bit Timer B!!! Cause I dont exactly know how to calculate it! Is ther e anyone who can give me a hint??
Any help would be appreciated Bjørn [ This message was edited by: B_buerke on 17-01-2005 08:12 ]2005-01-16 11:19 PM
Hello Bjørn!
You can measure a 100 us time with the LITE TIMER 2. The max error is 32 main clock pulses, 'cause it is feed by the output of a 32 divider (see Figure 40 of the datasheet) whose value is unknown when your code starts measuring the delay. If you can allow this error, these are the steps: 1) be sure that LTARR contains $FF BEFORE you start measuring the delay. If you plan to ''fire'' an interrupt when the delay will be timed out, disable it. 2) to start measuring a 100 us delay put 230 = 255-25 in LTARR (notice 100us = 25 * 32 clock pulses @ 8MHz) 3) if you plan to use interrupts, enable LTTB2 interrupt (set bit TB2IE in LTCSR2) 4) when the next LTCNTR overflow will happen (bit TB2F = 1 in LTCSR2), LTCNTR will start to measure the delay. This time is useful to restore $FF in LTARR. 5) when the next owerflow will happen, your delay is expired so you can do whatever you need. I hope I was clear, Regards, EtaPhi