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.

need help with assembly

Status
Not open for further replies.

ah_Hui

New Member
hi guys...i'm new to 8051....
and in the process of learning assembly language now
i wrote the below code ...a subroutine to cause the microcontroller delay for 1second...
and i tried to run it on the simulator...and found that the code keep looping on the instrution WAIT: JNB TF0,WAIT after MOV P1,#10001000B
it just wont continue to the next instructions...what's wrong with the code?
by the way...i'm working on ATMEL 89c51 with 12Mhz crystal
any 1 can help me out?... :oops:

HUNDRED EQU 100
COUNT EQU -10000

ORG 00H
MOV TMOD,#01H
MOV P1,#10001000B
CALL DELAY
MOV P1,#01010101B
CALL DELAY
MOV P2,#10101010B

DELAY:
MOV R7,#HUNDRED
AGAIN:
MOV TH0,#HIGH COUNT
MOV TL0,#LOW COUNT
SETB TR0
WAIT: JNB TF0,WAIT
CLR TF0
CLR TR0
DJNZ R7,AGAIN
RET

END
 
Its been a while since I looked at 8051 assembly but if the instruction is "jump if not bit" that means that TF0 is never set to 1. My guess is that the timer isn't set up correctly. Take a look at your timer initialization code.

Brent
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top