Having problem with the above 8051 microprocessor codes!!!

Thread Starter

lyrical

Joined Dec 20, 2010
2
QUESTION 1
The program shown is a 1-sec stop watch timer with two push buttons; a start and a stop button. When the program is executed, it does not work as it should.
Debug the program and show the working program to your examiner.

QUESTION 2
Modify the program to have a third button to reset the stop watch to "0".

Rich (BB code):
; Stop Watch
$include (c8051f200.inc)
EXTRN CODE (STARTUP)  CSEG AT 0000H
LJMP MAIN
CSEG AT 90H
LUT: DB 3FH
DB 06H
DB 5BH
DB 4FH
DB 66H
DB 6DH
DB 7DH
DB 27H
DB 7FH
DB 6FH
CSEG AT 100HMAIN:LCALL STARTUP
SETB P0.2
SETB P0.3
MOV R2,#0
MOV TMOD,#10H
SETB TR1
MOV DPTR,#LUTM1:MOV R7,#0HM2:MOV A,R7
MOVC A,@A+DPTR
MOV P1,A
LCALL DELAYB1:
JB P0.2,B2
MOV R2,#0B2:JB P0.3,B3
MOV R2,#0B3:CJNE R2,#1,B1
INC R7
CJNE R7,#10,M2
SJMP M1DELAY:MOV R1,#40DD1:MOV TH1,#3CH
MOV TL1,#0B0HD2: JNB TF1,D2
CLR TF1
DJNZ R1,D1
RET
END
 
Last edited by a moderator:

beenthere

Joined Apr 20, 2004
15,819
This is a homework assignment. What is your analysis of the problem with the code? Cab you add comment to each line to identify each defined byte and instruction?
 

n1ist

Joined Mar 8, 2009
189
Start by reformatting the code; each statement should be on its own line and use tabs or spaces to move all the code so that the labels are visible. That way, you can see the structure of the code. Then follow beenthere's suggestion to comment it. Then trace through the execution to find the bugs.
/mike
 
Top