Hi Glen,
Please read section 27.4.5 and 27.4.6 first. Reading from program flash memory space while a flash command is active is not allowed. When the flash is programming, MCU can't get next code from Flash. This will cause hardfault.
There is flash demo in KL16 SDK (SDK_2.2.0_MKL16Z64xxx4.zip\boards\frdmkl26z\driver_examples\flash\pflash). You can see that is code is execute in flash too. This is because before it trig flash erase/program command, it will copy a small piece of code to ram. This code will write CCIF register to launch the command and wait till command finish.
So, please refer to the pflash example and use this code directly. Flash can't program in VLPR mode. And please disable all interrupt before erase/program flash. This is because if interrupt happened during flash operation, MCU will read flash for interrupt vector address and service code. This will cause hardfault.
Regards,
Jing
Hi
See
https://www.utasker.com/kinetis/FRDM-KL26Z.html
You can use Flash for file system, logging of parameter system and the SDK will certainly have flash drivers for the device.
If you want a complete solution just use the open source uTasker project since it includes these as standard and allows simulation of the KL26(16), including its flash and other peripherals.
https://github.com/uTasker/uTasker-Kinetis
file system/parameter system and flash API document:
https://www.utasker.com/docs/uTasker/uTaskerFileSystem_3.PDF
Regards
Mark
[uTasker project developer for Kinetis and i.MX RT]