why would a hard-fault be generated during a flash sector erase on the KL28?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

why would a hard-fault be generated during a flash sector erase on the KL28?

415 Views
trevorhunt
Contributor I

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.. 

pastedImage_1.png

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.. 

pastedImage_2.png

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

Labels (1)
0 Kudos
1 Reply

294 Views
FelipeGarcia
NXP Employee
NXP Employee

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.

pastedImage_1.png

-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.

pastedImage_2.png

I hope this is useful.

Best regards, 

Felipe

0 Kudos