User programs are written to eeprom and are unprotected. Am I on the right track?
Both the flash and the EEPROM can be protected on the PIC chips.
I've never tried to read the EEPROM but this Microchip document
Advanced Code Security Features in 8-bit PIC Microcontrollers states that EEPROM can be protected, like flash, and reading protected EEPROM will return all zeros:
"The CPD Configuration bit protects the entire data EEPROM memory space from external read and write operations. When CPD = 0, external read and write operations of the data EEPROM memory are inhibited, and a read will return all zeros."
You can configure the EEPROM protection so that it only applies to external access, e.g. reading it using a programmer like the pickit2, and it allows internal program running on the chip can read and write to the EEPROM.
The document above also describes "Impact of Bulk Erase Operation" as "Completely erases the memory" in the flash, eeprom, configuration bits and user id memory sections.
So if I'm reading you correctly, the pocsxe code is written to data memory by rev-ed and is code protected. User programs are written to eeprom
Older microchip PIC chips, like the PIC12F683 used for the PICAXE 08M, did not provide the commands to allow the program that was running from flash to modify the contents of flash so when you downloaded the user program the PICAXE firmware running from the flash on the chip could only write the user program to the EEPROM.
The 08M/PIC12F683 chip has 2048 bytes of flash and 256 bytes of EEPROM.
The PICAXE firmware is stored in the 2048 bytes of flash and both the user program and the PICAXE BASIC DATA/TABLE data are stored in the 256 bytes of EEPROM.
So the 08M specs are:
- For the user program "Memory Capacity (bytes)" = 256 and "Max. Memory Capacity (lines)" = 220. i.e. the user program could use all the EEPROM space.
- For the DATA/TABLE data "Data EEPROM (bytes)" = 256-P, which means 256 bytes minus the size of the user program. i.e. the bigger the user program the smaller the amount memory available for DATA/TABLE data in the user program.
Newer Microchip PIC chips , like the PIC12F1840 used for the PICAXE 08M2, added commands that allowed the running program to modify the contents of flash.
The 08M2/PIC12F1840 chip has 4096 bytes of flash and 256 bytes of EEPROM.
and the 08M2 specs are:
- For the user program "Memory Capacity (bytes)" = 2048 and "Max. Memory Capacity (lines)" = 1800. As the chip only has 256 bytes of EEPROM the user program can only be stored in the flash not used by the PICAXE firmware and this is made possible by the commands that allow the running program to modify the contents of flash.
- For the DATA/TABLE data "Data EEPROM (bytes)" = 256. Now that the user program is being stored in flash, all the EEPROM memory can be used for DATA/TABLE data.
NOTE #1: The manual #1 states that on the 08M2 chip the DATA/TABLE memory is shared with the user program, which conflicts with the contents of the "PICAXE-M2 Information" document that was published when the 08M2 chip was released, so the specific info about the 08M2 above might be wrong.
When I check using PE 6.2.0.0 what I think Alleycat described in post
#4 I get a different result:
However, that detail doesn't matter as the 08M2 example I give above is intended to describe the general difference between the older chips where the user program was stored in EEPROM and those new chips where the user program is being stored in flash.
NOTE #2: The manual #1 also describes that "On X1 and X2 parts 256 bytes of the program memory can also be ‘reserved’ as a lookup table" for the TABLE/READTABLE commands.