Having problem with the above 8051 microprocessor codes!!!

Discussion in 'Homework Help' started by lyrical, Jan 26, 2011.

  1. lyrical

    Thread Starter New Member

    Dec 20, 2010
    2
    0
    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".

    Code ( (Unknown Language)):
    1.  
    2. ; Stop Watch
    3. $include (c8051f200.inc)
    4. EXTRN CODE (STARTUP)  CSEG AT 0000H
    5. LJMP MAIN
    6. CSEG AT 90H
    7. LUT: DB 3FH
    8. DB 06H
    9. DB 5BH
    10. DB 4FH
    11. DB 66H
    12. DB 6DH
    13. DB 7DH
    14. DB 27H
    15. DB 7FH
    16. DB 6FH
    17. CSEG AT 100HMAIN:LCALL STARTUP
    18. SETB P0.2
    19. SETB P0.3
    20. MOV R2,#0
    21. MOV TMOD,#10H
    22. SETB TR1
    23. MOV DPTR,#LUTM1:MOV R7,#0HM2:MOV A,R7
    24. MOVC A,@A+DPTR
    25. MOV P1,A
    26. LCALL DELAYB1:
    27. JB P0.2,B2
    28. MOV R2,#0B2:JB P0.3,B3
    29. MOV R2,#0B3:CJNE R2,#1,B1
    30. INC R7
    31. CJNE R7,#10,M2
    32. SJMP M1DELAY:MOV R1,#40DD1:MOV TH1,#3CH
    33. MOV TL1,#0B0HD2: JNB TF1,D2
    34. CLR TF1
    35. DJNZ R1,D1
    36. RET
    37. END
    38.  
    39.  
     
    Last edited by a moderator: Jan 26, 2011
  2. beenthere

    Retired Moderator

    Apr 20, 2004
    15,815
    282
    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?
     
  3. n1ist

    Active Member

    Mar 8, 2009
    171
    16
    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
     
Loading...