0% found this document useful (0 votes)
32 views23 pages

13-Calculation Steps and Problem Based On Timers MODE 1-06-02-2024

Uploaded by

Shikhar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
32 views23 pages

13-Calculation Steps and Problem Based On Timers MODE 1-06-02-2024

Uploaded by

Shikhar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 23

1

Course Name: Microprocessors and Microcontrollers


Course Code: BECE204L

Dr. Vishal Gupta


Assistant Professor
School of Electronics Engineering
Vellore Institute of Technology, Vellore, Tamil Nadu, India
2

Microcontroller 8051
Peripherals: Timers-Counters
8051 Pin Diagram
8051
Architecture
Special Function Registers [SFR]
8051 TMOD Register

TCON
Important Points to Start Timer
▪ Timers of 8051 do starting and stopping by either software or
hardware control.
▪ In using software to start and stop the timer where GATE = 0.
▪ The start and stop of the timer are controlled by way of software
by the TR (timer start) bits TR0 and TR1
▪ Instructions:
SETB (Start), CLR (Stop)
▪ The hardware way of starting and stopping the timer by an
external source is achieved by making GATE = 1 in the TMOD
register
How to Load Count?
❑ Attributes to Loads Count value:
▪ Timers are up Counter.
▪ As it will receive clock it will be increment by 1.
▪ Maximum Count FFFFH.
▪ When it reaches to FFFFH, it will roll back to 0000H.
▪ During that time, it will generate Timer overflow interrupt.
❑ So, load value in Counter:
How to Load Count?
Example: if you wants to count 9 then

Count = FFFFH – 9 + 1 = FFF7H

How to program the following Count value (= FFF7H) in the register?

MOV TH0, #FFH


MOV TL0, #7H

This loaded count value will increase after every clock.


1. Load Count Value in T0 or T1 How to Load Count?
2. Count will Increase After Every Clock
6. Execute Interrupt subroutine
3. When Count Rolls from FFFFH to 0000H -------
-------
4. It will make TF0 and TF1 bit to 1 (it is -------
interrupt to 8051)
RETI

5. It Jumps to ISR address


(Before that Make TF0 or TF1 bit to 0)
▪ Timer 0 ISR Address is 000BH
▪ Timer 1 ISR Address is 001BH
Mode 1 Programming

1. Load the TMOD value register


2. Load registers TL and TH with initial count
3. Start the timer
4. Keep monitoring the timer flag
5. Stop the timer
6. Clear the TF flag for the next round
7. Go back to Step 2 to load TH and TL again.
Duty Cycle

Duty cycle is simply the ratio of


time a circuit is on compared to
the time that the circuit is off.
Find the delay generated by Timer 0 in the following code. Do not include the overhead due
to instructions.
Solution:
The following program generates a square wave on pin P1.5 continuously using Timer 1
for a time delay. Find the frequency of the square wave if XTAL = 11.0592 MHz. In your
calculation do not include the overhead due to instructions in the loop.
Finding values to be loaded in timer
Program:

You might also like