Buffered Flash memory access routines for PIC microcontrollers
This is an intermediate code layer for fast and flat; non block boundary limited access to Flash memory. Written for the CCS C compiler and libraries for Microchip PIC microcontrollers. This lib resides right on top of CCS C built-in functions read_program_memory() and write_program_memory(), fulfilling their limitations and making per byte read/write/erase operations to Flash memory possible like that of EEPROM.
This code is originally written for PIC18F452. So the parameters RAM_ZEROZ, BLOCK_SIZE, and FLASH_DATA_END needs to be changed accordingly when implementing to a different PIC.
#byte RAM_ZEROZ = 0x0600
Is set so because, PIC18F452 have 1536 bytes on-chip RAM that ends at address 0x05ff and the vast unused address space after that is read as zero as per the datasheet.
The function flash_erase() erases destination bytes by writing zeros to it; sourced from this imaginary area, the '/dev/zero' of PIC.