34bf23ce-a2f0-4837-96e1-1c3f034b2543 (14)
34bf23ce-a2f0-4837-96e1-1c3f034b2543 (14)
45% 55%
ON OFF
Calculations:
We use timer 1 as timer
Counting frequency=fosc/12
Assume fosc=12MHz
Counting Frequency=1MHz
=65535- 450 +1
= ( 65086)—decimal
= ( FE3E )—hexadecimal
=65535-- 550 +1
=( 64986 )—decimal
=( FDDA )—hexadecimal
Date:
Experiment 2
AIM: program for generating 1KHz square wave with duty cycle of 45% using timer 1 in mode 1 at
port 0 pin.
Apparatus:
1.Desktop \ Laptop
2. Keil 5 IDE
THEORY:
T1 T0
0 0 0 1 0 0 0 0
G1 C/F M1 M0 G2 C/F M1 M0 =10H
TCON:
T1 T0 Interrupt
0 1 0 0 0 0 0 0
TF1 TR1 TF0 TRO IE1 IT1 IF0 IT0 =40H
Both timers 0 and 1 use the same register, called 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
In each case
The lower 2 bits are used to set the timer mode
The upper 2 bits to specify the operation
Observation Format:
RESULT: Generating a square wave of 1KHz with duty cycle 45% using timer 1 in mode 1 and port 0
pin is completed.