Q: Write A Program To Generate A Square Wave of 1Khz On P0.0 While Simultaneously Reading Data From P1 and Sending It To P2
Q: Write A Program To Generate A Square Wave of 1Khz On P0.0 While Simultaneously Reading Data From P1 and Sending It To P2
org 0
sjmp main ;goto main
org 000bh
sjmp T0ISR ; goto T0 ISR
org 0030h
main:
mov p1, #0ffh ; P1 input port
mov ie, #82h ; enable T0 int
mov tmod, #01h ; T0 - M1
mov tl0, #0ch ; count LB
mov th0, #0feh ; count HB
setb tr0 ; start timer
clr p0.0 ; make P0.0 = 0
again:
mov a, p1 ; A <-- P1
mov p2, a ; P2 <-- A
sjmp again ; loop
T0ISR:
cpl p0.0 ; compl. p0.0
clr tr0 ; make run bit 0
mov tl0, #0ch ; load count LB
mov th0, #0feh ; load count HB
setb tr0 ; start timer 0
reti ; return from isr
end
Delay calculation
Count = FE0CH
www.BharatAcharyaEducation.com
All the best J Watch Video Lectures of all topics by Bharat Acharya Page 1
BHARAT ACHARYA EDUCATION
Videos | Books | Classroom Coaching
E: [email protected]
M: 9820408217
On the Simulator
Load the exact same program…
www.BharatAcharyaEducation.com
All the best J Watch Video Lectures of all topics by Bharat Acharya Page 2
8051 | SQUARE WAVE PROGRAM
Using Timer Interrupt
Run it… You will see P0.0 toggling between 0 and 1… that’s the square wave output as desired…
You can also change the switch inputs on P1 and see the changed output on P2
www.BharatAcharyaEducation.com
All the best J Watch Video Lectures of all topics by Bharat Acharya Page 3
BHARAT ACHARYA EDUCATION
Videos | Books | Classroom Coaching
E: [email protected]
M: 9820408217
This shows that we are doing both operations simultaneously. While a square wave is being produced
on p0.0 at the same time we are transmitting value from p1 to p2
www.BharatAcharyaEducation.com
All the best J Watch Video Lectures of all topics by Bharat Acharya Page 4
8051 | SQUARE WAVE PROGRAM
Using Timer Interrupt
https://www.bharatacharyaeducation.com
Learn...
8085 | 8086 | 80386 | Pentium |
8051 | ARM7 | COA
Fees: 1199/-
Duration: 6 months
Activation: Immediate
Certification: Yes
Free: PDFs of theory explanation
Free: VIVA questions and answers
Free: PDF of Multiple Choice Questions
#bharatacharya
#bharatacharyaeducation
#8086 #8051 #8085 #80386 #pentium
#microprocessor #microcontrollers
www.BharatAcharyaEducation.com
All the best J Watch Video Lectures of all topics by Bharat Acharya Page 5