I am using KEA 128 microcontroller with s32 studio IDE. But i am facing problem with FLASH driver when i run continuously without step by step debugging.
I have configured bus clock frequency to 20MHZ, and FTMRE_FCLKDIV is configured to 0x13.
When i do step by step debug, I am able to erase and write any number of bytes but if i run at one shot, even the Erase is not working, instead hitting reset handler.
I have also attached my project for your reference.
Can somebody help me to find out the issue.
Original Attachment has been moved to: FlashTest.zip
I think you are not checking MGBUSY Flag(Memory controller busy flag) in status register FTMRE_FSTAT, before starting to send a new flash command.
Is that right?
After I added the below part of the code, and its been called on every flash operaiton, it started working fine.
void FLASH_LaunchCMD(uint8_t bWaitComplete)
MCM->PLACR |= MCM_PLACR_ESFC_MASK; /* enable stalling flash controller when flash is busy */
FTMRE->FSTAT = 0x80;
// Wait till command is completed
while (!(FTMRE->FSTAT & FTMRE_FSTAT_CCIF_MASK));