To find value for 8051 Timers to program in MODE 2

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

Translate This Thread From English to

Threaded View


Dear Experts,
               I am Ravikumar.N, working on Atmel At89c52
microcontroller. I have an issue regarding the Timers of the controller
to be used in mode 2.

1)I want to generate a delay of 200 microseconds in MODE 2.

2) I dont know what value to be loaded to the TH and TL register of the
TIMER.

3) I need to know how to calculate these value(which are to be loaded
to TH and TL register).

I went through the manual of the controller, I didn't get any
explaination regarding the calculation of the value to be loaded to the
TIMER registers(TH, TL).

I am in need of the calculation

Please guide me.


With Regards,
        Ravikumar.N


Re: To find value for 8051 Timers to program in MODE 2
Quoted text here. Click to load it

You need to know that the counters count up. When it rolls over, you get an
interrupt, if enabled. The counter can be clocked from the CPU's clock and
there is a prescaler between the clock and the counter. So the frequency of
the counter is the clock frequency divided by the prescale factor.

Example:
Your CPU clock is 8MHz. The prescaler is set to 1. Then T2 counts up in
125ns increments. You need 200us.
200us / 125ns = 1600 ticks. Since the counter counts up, you need to load
65536 - 1600 = 63936 or 0xF9C0 in TH,TL.

The clock source, prescaler and counter interoperation is in the datasheet.

Regards,
Meindert



Re: To find value for 8051 Timers to program in MODE 2
Thanks Sprang,
              The problem is MODE 2 is an 8-bit counter,the value that
is obtained from your calculation is a 16-bit value. I need an 8-bit
value to program the TIMERS in MODE 2. Please tell me how to get this
8-bit value.

Regards,
     Ravikumar.N
Meindert Sprang wrote:
Quoted text here. Click to load it


Re: To find value for 8051 Timers to program in MODE 2
Quoted text here. Click to load it

The same way as to obtain the 16 bit value. You just need to program a
higher prescaler value in order to get the result of the calculation below
256.

Meindert



Site Timeline