Erase EEPROM timming

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Erase EEPROM timming

Jump to solution
2,294 Views
SebaS
Contributor III
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:

Del_Eeprom:                       
                        ;unprotect
                        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
                        CLC
                        RTC
ERR_DEL:
                        ;erase ERROR
                        SEC
                        RTC   

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?

Thanks!!
Labels (1)
Tags (1)
0 Kudos
1 Solution
525 Views
bigmac
Specialist III
Hello,
 
Using EEPROM for storage of 77 bytes of NV data will require that twenty sectors, each of 4 bytes, be erased.  Since the erase of each sector will require a period of 20 - 27 milliseconds, the total period for 20 sectors should be 400 - 540 milliseconds, which is comparable to what you have observed.
 
If you were to use a flash sector, rather than EEPROM, only a single 512 byte sector would need to be erased, for a total erase period of 20 - 27 milliseconds.  However, this also exceeds the available time, so the sector would still need to be pre-erased.
 
Regards,
Mac
 

View solution in original post

0 Kudos
3 Replies
525 Views
Technoman64
Contributor III
If you are using the PLL to speed up the clock can you go back to the base crystal frequency and save power to extend programming time?
 
Also you may be able to shut down some of the on chip periphials to save on power consumtion with the first few instructions of your XIRG interrupt routine.
 
Can you use a higher value capacitor to store more backup power in the event of power failure?
 
The pre-erase sounds like a very good idea also, can you use two blocks of EEPROM and initialize two pointers at power up power up. One points to last saved data and the other points to block of erased data? You would also need to track which block is most recent during the save.
 
Just a few thoughts...
526 Views
bigmac
Specialist III
Hello,
 
Using EEPROM for storage of 77 bytes of NV data will require that twenty sectors, each of 4 bytes, be erased.  Since the erase of each sector will require a period of 20 - 27 milliseconds, the total period for 20 sectors should be 400 - 540 milliseconds, which is comparable to what you have observed.
 
If you were to use a flash sector, rather than EEPROM, only a single 512 byte sector would need to be erased, for a total erase period of 20 - 27 milliseconds.  However, this also exceeds the available time, so the sector would still need to be pre-erased.
 
Regards,
Mac
 
0 Kudos
525 Views
SebaS
Contributor III
Thank you!!! That saves me a lot of time doing test to improve timming... I think I'm gonna pre-erase de EEPROM...

Thanks again
SebaS
0 Kudos