Hi Pietro,
I checked your code, I find your code when run the flash_ops_write function, the code will be reset.
But run the erase have no problem.
So, I check your erase and program code, I find in your erase function, before you launch the flash operation, you disable the interrupt, after it finished, it enable the interrupt.
But in the program function, you didn't do it, so when you do the flash operation, your flash program will be interrupt by the PIT interrupt, then the MCU will have problems, it will reset the system, now I add the interrupt disable code before the program function, the reset problem will be disappear.
__disable_irq();
status = flash_ops_write( fbuf, start, length );
__enable_irq();
But, your code function seem still have problem, I check the memory, I find the code didn't write to the according address. Do you check your code function before? Whether it can write successfully to your according address?
If your function also have problem, I suggest you refer to our official KE18 SDK flash code, you can port the official code to your own project.
Wish it helps you!
Have a great day,
Kerry
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------