Calculating approx delay

Papabravo

Joined Feb 24, 2006
21,227
@Tajiknomi The normal prorgrammer's intuition says write the code in such a way that you do the EEPROM write and then wait for its completion by polling the BUSY bit. Instead what I want you to do is use your other tasks instead of a wait loop. After doing the write you know that you have some period of time before it is complete. Go do at least one other thing before checking the status of the EEPROM. Then keep doing other things. One of the other things you could do is set a "watchdog timer" (not THE watchdog timer for the processor) for the EEPROM write. You might set it for four times the expected EEPROM write time. If the timer expires then you can implement fault recovery procedures. It also satisfies one of the cardinal rules of embedded programming, which is:

  1. Never write a wait loop on a single condition
Glad we helped you get it working
 
Top