Link here

Chapter 7 - EEPROM


The 68HC11F1 has 512 bytes of on-chip EEPROM (electrically-erasable-programmable-read-only-memory). QED-Forth locates the EEPROM block at AE00H through AFFFH. The first 192 bytes of this non-volatile memory are reserved for QED-Forth initialization parameters and interrupt vector code as discussed in the QED Software Manual (see the memory map in Appendix A and the "Interrupts and Register Initializations" chapter in the Software Manual). The remaining 320 bytes of EEPROM beginning at location AEC0H may be used freely. The following QED-Forth words store values to the EEPROM:

(EEC!) \ stores a character
(EE!) \ stores a 16-bit cell
(EE2!) \ stores two 16-bit cells
(EEF!) \ stores a 32-bit floating point number
(EEX!) \ stores a 32-bit extended address

The parenthesis are included in the names to remind the programmer that these routines expect 16 bit page-less addresses rather than 32 bit extended addresses on the data stack. For example, to store the value 1234H at address AEC0H, execute

HEX 1234 AEC0 (EE!)

To avoid wearing out the EEPROM by executing unneeded write cycles, these words check whether each EEPROM byte already holds its specified contents. If so, the write is not performed. Thus there is no penalty for redundant execution of commands that initialize particular locations in EEPROM. The initializations can be performed every time the processor starts up, with no adverse effects on the life span of the EEPROM. For example, initialization code in an autostart routine could execute ATTACH commands to ensure that all needed interrupt vectors are properly initialized each time the processor restarts. The ATTACH routine calls the (EEC!) routines to store the specified interrupt vector into EEPROM. If the EEPROM cells have been corrupted for some reason, the ATTACH command installs the correct contents. If the specified interrupt vector information is already in the EEPROM, the memory cells are not modified.

All of the EEPROM storage routines globally disable interrupts while each EEPROM byte is being programmed, and it takes 20 milliseconds to program each byte. Thus you should avoid storing values in EEPROM while time-critical events are being serviced by interrupts. (For experts and the curious: Interrupts are disabled during stores to EEPROM because QED-Forth vectors all interrupts via the EEPROM, and the 68HC11 hardware does not allow any EEPROM cells to be read while a single EEPROM cell is being written to. Thus if an interrupt occurs while one of the EE! words is writing to EEPROM, the interrupt will not be able to read the instruction code in the interrupt vector).

Once values have been stored in the EEPROM, they may be read using the conventional memory fetch operations such as C@, @, and 2@.

It is possible to write-protect locations within the EEPROM to ensure the integrity of calibration constants or other vital information. This is done using the EEPROM block protect register named BPROT (F1 p.8-2). Four blocks of size 32, 64, 128, and 288 bytes may be individually protected by storing an appropriate configuration value to BPROT. The contents of the BPROT register may be changed using the QED-Forth word INSTALL.REGISTER.INITS; please consult its glossary entry for details.

To make a turnkeyed application maximally "bullet-proof" and fail-safe, consider using the BPROT register to protect the first three blocks in the EEPROM totaling 224 bytes. This protects the QED-Forth configuration region (the first 32 bytes in EEPROM) plus the interrupt vectors (the next 160 bytes in EEPROM) plus an additional 32 bytes available the programmer. The remaining 288 bytes of EEPROM then remain available for modification by the application program.

 
This page is about: Programming EEPROM on 68HC11 MC68HC11F1 Microcontroller – The 68HC11F1 has 512 bytes of on chip EEPROM (electrically erasable programmable read only memory). QED Forth locates EEPROM block at AE00H through AFFFH. The first 192 bytes of this non volatile memory are reserved for QED Forth initialization …
 
 
Navigation