Using AT93C56A as EEPROM with 89c51

Thread Starter

Reborn121

Joined Jun 29, 2010
3
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.
 

Thread Starter

Reborn121

Joined Jun 29, 2010
3
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


Rich (BB code):
.equ sk, p1.0    ;serial clock
.equ di, p1.1    ;data input
.equ do, p1.2    ;data output
.equ cs, p1.3    ;chip select
;__________________________________________

     Mov SCON, #50H       ;serial mode
     Mov TMOD, #20H       ;timer1 mode2

;__________________________________________

;Read a byte from EEPROM
;__________________________________________

Read:    SETB   cs             ;cs is set
         LCALL  Clock
         SETB   di             ;di is set
         LCALL  Clock
         MOV    A, EEADR
         ANL    A, #3Fh
         ORL    A, EEBYT       ;code and address for read
         LCALL  wr_byt         ;send address
         LCALL  Time
         LCALL  rd_byt         ;read a byte
         CLR    cs             ;cs is set
         RET                   ;return
;___________________________________________
         

;Write byte to EEPROM 
;__________________________________________   

Write:   SETB   cs             ;cs is set
         LCALL  Clock
         SETB   di             ;di is set
         LCALL  Clock
         MOV   A, #30h        
         LCALL   wr_byt
         CLR   di              ;clear di
         CLR   cs              ;clear cs

         LCALL  Time

         SETB   cs             ;cs is set
         LCALL  Clock
         SETB   di             ;di is set
         LCALL  Clock
         MOV    A, EEADR
         ANL    A, #1Fh         
         ORL    A, #40h
         LCALL  wr_byt      
         MOV    A, EEBYT
         LCALL  wr_byt
         CLR    di             ;clear di
         CLR    cs             ;clear cs

         LCALL Time

         SETB  cs              ;cs is set
         JNB   do, $
         CLR   cs              ;clear cs

         LCALL  Time

         SETB   cs             ;cs is set
         LCALL  Clock
         SETB   di             ;di is set
         LCALL  Clock
         MOV    A, #00h         
         LCALL  wr_byt
         CLR    di             ;clear di
         CLR    cs             ;clear cs
         RET                   ;return
;____________________________________________________________

;Clock time delay
;____________________________________________________________

Clock:   SETB  sk              ;clock is set
         MOV   R6, #10h        ;move 10 hex into reg 6

H_Loop:  NOP
         NOP
         NOP
         NOP
         DJNZ  R6, H_Loop
         CLR   sk              ;clear clock

L_Loop:  NOP
         NOP
         NOP
         NOP
         DJNZ  R6, L_Loop
         RET                    ;return

Time:    Mov R6,#10H
;____________________________________________________________
 
Top