Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronic 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.

Register Log in

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....???
 

ckshivaram

Advanced Member level 5
Joined
Apr 21, 2008
Messages
5,070
Helped
2,146
Reputation
4,298
Reaction score
2,087
Trophy points
1,393
Location
villingen (Germany) / Bangalore
Activity points
30,097
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.....
 

KerimF

Advanced Member level 4
Joined
May 17, 2011
Messages
1,461
Helped
374
Reputation
756
Reaction score
370
Trophy points
1,363
Location
Syria
Activity points
12,314
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:
 

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
Are the 3 bits just 'not used' (somewhat like 'dont cares') or they are used for some other special purpose....???
 

KerimF

Advanced Member level 4
Joined
May 17, 2011
Messages
1,461
Helped
374
Reputation
756
Reaction score
370
Trophy points
1,363
Location
Syria
Activity points
12,314
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

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
Ok, understood... They are ignored.. But what advantage(or disadvantage) does it have when compared with mode 1, where all 8 bits are used...???
 

ckshivaram

Advanced Member level 5
Joined
Apr 21, 2008
Messages
5,070
Helped
2,146
Reputation
4,298
Reaction score
2,087
Trophy points
1,393
Location
villingen (Germany) / Bangalore
Activity points
30,097
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...........
 

KerimF

Advanced Member level 4
Joined
May 17, 2011
Messages
1,461
Helped
374
Reputation
756
Reaction score
370
Trophy points
1,363
Location
Syria
Activity points
12,314
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

bigdogguru

Administrator
Joined
Mar 12, 2010
Messages
9,831
Helped
2,348
Reputation
4,690
Reaction score
2,273
Trophy points
1,413
Location
Southwest, USA
Activity points
62,486
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:

8051 Tutorial: Timers

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

    banku

    points: 2
    Helpful Answer Positive Rating

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
Can someone tell about mode 3, its not found elaborately in many books.....
 

ckshivaram

Advanced Member level 5
Joined
Apr 21, 2008
Messages
5,070
Helped
2,146
Reputation
4,298
Reaction score
2,087
Trophy points
1,393
Location
villingen (Germany) / Bangalore
Activity points
30,097
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....
http://www.cecs.csulb.edu/~rallison/ppt/285ppt/Chapter_9.ppsx
 
  • Like
Reactions: KerimF

    KerimF

    points: 2
    Helpful Answer Positive Rating
Status
Not open for further replies.
Toggle Sidebar

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top