Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
01/14/12 13:25
Modified:
  01/14/12 13:28

Read: 783 times


 
#185492 - EEPROM Write Issue
Hi guys. I'm using the Atmel AT89S8253 I have a code routine where I write two values to two different locations in EEPROM one
right after the other. I set up the call to this routine as such -

                 mov        DPTR,#EEADDRESS1
                 mov        A,DATA1
                 acall      EEWrite

                 mov        DPTR,#EEADDRESS2                 
                 mov        A,DATA2
                 acall      EEWrite

 


My write routine is -

EEWrite:         mov        EECON,#0x1A
                 movx       @DPTR,A
                 mov        EECON,#0x0A
                 ret

 


#EEADDRESS1 and #EEADDRESS2 are predefined variables that are equated to the EEPROM write addresses. DATA1 and DATA2 are predefined buffers in RAM which hold the data to be written.

Now, when executing this code, the first value gets written but the second one does not. Now if I call a delay loop between the two writes, both values will get written, but without the delay only the first gets written.

In the data sheet, it states that the RDY/BSY bit in EECON will have already transitioned back to the ready state prior to the completion of executing the movx instruction. But this doesn't seem to be the case.

I've been trying to figure out how to read the RDY/BSY bit in EECON between the two writes instead of using the delay loop, but the assembler says that it is not an addressable bit. The other thing I tried between the two writes was -

EEWait:            mov       A,EECON
                   cjne      A,#0x0A,EEWait
 


But this code segment gets the code stuck in that wait loop, which doesn't make sense since the value of 0x0A gets written to EECON prior to returning from the EEWrite routine. The only thing I could think of that would cause EECON not to be equal to 0x0A would be if the RDY/BSY bit was stuck in the low state as if the hardware never reset the bit to 1 (RDY/BSY is a hardware controlled flag bit), but this doesn't make any sense to me at all since it should transition back to one upon completion of the write cycle according to the data sheet.

Is there anyone who can educate me on how to properly poll the RDY/BSY bit in EECON? Or shall I just stick with calling a delay loop between the two writes?

List of 3 messages in thread
TopicAuthorDate
EEPROM Write Issue      Jon Wilder      01/14/12 13:25      
   Nevermind      Jon Wilder      01/14/12 13:40      
      A better approach      Daniel Contarino      01/14/12 14:44      

Back to Subject List