Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Assemply Program On Atm89C51

Status
Not open for further replies.

IronMan2010

New Member
I wrote this Program To Count Fro 0 to 9 On 7-seg

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

Cheers Ian
 
Last edited:
There is no instuction called ''GOTO''' in assemply ,, Keil gives me error , so i deleted it and it gave the same result :(
 
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.

cheers Ian

P.S. I edited the code again
 
Last edited:
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top