I wonder if you might be able to help me with a problem I am having here using the KL28..
Basically, I am using a function to erase a sector of flash on the KL28, the function is running from RAM (and code is generated using GCC compiler)..
If I run the function as shown below without a “nop” instruction at the end of the function I get a ‘hard-fault’ generated.. I can’t figure out why the ‘nop’ instruction would have any effect..
I have compared the disassembly with and without the ‘nop’ and its pretty much the same…
Here's the function..
here's is the disassembly comparison of the code generated when i insert the 'NOP' versus the when the 'NOP' is removed, they are practically the same except for whats shown in the snippet below..
I wonder is there a delay required after issuing the flash cache instruction before returning from the function..
Any help would be much appreciated.. I am pulling our hair out here.. :-)
regards
Trevor
Hi Trevor,
I replicated the issue on my side by copying your function in the pflash example that it's in the KL28 SDK (using MCUXpresso) and I was able to run the project with or without the nop so I have the following comments:
-Are you able to know the address of the highlighted instruction in the following snippet? I believe is not an issue caused by the nop I think your function is not returning correctly.
-As you can see in the following snippet when I run the project I get the next instructions in disassembly and there are some differences, the highlighted instructions is the one that exits the function.
I hope this is useful.
Best regards,
Felipe