AnsweredAssumed Answered

MPC5566: Why does flash erase code hang?

Question asked by Ryan K on Dec 3, 2019
Latest reply on Jan 24, 2020 by Ryan K

I'm working on a bootloader that loads using CAN messages with the BAM. Once the bootloader starts running, it listens for other messages on CAN that it uses to program the flash memory.

I'm trying to add support that will allow parts of flash to be erased in case the user wants to power cycle and start over, particularly I want to be able to erase the first 8 bytes in flash that can cause a boot failure if the image isn't ready.

 

I'm using the driver code from:

MPC5566|32-bit MCU|Powertrain | NXP 

 

But any calls I make to the FlashInit_C and the FlashErase_C hang and never return.

I'm using SetLock_C prior to trying to erase, but I still get hangs when I try to erase.

 

I see similar behavior if I try to just overwrite an address with zeros. From the manual, it sounds like when you program you're changing 1's to 0's and cannot do the reverse. So it seems like I should be able to write 0xA5A5A5A5 for example, then write again with 0x00000000. But on the second write, the FlashProgram_C call just hangs.

 

Why does it hang? How can I erase?

Outcomes