For 2ms delay. what should be the value of TH0 & TL0? Assuse that XTAL is 12 MHZ.

05 Feb 2022 Balmiki Mandal 0 8051 micro-controller

Understanding TH0 and TL0 in 8051 Microcontroller

The 8051 microcontroller is a widely used microcontroller in embedded systems. It comes equipped with a timer system that includes two 8-bit timers: Timer 0 (T0) and Timer 1 (T1). Each of these timers has associated registers known as TH0, TL0, TH1, and TL1. In this article, we'll focus on TH0 and TL0.

TH0 (Timer 0 High Byte) and TL0 (Timer 0 Low Byte)

Timer Basics:

  • Timer 0 is an 8-bit timer, meaning it can count from 0 to 255.
  • TH0 and TL0 together form a 16-bit register that works as a timer/counter.

Registers' Functionality:

TH0 (Timer 0 High Byte):

  • TH0 holds the most significant bits (MSBs) of the 16-bit timer value.
  • It can be read from or written to by the program.

TL0 (Timer 0 Low Byte):

  • TL0 holds the least significant bits (LSBs) of the 16-bit timer value.
  • Similarly, it can be read from or written to by the program.

Timer Mode:

  • Timer 0 can operate in two modes: 13-bit mode and 16-bit mode.
  • In 13-bit mode, TH0 is fixed at FCh (252 in decimal), and TL0 is loaded with an initial value.
  • In 16-bit mode, both TH0 and TL0 can be loaded with an initial value.

Timer/Counter Function:

  • TH0 and TL0 can be used as a timer to generate time delays or as counters to count external events.

Overflow and Interrupts:

  • When Timer 0 overflows (i.e., reaches its maximum value of 255), it sets the TF0 flag in the TCON register.
  • This can be used to trigger an interrupt, allowing the microcontroller to respond to the overflow event.

Applications:

  • TH0 and TL0 find applications in tasks that require precise timing, such as generating PWM signals, measuring time intervals, or interfacing with external devices.

Programming Considerations:

  • Programmers need to be mindful of the initial values loaded into TH0 and TL0 and understand the mode of operation (13-bit or 16-bit) that best suits their application.

 

For 2ms delay. what should be the value of TH0 & TL0? Assuse that XTAL is 12 MHZ.

  • 0xFC18
  • 0xFC1A
  • 0xF832 
  • 0xF830

ANS-> 0xF832 

Understanding TH0 and TL0 in the 8051 microcontroller is crucial for effective time management and control in embedded systems. By manipulating these registers, developers can create sophisticated applications with precise timing requirements.

For in-depth programming and utilization of TH0 and TL0, consult the manufacturer's datasheet and reference materials.

BY: Balmiki Mandal

Related Blogs

Post Comments.

Login to Post a Comment

No comments yet, Be the first to comment.