If the oscillator frequency is 12MHz.
Please produce the pulses with period of 2ms
at pin P1.0 . Duty cycle is one by one.
using assembly language 8051
Answer :- Oscillator frequency is 12 MHz, hence timer frequency
will be 12/12 MHz = 1 MHz.So one count time for timer is 1 us,
delay = 2 ms, hence count value(for one pulse i.e. for 1 ms),
n = 0.001/0.000001 = 1000 = 3E8H.
The assembly code is written below-
ORG 0000H ;start cose from this address
MOV TMOD,#01H ;timer mode is mode 1 i.e. 16-bit timer
UP:SETB P1.0 ;making output high
LCALL DELAY ;call the delay sub-routine
CLR P1.0 ;clear the output
LCALL DELAY ;call the delay sub-routine
SJMP UP ;go to label name UP, for repeating the output
DELAY: ;label name DELAY
MOV TH0,#0FCH ;load timer0 upper half value
MOV TL0,#17H ;load timer0 lower half value
CLR TF0 ;clear timer interrupt flag
SETB TR0 ;start timer0
HERE:JNB TF0,HERE ;wait here till timer interrupt is
generated
RET ;return from subroutine
END ;end of the program
Get Answers For Free
Most questions answered within 1 hours.