Newbie - TIMERS

Do you have a question? Post it now! No Registration Necessary

Translate This Thread From English to

Threaded View
Hello,

I'm quite lost with the configuration of the timers reload.

For example: my 8051 is working at 6MHZ, and I want an interruption on
the timer0 each 1 ms, How should I configure TH0 and TL0?

And please, explain me how must be calculated for different interval
values cause I want to learn as well.

Thank you.


Re: Newbie - TIMERS
Quoted text here. Click to load it

Don't know about the 8051 (and it probably varies between the dozens of
8051 families - it pays to be specific in questions), but timer
peripherals all work in pretty much the same way for simple interrupts.
  The reference clock (6 MHz here) passes through a
divide-by-power-of-two prescaler, which may be fixed or configurable
(see your specific chip's datasheet), and clocks a counter.  The counter
may be 8-bit or 16-bit (or more, for some micros) - I'm guessing you
have a 16-bit timer here.  The counter either counts up to a set value
and interrupts on overflow, or counts down from the set value and
interrupts on underflow.  Either way, the counter target value is
calculated in the same way - take your reference frequency, divide it by
the prescaler, and then by your target frequency, to get the counter
value.  E.g., for a prescaler of 4, this would give you: 6,000,000 / 4 /
1,000 = 1500.  Put (1500 div 256) = 5 in the  high register, and (1500
mod 256) = 220 in the low register.  For some timers, you should use one
less that this count value if you are being precise - check your datasheet.

You also have to set up the prescaler, start the timer, enable
interrupts, and so on.

Re: Newbie - TIMERS

Quoted text here. Click to load it

Hey.


http://www.8052.com has all the 8051/2 info you will ever need.  A timer
tutorial is located at http://www.8052.com/tuttimer.phtml

Quoted text here. Click to load it

mmmKay

--
========================================================================
          Michael Kesti            |  "And like, one and one don't make
We've slightly trimmed the long signature. Click to see the full one.

Site Timeline