Your SlideShare is downloading. ×
Timers
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Timers

2,939
views

Published on

timers in 8051 microcontroller.

timers in 8051 microcontroller.

Published in: Education, Technology, Business

1 Comment
9 Likes
Statistics
Notes
  • 8051 , nice core for quick project
    thanks
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
No Downloads
Views
Total Views
2,939
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
189
Comments
1
Likes
9
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. TIMER
  • 2. TIMERS
    • The 8051 has two Timers/Counters.
    • Timer 0 and Timer 1.
    • Both have 16 bits.
    • Accessed as low byte (TL) and high byte (TH).
    • The TIMER action is controlled by two more SFR's Registers
      • Timer Mode Control Register( TMOD) .
      • Timer/Counter Control Register ( TCON ). 
  • 3. TH and TL
    • The TIMERS are divided into two 8-bit called Timer LOW (TL0, TL1) & Timer HIGH (TH0, TH1)
    • These registers contain the latest count of the TIMER.
    • TL0 - 8A , TL1 8B,
    • TH0 - 8C , TH1 8D.
  • 4. TMODE
    • TMOD (timer mode), to set the various timer operation modes.
    • TMOD is 8 bit register.
      • The lower 4 bits are for Timer 0.
      • The upper 4 bits are for Timer 1.
      • The lower 2 bits of nibble are used to set the timer mode.
      • The upper 2 bits to specify the operation.
  • 5. TMODE TIMER 1 TIMER 0 M0 M1 C/ T GATE M0 M1 C/ T GATE
  • 6.
    • C/T - Timer or counter selector.
    • Gate - to select software or hardware to select the timer run/stop bit.
      • Gate = 0 software control the timer run/stop bit.
      • Gate = 1 hardware control the timer run/stop bit.
    • M1 & M0 to select the timer mode.
  • 7. TIMER MODES Split mode 3 1 1 8 bit auto reload 2 0 1 16 bit timer 1 1 0 13 bit timer 0 0 0 OPERATIONS MODE M0 M1
  • 8. TCON REGISTER
    • The lower 4 bits are set aside for controlling the interrupt bits.
    • The upper four bits are used to store the TF and TR bits of both timer 0 and 1.
    IT0 IE0 IT1 IE1 TR0 TF0 TR1 TF1
  • 9.
    • TF - is the overflow flag.
    • TR – is the run/stop control bit of Timers.
  • 10. MODE 1
    • 16 bit timer.
    • Range is 0000 to FFFFh.
    • TH and TL are loaded with a 16-bit initial value.
    • It counts up until it reaches its limit of FFFFh.
    • When it rolls over from FFFFH to 0000, it sets overflow flag TF (timer flag).
  • 11.
    • To calculate the values to be loaded into the TL and TH registers.
    • Divide the desired time delay by 1.085 us.
    • Perform 65536 – n, where n is the decimal value we got in Step1
    • Convert the result of Step2 to hex, where yyxx is the initial hex value to be loaded into the timer’s register.
    • Set TL = xx and TH = yy.
  • 12. MODE 0
    • It is an 13-bit timer.
    • Range is 000 to 1FFFh.
    • TH and TL are loaded with a 13-bit initial value.
    • It counts up until it reaches its limit of 1FFFh.
    • When it rolls over from 1FFFH to 0000, it sets overflow flag TF (timer flag).
  • 13. MODE 2
    • It is an 8-bit timer.
    • It allows only values of 00 to FFH.
    • TH is loaded with the 8-bit value ,then the 8051 gives a copy of it to TL.
    • After the timer is started, it starts to count up by incrementing the TL register.
    • It counts up until it reaches its limit of FFH.
  • 14.
    • When it rolls over from FFH to 00, it sets high the TF (timer flag).
    • When TF is set to 1, TL is reloaded automatically with the original value kept by the TH register
    • This mode is also called Auto reload mode.
  • 15. MODE 3
    • Timer mode 3 is a split-timer mode.
    • When Timer 0 is placed in mode 3, it essentially becomes two separate 8-bit timers.
    • Timer 0 is TL0 and Timer 1 is TH0.
    • Both timers count from 0 to 255 and overflow back to 0.
    • the control bit TR1 and the timer 1 flag TFI are then used by timer 0.
  • 16. Thank you

×