Skip to main content
Visitor II
January 17, 2005
Question

Calculating a delay/timer for 100 microseconds

  • January 17, 2005
  • 2 replies
  • 1040 views
Posted on January 17, 2005 at 08:19

Calculating a delay/timer for 100 microseconds

    This topic has been closed for replies.

    2 replies

    b_buerkeAuthor
    Visitor II
    January 17, 2005
    Posted on January 17, 2005 at 03:41

    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 ]

    Visitor II
    January 17, 2005
    Posted on January 17, 2005 at 08:19

    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