Discuss: 1. TMOD, TCON, IE and IP register2. Procedure (Steps) for Time Delay calculation with an example
Question
Discuss:
-
TMOD, TCON, IE and IP register
-
Procedure (Steps) for Time Delay calculation with an example
Solution
-
TMOD, TCON, IE and IP Register:
-
TMOD Register: This is the Timer Mode Register. It is used to define the operation (mode) of the timers 0 and 1. It can be used to set the timers for 16-bit or 8-bit mode, auto-reload, and other features.
-
TCON Register: This is the Timer Control Register. It is used to start or stop the timers and to configure the way the timers count (up or down).
-
IE Register: This is the Interrupt Enable Register. It is used to enable or disable specific interrupts. Each bit in the register corresponds to a specific interrupt.
-
IP Register: This is the Interrupt Priority Register. It is used to set the priority of the interrupts. If two interrupts occur at the same time, the one with the higher priority (set in the IP register) is handled first.
-
-
Procedure for Time Delay Calculation:
The steps for calculating a time delay using a timer are as follows:
Step 1: Choose the timer mode in the TMOD register.
Step 2: Load the TH (Timer High) and TL (Timer Low) registers with the initial count. The initial count is calculated based on the desired delay and the clock frequency.
Step 3: Start the timer by setting the appropriate bit in the TCON register.
Step 4: Wait for the timer to overflow. When the timer overflows, it sets a flag in the TCON register.
Step 5: Stop the timer by clearing the appropriate bit in the TCON register.
Step 6: Clear the timer overflow flag.
Example: If we want a delay of 1ms and we have a clock frequency of 11.0592 MHz, we can calculate the initial count as follows:
-
First, calculate the timer count frequency, which is the clock frequency divided by 12 (because the timer counts on every 12th clock cycle). For an 11.0592 MHz clock, this gives a timer count frequency of 921.6 kHz.
-
Next, calculate the number of timer counts needed for a 1ms delay. Since 1ms is 1/1000 of a second, and our timer count frequency is 921.6 kHz, we need 921.6 counts for a 1ms delay.
-
Since the timer counts up to 65536 (for 16-bit mode), we subtract our count from 65536 to get the initial count. So, the initial count is 65536 - 922 = 64614.
-
This initial count is then loaded into the TH and TL registers (with the high byte in TH and the low byte in TL) before starting the timer.
-
Similar Questions
Processing Delay, Queuing Delay, Transmission Delay, Propagation Delay, Throughput and Loss
Describe the different types of delays at each node along the path the packet traverses. State an expression to represent the total node delay with a diagram.
Assume that XTAL = 1MHz. Find the OCR0 value needed to generate time delay of 0.2ms. Use CTC Mode and no prescalar.
Assume that XTAL= 8MHz. Find the TCNT0 value needed to generate a time delay of 5ms. Use Normal Mode, and the largest prescaler possible.
What value we should load in OCR0 register to generate 25.6ms of delay. Use Timer 0, CTC mode, with prescalar = 1024.
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.