FLASH (Program memory) Routines. 

These routines allow the writing and reading of the program memory. Although intended for storage of infrequently-changing data, such as user-entered calibration constants that are too large to fit into EEPROM, they could also be used for loading or modifying code. The program memory is organized in “rows” of 64 bytes for writing purposes. In order to change one or more bytes, the user must read an entire 64 byte row (which must be on a 64 byte boundary) into RAM, change the bytes, then write the entire 64 byte row.

The TBLPTR register must be set up with the address of the FLASH memory to be read or written before calling each routine; it must be on a 64 byte boundary. On return, TBLPTR will be have been changed. 

Click on a routine name to see the source.

ReadFlashRow( addr(ramdata)) 

Read 64 bytes of program memory starting at the address in TBLPTR into RAM starting at ramdata. 

WriteFlashRow(addr(ramdata)) 

Write 64 bytes of data from RAM starting at ramdata into program memory, starting at the address in TBLPTR. 

Example: 

Const FlashAddr = 0x7FC0
Dim FlashData(10) as uInteger 

TBLPTR = FlashAddr
ReadFlashRow( addr(FlashData))


FlashData(4) = 26
FlashData(5) = 5542

TBLPTR = FlashAddr
WriteFlashRow(addr(FlashData))