Hello,
If you search this forum, you should find numerous examples of programming non-volatile data to a flash block, from within an application. This is a very frequent request. The datasheet for the device details the erase amd programming algorithms used, and provides flow diagrams.
Some basics to keep in mind -
- The minimum block size for erasure is 512 bytes.
- Flash memory within the same flash array is inaccessible during the erasure or byte programming process, so the code for these operations must be transferred to RAM, and run from there. The device you are using, along with most other HCS08 devices, has only a single flash array.
- The RAM based code may be either pushed onto the stack, or alternatively occupy a fixed block of RAM. The size of the block is quite variable, depending on the specific implemtation. For the 'SH8 device, the minimum is about 20 bytes of code.
- Interrupts need to be globally disabled during the erasure or byte programming process.
Regards,
Mac