Using AT93C56A as EEPROM with 89c51

Discussion in 'Embedded Systems and Microcontrollers' started by Reborn121, Jun 29, 2010.

  1. Reborn121

    Thread Starter New Member

    Jun 29, 2010
    3
    0
    I need to write a simple program to erase, read, and write a value in assembly language using the EEPROM AT93C56A with the 89c51RB2...can anyone help me get started please? This is really urgent! Thank you for any assistance.
     
  2. retched

    AAC Fanatic!

    Dec 5, 2009
    5,201
    312
    Homework due tomorrow and just getting started? ;)

    Ok the AT93C56A has a 3 wire serial interface.

    If you read the datasheet for the AT93C56A EEPROM, it shows EXACTLY how the chip needs to be hit in order to read and write.

    Data sheet is here:
    www.atmel.com/dyn/resources/prod_documents/doc3408.pdf
     
  3. Reborn121

    Thread Starter New Member

    Jun 29, 2010
    3
    0
    Thanks for your post...i have tried to get as much code together as i could for my application...my specific requirements are to erase the EEPROM, read a value in variable EEADR and store in EEBYT then output the value to port 2 of the micro. Can anyone tell me if im on the right track or offer suggestions,,i know its not complete? Thanks


    Code ( (Unknown Language)):
    1.  
    2. .equ sk, p1.0    ;serial clock
    3. .equ di, p1.1    ;data input
    4. .equ do, p1.2    ;data output
    5. .equ cs, p1.3    ;chip select
    6. ;__________________________________________
    7.  
    8.      Mov SCON, #50H       ;serial mode
    9.      Mov TMOD, #20H       ;timer1 mode2
    10.  
    11. ;__________________________________________
    12.  
    13. ;Read a byte from EEPROM
    14. ;__________________________________________
    15.  
    16. Read:    SETB   cs             ;cs is set
    17.          LCALL  Clock
    18.          SETB   di             ;di is set
    19.          LCALL  Clock
    20.          MOV    A, EEADR
    21.          ANL    A, #3Fh
    22.          ORL    A, EEBYT       ;code and address for read
    23.          LCALL  wr_byt         ;send address
    24.          LCALL  Time
    25.          LCALL  rd_byt         ;read a byte
    26.          CLR    cs             ;cs is set
    27.          RET                   ;return
    28. ;___________________________________________
    29.          
    30.  
    31. ;Write byte to EEPROM
    32. ;__________________________________________  
    33.  
    34. Write:   SETB   cs             ;cs is set
    35.          LCALL  Clock
    36.          SETB   di             ;di is set
    37.          LCALL  Clock
    38.          MOV   A, #30h        
    39.          LCALL   wr_byt
    40.          CLR   di              ;clear di
    41.          CLR   cs              ;clear cs
    42.  
    43.          LCALL  Time
    44.  
    45.          SETB   cs             ;cs is set
    46.          LCALL  Clock
    47.          SETB   di             ;di is set
    48.          LCALL  Clock
    49.          MOV    A, EEADR
    50.          ANL    A, #1Fh        
    51.          ORL    A, #40h
    52.          LCALL  wr_byt      
    53.          MOV    A, EEBYT
    54.          LCALL  wr_byt
    55.          CLR    di             ;clear di
    56.          CLR    cs             ;clear cs
    57.  
    58.          LCALL Time
    59.  
    60.          SETB  cs              ;cs is set
    61.          JNB   do, $
    62.          CLR   cs              ;clear cs
    63.  
    64.          LCALL  Time
    65.  
    66.          SETB   cs             ;cs is set
    67.          LCALL  Clock
    68.          SETB   di             ;di is set
    69.          LCALL  Clock
    70.          MOV    A, #00h        
    71.          LCALL  wr_byt
    72.          CLR    di             ;clear di
    73.          CLR    cs             ;clear cs
    74.          RET                   ;return
    75. ;____________________________________________________________
    76.  
    77. ;Clock time delay
    78. ;____________________________________________________________
    79.  
    80. Clock:   SETB  sk              ;clock is set
    81.          MOV   R6, #10h        ;move 10 hex into reg 6
    82.  
    83. H_Loop:  NOP
    84.          NOP
    85.          NOP
    86.          NOP
    87.          DJNZ  R6, H_Loop
    88.          CLR   sk              ;clear clock
    89.  
    90. L_Loop:  NOP
    91.          NOP
    92.          NOP
    93.          NOP
    94.          DJNZ  R6, L_Loop
    95.          RET                    ;return
    96.  
    97. Time:    Mov R6,#10H
    98. ;____________________________________________________________
    99.  
    100.  
    101.  
    102.  
     
Loading...