Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

8051-Doubts regarding timers

Status
Not open for further replies.

banku

Newbie level 5
Joined
Apr 12, 2011
Messages
8
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,331
Hello friends,

In mode 0 operation of both the timers of 8051(timer 0 and timer 1),the lower order timers(TL0 and TL1) are configured as 5 bit timers. Even though their full capacity is 8 bits, why only 5 is used. What use the remaining 3 bits have....???
 

As far as i know timers can be configured in 8 bit, 13 bit and 16 bit... your question is vague.. can you explain a still more better way........ what values you load into it and the time you need is also a factor.....
 

Hello friends,

In mode 0 operation of both the timers of 8051(timer 0 and timer 1),the lower order timers(TL0 and TL1) are configured as 5 bit timers. Even though their full capacity is 8 bits, why only 5 is used. What use the remaining 3 bits have....???

This is exactly the idea of mode 0... not to use these 3 bits :wink:
 

Are the 3 bits just 'not used' (somewhat like 'dont cares') or they are used for some other special purpose....???
 

Good question... 'don't care'.

So whatever a MOV puts in TL0 or TL1, their bit5, bit6 and bit7 are ignored.
 
  • Like
Reactions: banku

    banku

    Points: 2
    Helpful Answer Positive Rating
Ok, understood... They are ignored.. But what advantage(or disadvantage) does it have when compared with mode 1, where all 8 bits are used...???
 

the timer value window decreases, you can generate delay of shorter duration ...........

---------- Post added at 12:05 ---------- Previous post was at 12:04 ----------

from 1.085micro sec to 71.1 milliseconds...........
 

Ok, understood... They are ignored.. But what advantage(or disadvantage) does it have when compared with mode 1, where all 8 bits are used...???

Another good question... to be honest with you... I use mode 0 rarely. In some applications, we may be content to load only TH0 when an interrupt (due to its overflow) occurs to prepare Timer0 for the next interrupt while leaving TL0 as it is (by the way, when the interrupt occurs TL0=0). So the unit step of the timer0 delay is 32 cycles (32us if 12MHz) in this case, that is incrementing the initial value of TH0 by 1, the delay decreases by 32 cycles. Also by doing this, we don't need to clear TR0 to change TH0 then set TR0 again, because we can just reload TH0 at the start of the timer0 interrupt routine while TL0 is within its first 32 counts.

Added:
If we like do the same in mode 1 , the step would be 256 cycles which is rather big.
 
Last edited:
  • Like
Reactions: banku

    banku

    Points: 2
    Helpful Answer Positive Rating
Actually Mode 0 is a relic from the days of the 8048.

8051 Mode 0 History:

13-bit Time Mode (mode 0)

Timer mode "0" is a 13-bit timer. This is a relic that was kept around in the 8051 to maintain compatability with its predecesor, the 8048. Generally the 13-bit timer mode is not used in new development.

When the timer is in 13-bit mode, TLx will count from 0 to 31. When TLx is incremented from 31, it will "reset" to 0 and increment THx. Thus, effectively, only 13 bits of the two timer bytes are being used: bits 0-4 of TLx and bits 0-7 of THx. This also means, in essence, the timer can only contain 8192 values. If you set a 13-bit timer to 0, it will overflow back to zero 8192 machine cycles later.

Again, there is very little reason to use this mode and it is only mentioned so you wont be surprised if you ever end up analyzing archaeic code which has been passed down through the generations (a generation in a programming shop is often on the order of about 3 or 4 months).

Quoted from the following link:

**broken link removed**

A fairly good discussion of 8051 timer modes.
 
  • Like
Reactions: banku

    banku

    Points: 2
    Helpful Answer Positive Rating
Can someone tell about mode 3, its not found elaborately in many books.....
 

Timer mode "3" is a split-timer mode. When Timer 0 is placed in mode 3, it essentially becomes two separate 8-bit timers. That is to say, Timer 0 is TL0 and Timer 1 is TH0. Both timers count from 0 to 255 and overflow back to 0. All the bits that are related to Timer 1 will now be tied to TH0.

While Timer 0 is in split mode, the real Timer 1 (i.e. TH1 and TL1) can be put into modes 0, 1 or 2 normally--however, you may not start or stop the real timer 1 since the bits that do that are now linked to TH0. The real timer 1, in this case, will be incremented every machine cycle no matter what.

The only real use I can see of using split timer mode is if you need to have two separate timers and, additionally, a baud rate generator. In such case you can use the real Timer 1 as a baud rate generator and use TH0/TL0 as two separate timers.

---------- Post added at 19:27 ---------- Previous post was at 19:08 ----------

see this if you can understand....
**broken link removed**
 
  • Like
Reactions: KerimF

    KerimF

    Points: 2
    Helpful Answer Positive Rating
Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top