ORG 0H
MOV A, #0H
MOV P2, A
ACALL DELAY
main : INC A
MOV P2, A
ACALL DELAY
CJNE A, #9H, main
MOV R4, #2
DELAY : MOV R3, #220
HERE : NOP
NOP
NOP
NOP
NOP
DJNZ R3, HERE
DJNZ R4, DELAY
RET
END
I will connect BCD To 7-seg to pins 0 : 3 .. It works Fine but i dont know why it stops and freeze on ZERO after counting twice from 0 to 9 ??? Offcourse this on simulation program Protus ,, i didnt made it practically yet >>>> can sm 1 tell me why it freez after Counting twice from 0 to 9 ?>??
Because you are not resetting 'A' to zero on the second pass you never get back to 9
Code:
ORG 0H
MOV A, #0H
MOV P2, A
ACALL DELAY
main :
MOV P2, A
INC A
ACALL DELAY
CJNE A, #0AH, main
MOV A, #0H ; reset a
JMP main
DELAY : MOV R4, #0
DLY : MOV R3, #220
HERE : NOP
NOP
NOP
NOP
NOP
DJNZ R3, HERE
DJNZ R4, DLY
RET
END
Yes! sorry about that! it's" JMP main " not goto (pic on the brain ) Another thing.. if you want '0' place the INC A after writing to port 2. the delay needs to be a bit slower as well start with R4 = 0.