Hello.
I have a question regarding the title, when issuing the following API using fsl_flash.c of the kinetis SDK Driver.
FLASH_Erase( ,,,,)
FLASH_Program(,,,,)
Is it necessary to execute this API with interrupts disabled?
In other words, before calling this API, the user should disable interrupts and allow interrupts after the execution is complete.
Thank you in advance.
zunda
Hi,
I suppose that you are right.
As you know when the flash is operated for example erasing or programming, the same flash block is NOT allowed to be accessed.
So the operating flash code is copied to on-chip ram and executed from RAM. Because interrupt table and ISR are saved in flash, while the flash is operated, if an external interrupt happens, in the case, the flash can not be accessed, so hardware fault will happens.
In conclusion, you have to disable interrupt while you operate flash.
Hope it can help you
BR
XiangJun Rong
Thank you for your reply.
I would like to ask for one more piece of advice.
Actually, I'm communicating via MODBUS on another thread, and communication errors are occurring because UART interrupts are being delayed due to interrupts being disabled for FLASH operations. Is there a way to prevent this from happening? Would DMA be an effective solution?
Hi,
As you said that interrupt should be disabled when you operate flash.
But if you want to enable all interrupt during the flash operation such as erasing/programming, you can copy the interrupt table to SRAM, copy the ISR to SRAM, change the VTOR so that the core can access the interrupt table. But the KM family uses Cortex-M0 core, which does not have VTOR register, so the solution can not be implemented.
In conclusion, no way to enable interrupt while you operate flash.
Hope it can help you
BR
XiangJun Rong