SlideShare a Scribd company logo
TIMERS  A HARDWARE EXPLANATION
WHAT IS TIMER? In general, timer is nothing but a process  of time being or time based operation. When coming to microcontroller, timer is a set of registers together doing the same time being operations. The difference is, in microcontroller the time being operation was depends on crystal oscillator we used in microcontroller.
Timers in 89C51 AT89c51 equipped with 2 timers, both of which may be controlled, set, read and configure individually. They are called as timer 0 and timer 1.
Functions of timers There are three general functions the timers in 89C51 have Keeping time and calculating the amount of the time between the events Counting the event themselves Generating baud rate for serial communication.
Measuring Time This is one of the primary work of the timers Another one is counting the events The meaning of the measuring the time is “measuring the interval time between two events”. Therefore it can also called as “interval timers” .
Time required to do the process? Since we already explained that timer was running under the frequency of microcontroller’s crystal oscillator and the atmel has 12 Tcycles for each machine cycle. When timer is in interval timer mode and correctly configured,it will increment by 1 for every machine cycle. Thus running timer will be incremented  11,059,200  /  12  =  921,583 times.
Timer’s SFR As we mentioned earlier, in 8051 we have two timers One is timer0 and another is timer1. These two timers shares 2 SFRs TCON timer control TMOD timer mode select Also these two timers have their own dedicated registers for sole purpose TL0 and TH0 for timer0 TL1 and TH1 for timer1
TMOD SFR operation First we will discuss about TMOD.. Each and every bit of the this mode will give an information to the microcontroller, how to run the timers. The MSB 4 bits(4 through 7) are allocated for timer 1 The LSB 4 bits(0 through 3) are allocated for timer 0 Each 4 bits holds the information about the operation of timer
Mode 0 – 13 bit timer This is just a relic for microcontroller, which never used in any operation. But for our knowledge, It is a13 bit mode, that means the TLx will count 0 to 31 and reset to 0 and increment 1 to THx, THx will increment like this upto 255. Totally 13 bits are used and its limitation of data is 8192 values only. If you set a 13-bit mode, it will overflow after 8192 machine cycle.
Mode 1 – 16 bit timer It is similar to mode 0 except it uses all 16 bits. Therefore TLx increment from 0 to 255,when it reaches 255 it resets TLx and increment THx by 1. Since 16 bits are used in this mode, 65,536 distinct values can be accessed using this mode. When 65,536 machine cycles are over, the timer will be overflow in the microcontroller and reset to 0.
Mode 2 – auto reload timer It is an 8 bit auto reload mode. When the timer is in 8 bit auto reload mode, THx holds the reload value and TLx is the timer itself here. TLx starts counting and reaches 255. When it reaches 255, instead of resetting to 0, it loads the value stored in THx. That’s why it is called as 8 – bit Auto reload mode.
Mode 3 split timer When this mode is activated, the timer will split itself into two timers. For example, if this mode is used in timer0 then timer0 splits into two 8 bit timer, i.e.,  TL0 is timer0 and TH0 is timer1. All bits tied up to timer1 will tied up with TH0 now. TL0 and TH0 increment to 255 and resets to 0 individually.
TCON SFR This SFR is located in 0x88. In the 8 bits of this SFR only 4 bits of MSB required to be set to run the timer Those are TF1  TR1  TF0  TR0  This TCON is bit addressable, therefore if you want to set any particular bit, then it is easy to do it without disturbing other bits.
Initializing the timer  The first thing to be decided while initializing the timer is selecting the mode of operation. For 16-bit you have to select mode 1 For 8-bit auto reload mode you have to select mode 2 This is depends on your application or use of timer in you system.
Reading the values of timer There are three methods using this timers Read the TL and TH  values as 16- bit value Read the TL and TH as separate 8 bit values Calculate weather the timer is overflowed or not.
Detection of timer overflow It is very easy to check the timer overflow rather than the exact value of timer. Whenever the timer reset to 0 from a highest value the TFx  in the TCON SFR will be set. Therefore if timer 0 get overflowed then TF0 will be set If timer 1 get overflowed then TF1 will be set
Second purpose of timer The second purpose of the timer is event counting There are two methods in event counting. Counting the length of the event(eg., how many hours the tube light glown today) Counting the number of occurrence of that event(eg., how many cars has passed this way) Depends upon the purpose the method of usage varies.
Assignments Use timer in a delay process Use timer for counting purpose Generate a delay of 1 second Generate a square wave of 1 Khz. Generate a square wave using timer 0 generate a saw tooth wave using timer 1 at the same time

More Related Content

PPTX
Ppt
PDF
Timers and counters of microcontroller 8051
PDF
8051 Timers / Counters
DOCX
8096 microcontrollers notes
PPTX
Introduction to Digital Signal processors
PPT
ARM Architecture
PPT
SPI Bus Protocol
Ppt
Timers and counters of microcontroller 8051
8051 Timers / Counters
8096 microcontrollers notes
Introduction to Digital Signal processors
ARM Architecture
SPI Bus Protocol

What's hot (20)

PPT
Real time-embedded-system-lec-02
PPTX
Ch 1 introduction to Embedded Systems (AY:2018-2019--> First Semester)
PPT
80486 microprocessor
PPTX
8051 timer counter
PPTX
COMPUTER INSTRUCTIONS & TIMING & CONTROL.
PPTX
Advanced Pipelining in ARM Processors.pptx
PPTX
Embedded Product Development Life Cycle(EDLC)
PDF
COMPUTER ORGANIZATION NOTES Unit 2
PPTX
INTERRUPTS OF 8086 MICROPROCESSOR
PDF
Unit II arm 7 Instruction Set
PDF
Unit 2 mpmc
PPTX
Minimum Modes and Maximum Modes of 8086 Microprocessor
PPTX
8086 microprocessor-architecture
PPT
Prioritizing handoffs
PDF
Memory interfacing of microcontroller 8051
PPTX
PIC-18 Microcontroller
PPT
PPTX
Interrupts on 8086 microprocessor by vijay kumar.k
DOCX
Study of 8051 microcontroller
PDF
Digital logic-formula-notes-final-1
Real time-embedded-system-lec-02
Ch 1 introduction to Embedded Systems (AY:2018-2019--> First Semester)
80486 microprocessor
8051 timer counter
COMPUTER INSTRUCTIONS & TIMING & CONTROL.
Advanced Pipelining in ARM Processors.pptx
Embedded Product Development Life Cycle(EDLC)
COMPUTER ORGANIZATION NOTES Unit 2
INTERRUPTS OF 8086 MICROPROCESSOR
Unit II arm 7 Instruction Set
Unit 2 mpmc
Minimum Modes and Maximum Modes of 8086 Microprocessor
8086 microprocessor-architecture
Prioritizing handoffs
Memory interfacing of microcontroller 8051
PIC-18 Microcontroller
Interrupts on 8086 microprocessor by vijay kumar.k
Study of 8051 microcontroller
Digital logic-formula-notes-final-1
Ad

Viewers also liked (20)

PPTX
6 weeks training on Embedded System
PPT
Embedded System
PDF
Leap embedded system_profile
PPT
introduction to Embedded System
PDF
8051 microcontrollers ch3
DOCX
EDLC-EMBEDDED PRODUCT DEVELOPMENT LIFE CYCLE
PPTX
Summer training embedded system and its scope
PDF
Enabling embedded security for the Internet of Things
PPTX
Embedded System Practical Workshop using the ARM Processor
PPTX
Embedded system
PPTX
Embedded System
PDF
Embedded System
PDF
Introduction to Embedded System
PPTX
Embedded System Design latest
PPT
Embedded system design process
PDF
Embedded Systems Security: Building a More Secure Device
PDF
An entire concept of embedded systems entire ppt
PPTX
EMBEDDED WEB SERVER
PDF
Security in Embedded systems
PPTX
introduction to Embedded System Security
6 weeks training on Embedded System
Embedded System
Leap embedded system_profile
introduction to Embedded System
8051 microcontrollers ch3
EDLC-EMBEDDED PRODUCT DEVELOPMENT LIFE CYCLE
Summer training embedded system and its scope
Enabling embedded security for the Internet of Things
Embedded System Practical Workshop using the ARM Processor
Embedded system
Embedded System
Embedded System
Introduction to Embedded System
Embedded System Design latest
Embedded system design process
Embedded Systems Security: Building a More Secure Device
An entire concept of embedded systems entire ppt
EMBEDDED WEB SERVER
Security in Embedded systems
introduction to Embedded System Security
Ad

Similar to Timers (20)

PPTX
TIMERS.pptx
PPTX
8051 Timers and Counters
PPTX
8051 MICROCONTROLLER TIMER AND ITS APPLICATIONS
PPTX
Timers
PPTX
89C51 PROGRAMMING in Unit-4 of Microprocessor
PPT
lecture 12 counter_microcontroller2.ppt
PPT
8051 microcontroller timer summary presentation
PPT
Microcontroller Timer Counter Modules and applications
PPT
Timers
PDF
8051 Timers, Interrupts and Serial Communication
PPTX
8051 timer counter
PDF
8051 timers--2
PPTX
PPT
8051e
PPTX
6-Interrupts Programming-27-03-2024.pptx
PPTX
KTU_Microprocessor and Microcontrollers_Module2
PPTX
Module-03 Timers and serial port communication
PDF
8051 Microcontroller Timer
PPTX
5-Timer Mode 2 Programming-18-03-2024.pptx
PDF
SE PAI Unit 5_Timer Programming in 8051 microcontroller_Part 1
TIMERS.pptx
8051 Timers and Counters
8051 MICROCONTROLLER TIMER AND ITS APPLICATIONS
Timers
89C51 PROGRAMMING in Unit-4 of Microprocessor
lecture 12 counter_microcontroller2.ppt
8051 microcontroller timer summary presentation
Microcontroller Timer Counter Modules and applications
Timers
8051 Timers, Interrupts and Serial Communication
8051 timer counter
8051 timers--2
8051e
6-Interrupts Programming-27-03-2024.pptx
KTU_Microprocessor and Microcontrollers_Module2
Module-03 Timers and serial port communication
8051 Microcontroller Timer
5-Timer Mode 2 Programming-18-03-2024.pptx
SE PAI Unit 5_Timer Programming in 8051 microcontroller_Part 1

More from PRADEEP (20)

PPT
Unit 3 tables and data structures
PPT
Unit 2 software partitioning
PPT
Unit 1 introduction
PPT
Unit 5 multi-board system
PDF
16f877
PDF
Mp lab
PDF
19199406 embedded-c-tutorial-8051
PDF
13986149 c-pgming-for-embedded-systems
PDF
22323006 embedded-c-tutorial-8051
PDF
14157565 embedded-programming
PPT
Rtos 3 & 4
DOCX
Introduction to pic
PPT
Interrupts
PPTX
Chapter 3
PPT
Leadership lessons-from-obama-
PPT
Programming timers
PPT
Interfacing stepper motor
PPT
Interfacing rs232
PPT
Interfacing keypad
PPT
Interfacing adc
Unit 3 tables and data structures
Unit 2 software partitioning
Unit 1 introduction
Unit 5 multi-board system
16f877
Mp lab
19199406 embedded-c-tutorial-8051
13986149 c-pgming-for-embedded-systems
22323006 embedded-c-tutorial-8051
14157565 embedded-programming
Rtos 3 & 4
Introduction to pic
Interrupts
Chapter 3
Leadership lessons-from-obama-
Programming timers
Interfacing stepper motor
Interfacing rs232
Interfacing keypad
Interfacing adc

Timers

  • 1. TIMERS A HARDWARE EXPLANATION
  • 2. WHAT IS TIMER? In general, timer is nothing but a process of time being or time based operation. When coming to microcontroller, timer is a set of registers together doing the same time being operations. The difference is, in microcontroller the time being operation was depends on crystal oscillator we used in microcontroller.
  • 3. Timers in 89C51 AT89c51 equipped with 2 timers, both of which may be controlled, set, read and configure individually. They are called as timer 0 and timer 1.
  • 4. Functions of timers There are three general functions the timers in 89C51 have Keeping time and calculating the amount of the time between the events Counting the event themselves Generating baud rate for serial communication.
  • 5. Measuring Time This is one of the primary work of the timers Another one is counting the events The meaning of the measuring the time is “measuring the interval time between two events”. Therefore it can also called as “interval timers” .
  • 6. Time required to do the process? Since we already explained that timer was running under the frequency of microcontroller’s crystal oscillator and the atmel has 12 Tcycles for each machine cycle. When timer is in interval timer mode and correctly configured,it will increment by 1 for every machine cycle. Thus running timer will be incremented 11,059,200 / 12 = 921,583 times.
  • 7. Timer’s SFR As we mentioned earlier, in 8051 we have two timers One is timer0 and another is timer1. These two timers shares 2 SFRs TCON timer control TMOD timer mode select Also these two timers have their own dedicated registers for sole purpose TL0 and TH0 for timer0 TL1 and TH1 for timer1
  • 8. TMOD SFR operation First we will discuss about TMOD.. Each and every bit of the this mode will give an information to the microcontroller, how to run the timers. The MSB 4 bits(4 through 7) are allocated for timer 1 The LSB 4 bits(0 through 3) are allocated for timer 0 Each 4 bits holds the information about the operation of timer
  • 9. Mode 0 – 13 bit timer This is just a relic for microcontroller, which never used in any operation. But for our knowledge, It is a13 bit mode, that means the TLx will count 0 to 31 and reset to 0 and increment 1 to THx, THx will increment like this upto 255. Totally 13 bits are used and its limitation of data is 8192 values only. If you set a 13-bit mode, it will overflow after 8192 machine cycle.
  • 10. Mode 1 – 16 bit timer It is similar to mode 0 except it uses all 16 bits. Therefore TLx increment from 0 to 255,when it reaches 255 it resets TLx and increment THx by 1. Since 16 bits are used in this mode, 65,536 distinct values can be accessed using this mode. When 65,536 machine cycles are over, the timer will be overflow in the microcontroller and reset to 0.
  • 11. Mode 2 – auto reload timer It is an 8 bit auto reload mode. When the timer is in 8 bit auto reload mode, THx holds the reload value and TLx is the timer itself here. TLx starts counting and reaches 255. When it reaches 255, instead of resetting to 0, it loads the value stored in THx. That’s why it is called as 8 – bit Auto reload mode.
  • 12. Mode 3 split timer When this mode is activated, the timer will split itself into two timers. For example, if this mode is used in timer0 then timer0 splits into two 8 bit timer, i.e., TL0 is timer0 and TH0 is timer1. All bits tied up to timer1 will tied up with TH0 now. TL0 and TH0 increment to 255 and resets to 0 individually.
  • 13. TCON SFR This SFR is located in 0x88. In the 8 bits of this SFR only 4 bits of MSB required to be set to run the timer Those are TF1 TR1 TF0 TR0 This TCON is bit addressable, therefore if you want to set any particular bit, then it is easy to do it without disturbing other bits.
  • 14. Initializing the timer The first thing to be decided while initializing the timer is selecting the mode of operation. For 16-bit you have to select mode 1 For 8-bit auto reload mode you have to select mode 2 This is depends on your application or use of timer in you system.
  • 15. Reading the values of timer There are three methods using this timers Read the TL and TH values as 16- bit value Read the TL and TH as separate 8 bit values Calculate weather the timer is overflowed or not.
  • 16. Detection of timer overflow It is very easy to check the timer overflow rather than the exact value of timer. Whenever the timer reset to 0 from a highest value the TFx in the TCON SFR will be set. Therefore if timer 0 get overflowed then TF0 will be set If timer 1 get overflowed then TF1 will be set
  • 17. Second purpose of timer The second purpose of the timer is event counting There are two methods in event counting. Counting the length of the event(eg., how many hours the tube light glown today) Counting the number of occurrence of that event(eg., how many cars has passed this way) Depends upon the purpose the method of usage varies.
  • 18. Assignments Use timer in a delay process Use timer for counting purpose Generate a delay of 1 second Generate a square wave of 1 Khz. Generate a square wave using timer 0 generate a saw tooth wave using timer 1 at the same time