AnsweredAssumed Answered

Erase EEPROM timming

Question asked by Sebastian Irazabal on Nov 2, 2007
Latest reply on Nov 8, 2007 by Dennis Shutt
Hello once again... Now I've got a problem because I want to retain some data when the power goes down... So, when the supply voltages goes below some threshold, uC enters in the XIRQ ISR to save data in EEPROM... But previously, that part of the EEPROM has to be erased...
So, to erase that part of the EEPROM I call the next routine:

                        MOVB    #$88,EPROT
                        ;all empty and no command pending
                        BRCLR    ESTAT,CCIF,*
                        BRCLR    ESTAT,CBEIF,*

                        ;address to erase
                        STD        0,Y
                        ;send erase cmd
                        LDAB    #$40
                        STAB    ECMD
                        BSET    ESTAT,CBEIF                 ;******* REMEMBER THIS LINE....

                        BITB    #(PVIOL+ACCERR)
                        BNE        ERR_DEL
                        ;erase OK
                        ;erase ERROR

And outside that, I incremenr the pointer register Y until I reach the end of the part I want to delete....

The question is.... Is that routine OK???.... I think it is, but the problem is that it takes 550mseg to erase a block of 77 bytes and I don't know why it takes 200mseg to erase 4 bytes.... Any way, the time I have to erase the data is 5mseg... (I know I can erase de EEPROM outside the XIRQ but If I can, I'd like to put it inside)...

And about the line marked (the one to remember).... I read the manual, and there's a part that says that "By clearing this flag (CBEIF) the command secuense is launched"... What I undestood is that the flag is set when all is empty... So, if I want to erase, y SET the ERASE bit in the ECMD, and the erase is started (launched) when I clear the CBEIF flag.. Is that correct?