EEPROM test code problem.

Discussion in 'Programmer's Corner' started by NexusRevZ, Jul 29, 2014.

  1. NexusRevZ

    Thread Starter New Member

    Jul 29, 2014
    1
    0
    This simple code is test the write and read of EEPROM on AT89S8253.

    Firstly the LED at P1 will have all LED on, after a sec, have the P1 will have LED on.
    Next, code is to write 01010101B into the EEPROM.
    CJNE will check to see if it is written.
    But, after comparing, the data isn't similar and the code is restarted.

    If the writing process works the LED at P1.0 should be the only LED on, which will notify the success of writing into the EEPROM.

    The next portion of the code will recall/read the written data in the EEPROM.
    f it is able to read, P1 will have alternate LED on and off.
    Please provide solutions, sources and why or what I had done wrong, to educate me. Thank you.

    =============================

    Code ( (Unknown Language)):
    1.  
    2. [COLOR=#333333][FONT=Tahoma]org 0[/FONT][/COLOR]
    3. [COLOR=#333333][FONT=Tahoma]jmp start[/FONT][/COLOR]
    4. [COLOR=#333333][FONT=Tahoma]eecon EQU 96h[/FONT][/COLOR]
    5.  
    6. [COLOR=#333333][FONT=Tahoma]start:[/FONT][/COLOR]
    7. [COLOR=#333333][FONT=Tahoma]MOV A,#11111111B[/FONT][/COLOR]
    8. [COLOR=#333333][FONT=Tahoma]MOV P1,A[/FONT][/COLOR]
    9. [COLOR=#333333][FONT=Tahoma]ACALL DELAY0[/FONT][/COLOR]
    10. [COLOR=#333333][FONT=Tahoma]MOV A,#00001111B[/FONT][/COLOR]
    11. [COLOR=#333333][FONT=Tahoma]MOV P1,A[/FONT][/COLOR]
    12. [COLOR=#333333][FONT=Tahoma]ACALL DELAY0[/FONT][/COLOR]
    13.  
    14. [COLOR=#333333][FONT=Tahoma]WRITE:[/FONT][/COLOR]
    15. [COLOR=#333333][FONT=Tahoma]MOV EECON,#00001000b[/FONT][/COLOR]
    16.  
    17. [COLOR=#333333][FONT=Tahoma]mov dptr,#0 ;point to the memory location needed to write to. chosen location 0[/FONT][/COLOR]
    18. [COLOR=#333333][FONT=Tahoma]mov a,#10101010B ;move the data (0fch) to Accumulator[/FONT][/COLOR]
    19. [COLOR=#333333][FONT=Tahoma]movx @dptr,a ;write the data to the chosen location[/FONT][/COLOR]
    20.  
    21. [COLOR=#333333][FONT=Tahoma]MOVX A, @DPTR[/FONT][/COLOR]
    22. [COLOR=#333333][FONT=Tahoma]CJNE A, #10101010B, START[/FONT][/COLOR]
    23.  
    24. [COLOR=#333333][FONT=Tahoma]WRITEFIN:[/FONT][/COLOR]
    25. [COLOR=#333333][FONT=Tahoma]MOV A,#00000001B[/FONT][/COLOR]
    26. [COLOR=#333333][FONT=Tahoma]MOV P1,A[/FONT][/COLOR]
    27. [COLOR=#333333][FONT=Tahoma]ACALL DELAY0[/FONT][/COLOR]
    28. [COLOR=#333333][FONT=Tahoma]READ:[/FONT][/COLOR]
    29. [COLOR=#333333][FONT=Tahoma]MOV EECON,#00001000b[/FONT][/COLOR]
    30. [COLOR=#333333][FONT=Tahoma]mov DPTR,#0 ;point to the memory location needed to read from. Chosen location 0[/FONT][/COLOR]
    31. [COLOR=#333333][FONT=Tahoma]movx A,@dptr ;move the data within the memory location to the Accumulator[/FONT][/COLOR]
    32. [COLOR=#333333][FONT=Tahoma]mov R0,A ;move the data within Accumulator to the Register[/FONT][/COLOR]
    33.  
    34. [COLOR=#333333][FONT=Tahoma]WAT: MOV P1,R0[/FONT][/COLOR]
    35. [COLOR=#333333][FONT=Tahoma]SJMP WAT[/FONT][/COLOR]
    36.  
    37. [COLOR=#333333][FONT=Tahoma];========================================[/FONT][/COLOR]
    38. [COLOR=#333333][FONT=Tahoma]DELAY0:[/FONT][/COLOR]
    39. [COLOR=#333333][FONT=Tahoma]ACALL DELAY[/FONT][/COLOR]
    40. [COLOR=#333333][FONT=Tahoma]ACALL DELAY[/FONT][/COLOR]
    41. [COLOR=#333333][FONT=Tahoma]ACALL DELAY[/FONT][/COLOR]
    42. [COLOR=#333333][FONT=Tahoma]ACALL DELAY[/FONT][/COLOR]
    43. [COLOR=#333333][FONT=Tahoma]ACALL DELAY[/FONT][/COLOR]
    44. [COLOR=#333333][FONT=Tahoma]RET[/FONT][/COLOR]
    45. [COLOR=#333333][FONT=Tahoma]DELAY:[/FONT][/COLOR]
    46. [COLOR=#333333][FONT=Tahoma]MOV R3, #255[/FONT][/COLOR]
    47. [COLOR=#333333][FONT=Tahoma]HERE2:[/FONT][/COLOR]
    48. [COLOR=#333333][FONT=Tahoma]MOV R4, #255[/FONT][/COLOR]
    49. [COLOR=#333333][FONT=Tahoma]HERE:[/FONT][/COLOR]
    50. [COLOR=#333333][FONT=Tahoma]DJNZ R4, HERE[/FONT][/COLOR]
    51. [COLOR=#333333][FONT=Tahoma]DJNZ R3, HERE2[/FONT][/COLOR]
    52. [COLOR=#333333][FONT=Tahoma]RET[/FONT][/COLOR]
    53. [COLOR=#333333][FONT=Tahoma]end[/FONT][/COLOR]
    54.  
     
    Last edited by a moderator: Jul 29, 2014
Loading...