0% found this document useful (0 votes)
45 views7 pages

34bf23ce-a2f0-4837-96e1-1c3f034b2543 (14)

The document describes an experiment to program a microcontroller to generate a 1KHz square wave with a 45% duty cycle using Timer 1 in mode 1 and output on port 0 pin 1. It provides the theory of operation for timers in the 8051 microcontroller and an assembly language program to configure the timer for the desired frequency and duty cycle along with logic to output the signal on a pin. Registers are initialized, timers are loaded with appropriate count values, and a loop waits for the timer flag to toggle the output pin high and low to generate the square wave.

Uploaded by

swathi kesana
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)
45 views7 pages

34bf23ce-a2f0-4837-96e1-1c3f034b2543 (14)

The document describes an experiment to program a microcontroller to generate a 1KHz square wave with a 45% duty cycle using Timer 1 in mode 1 and output on port 0 pin 1. It provides the theory of operation for timers in the 8051 microcontroller and an assembly language program to configure the timer for the desired frequency and duty cycle along with logic to output the signal on a pin. Registers are initialized, timers are loaded with appropriate count values, and a loop waits for the timer flag to toggle the output pin high and low to generate the square wave.

Uploaded by

swathi kesana
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/ 7

Model Wave:

45% 55%

ON OFF

Calculations:
We use timer 1 as timer

Counting frequency=fosc/12

Assume fosc=12MHz

Counting Frequency=1MHz

1 count=1 micro sec

1)count to be loaded in timer for ON time:


=max count-desired count+1

=65535- 450 +1

= ( 65086)—decimal

= ( FE3E )—hexadecimal

2)count to be loaded in timer for OFF time:


=max count—desired count+1

=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:

 The 8051 has two timers/counters, they can be used either as


 Timers to generate a time delay or as
 Events counters to count events happening outside the microcontroller.
 Both Timer 0 and Timer 1 are 16 bits wide
 Since 8051 has an 8-bit architecture, each 16-bit timer is accessed as two
separate registers of low byte and high byte
 Accessed as low byte and high byte
 The low byte register is called TL0/TL1 and
 The high byte register is called TH0/TH1
 Accessed like any other register

 MOV TL0, #4FH


 MOV R5, TH0
TMOD:

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:

Label Mnemonic Operand Opcode No of Memory Program in


Bytes address memory
1 ORG 00H
2 0000 1100 0010
MAIN CLR PO.1 C281 2 0001 1000 0001
3 ACALL DELAY 1 110A 0002 0001 0001
2 0003 0000 1010
4 SETB P0.1 D281 0004 1101 0010
2 0005 1000 0001
5 ACALL DELAY 2 111E 0006 0001 0001
2 0007 0001 1110
6 SJMP MAIN 80F6 0008 1000 0000
2 0009 1111 0110
7 MOV TMOD #10H 758910 000A 0111 0101
DELAY1 3 000B 1000 1001
000C 0001 0000
8 MOV TL1 #0DAH 758BDA 000D 0111 0101
3 000E 1000 1011
000F 1101 1010
9 MOV TH1 #0FDH 758DFE 0010 0111 0101
3 0011 1000 1101
0012 1111 1110
0013 0111 0101
10 MOV TCON #40H 758840 3 0014 1000 1000
0015 0100 0000
11 0016 0011 0000
WAIT1 JNB TF1 WAIT 308FFD 3 0017 1000 1111

0018 1111 1101


OUTPUT WAVE:
12 CLR TR1 C28E 2 0019 1100 0010
001A 1000 1110
13 CLR TF1 C28F 2 001B 1100 0010
001C 1000 1111
14 RET 22 1 001D 0010 0010
16 001E 0111 0101
DELAY2 MOV TMOD #10H 758910 3 001F 1000 1001
0020 0001 0000
17 MOV TL1 #3EH 758B3E 0021 0111 0101
3 0022 1000 1011
0023 0011 1110
18 MOV TH1 #0FEH 758DFE 0024 0111 0101
3 0025 1000 1101
0026 1111 1110
19 MOV TCON #40H 758840 0027 0111 0101
3 0028 1000 1000
0029 0100 0000
20 002A 0011 0000
WAIT2 JNB TF1 WAIT2 308FFD 3 002B 1000 1111
002C 1111 1101
21 CLR TR1 C28E 002D 1100 0010
2 002E 1000 1110
22 CLR TF1 C28F 002F 1100 0010
2 0030 1000 1111
23 RET 22 1 0031 0010 0010
END

RESULT: Generating a square wave of 1KHz with duty cycle 45% using timer 1 in mode 1 and port 0
pin is completed.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy