Hi,
Thanks for your feedback.
Now I know kinetis flash can not read and programmed/erased a same flash bank at the same time.
If I want to do this, it have to copy run command to ram or enable ESFC bit in MCM PLACR.
But I found the SDK as below. when FTFx_DRIVER_IS_FLASH_RESIDENT is open, it will copy run command to ram. but why do not add disable interrupt and enable interrupt before and after running flash ram command. Also do not Enable stalling flash controller when flash is busy when FTFx_DRIVER_IS_FLASH_RESIDENT is not open.
if do not do this, it will lead something wrong, such as: chip reset(flash operation hard fault), print out messy logs, when read and programmed/erased a same flash bank at the same time.
-------------------------------------------------------------------------------------------------------------------
/*!
* @brief FTFx Command Sequence
*
* This function is used to perform the command write sequence to the flash.
*
* @param driver Pointer to storage for the driver runtime state.
* @return An error code or kStatus_FTFx_Success
*/
static status_t ftfx_command_sequence(ftfx_config_t *config)
{
uint8_t registerValue;
#if FTFx_DRIVER_IS_FLASH_RESIDENT
/* clear RDCOLERR & ACCERR & FPVIOL flag in flash status register */
FTFx->FSTAT = FTFx_FSTAT_RDCOLERR_MASK | FTFx_FSTAT_ACCERR_MASK | FTFx_FSTAT_FPVIOL_MASK;
/* Since the value of ARM function pointer is always odd, but the real start address
* of function memory should be even, that's why +1 operation exist. */
config->runCmdFuncAddr.commadAddr += 1UL;
callFtfxRunCommand_t callFtfxRunCommand = config->runCmdFuncAddr.callFlashCommand;
/* We pass the ftfx_fstat address as a parameter to flash_run_comamnd() instead of using
* pre-processed MICRO sentences or operating global variable in flash_run_comamnd()
* to make sure that flash_run_command() will be compiled into position-independent code (PIC). */
callFtfxRunCommand((FTFx_REG8_ACCESS_TYPE)(&FTFx->FSTAT));
config->runCmdFuncAddr.commadAddr -= 1UL;
#else
/* clear RDCOLERR & ACCERR & FPVIOL flag in flash status register */
FTFx->FSTAT = FTFx_FSTAT_RDCOLERR_MASK | FTFx_FSTAT_ACCERR_MASK | FTFx_FSTAT_FPVIOL_MASK;
/* clear CCIF bit */
FTFx->FSTAT = FTFx_FSTAT_CCIF_MASK;
/* Check CCIF bit of the flash status register, wait till it is set.
* IP team indicates that this loop will always complete. */
while (!(FTFx->FSTAT & FTFx_FSTAT_CCIF_MASK))
{
}
#endif /* FTFx_DRIVER_IS_FLASH_RESIDENT */