ORG 0
MOV A, #55H
AGAIN: MOV P0, A
ACALL DELAY
CPL A
SJMP AGAIN
DELAY: MOV R2, #7
HERE1: MOV R1, #255
HERE2: MOV R0, #255
HERE3: DJNZ R0, HERE3
DJNZ R1, HERE2
DJNZ R2, HERE1
RET
END
Delay Calculation:
Machine cycle frequency = (Crystal Frequency) / (Clocks per machine cycle)
= 4/12
= 0.3333 MHz
Time Period of Machine Cycle = 1/0.33
= 3.003us (microseconds)
No. of machine cycles = 1(for MOV A, #55H) + 1(for MOV P0, A)
= 2 cycles
Total Delay = 7 * 255 * 255 * 2 * 3.003
= 2733781.05us
= 2.73 seconds
Thus the LEDs will show alternate blinking after every 2.73 seconds; the delay can be adjusted as per the requirement by just varying the values of registers R0, R1 or R2.
Why alternate blinking?
Initially value at P0 = #55h
55h in binary- 0 1 0 1 0 1 0 1.
Thus LEDs status is-
LED 1- 0(low) : GLOW
LED 2- 1(high) : OFF
LED 3- 0(low) : GLOW
LED 4- 1(high) : OFF
LED 5- 0(low) : GLOW
LED 6- 1(high) : OFF
LED 7- 0(low) : GLOW
LED 8- 1(high) : OFF
After delay of 2.7 seconds CPL A is executed
Now Value at P0 = #AAh
AAh in binary- 1 0 1 0 1 0 1 0
Thus LEDs status is-
LED 1- 1(high) : OFF
LED 2- 0(low) : GLOW
LED 3- 1(high) : OFF
LED 4- 0(low) : GLOW
LED 5- 1(high) : OFF
LED 6- 0(low) : GLOW
LED 7- 1(high) : OFF
LED 8- 0(low) : GLOW
Regards:
Aditya Sharma (heloitsadi)
http://robozeal.blogspot.com
9 comments:
i m gaurav
will u give me the connection dig for isp
for mc 89cs51 mc
Go to this link..
http://read.pudn.com/downloads42/sourcecode/comm/para_port/144081/编程器制作/自制AT89S51编程器教程.files/image001.png
hai men the image is good
buti required it with out 74ls373 ic
just leave your ID, will mail u the other one.
gaurav_opjy@yahoo.co.in
can u send me the synopsis of this ckt. please
hello Aditya,
how to calculate machine cycle for ATMEGA8....???
What is the logic of lighting 9 led one after another inATmega8??
&&..Circuit diagram ?????
The post made me to post reply. Very convincing content on your blog. Keep doing the collective work about information.
Thanks
Dedicated hosting provider
Post a Comment