Good morning, I keep having a Flash Access Error Flag whenever I attempt to write to the Flash Status Register. I am attempting to use the Freescale libraries that were provided to initialize the Flash Swap function on a K66. The function that I am attempting to execute is called FLASH_SwapControl.
Inside the flash swap control, one of the steps attempts to reset the CCIF bit in the flash status register, by setting it to a 1. However, as soon as it tries to do this, the access error flag (in the same register) gets set and then everything goes downhill. All of this is being executed internally in the Freescale library, so I not 100% sure of what each step does. Here are libraries. Can anyone point me to the right direction as to why this is happening? Any help is very appreciated. Thank you.
Not sure if it's relevant, and unfortunately it's not an immediate solution, but it may provide some guidance. I've been experiencing a similar issue with K64 and receiving, what I believe to be, the same error. However, with my issue, the error only occurs on the 2nd attempt to swap.
Also, my original was seen with SDK2.4.2 for K64 which included v3.0.0 of the FSL_FLASH_DRIVER. My interim solution was to revert back to an older flash driver version (v2.1.0).
Here is the original thread...
Does anyone have any suggestions? I'm completely lost as to what is happening.
This is the line that it is giving me an access error flag.
#define FTFx_REG8_ACCESS_TYPE volatile uint8_t *
/*! @brief A function pointer used to point to relocated flash_run_command() */
static void (*callFlashRunCommand)(FTFx_REG8_ACCESS_TYPE ftfx_fstat);
* @brief Flash 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_FLASH_Success
static status_t flash_command_sequence(flash_config_t *config)
/* clear RDCOLERR & ACCERR & FPVIOL flag in flash status register */
FTFx->FSTAT = FTFx_FSTAT_RDCOLERR_MASK | FTFx_FSTAT_ACCERR_MASK | FTFx_FSTAT_FPVIOL_MASK;
status_t returnCode = flash_check_execute_in_ram_function_info(config);
if (kStatus_FLASH_Success != returnCode)
/* 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). */
#endif /* FLASH_DRIVER_IS_FLASH_RESIDENT */
/* Check error bits */
/* Get flash status register value */
registerValue = FTFx->FSTAT;
/* checking access error */
if (registerValue & FTFx_FSTAT_ACCERR_MASK)
/* checking protection error */
else if (registerValue & FTFx_FSTAT_FPVIOL_MASK)
/* checking MGSTAT0 non-correctable error */
else if (registerValue & FTFx_FSTAT_MGSTAT0_MASK)
Remember that flash operations are not possible in HSRUN mode - check that you are not running at > 120MHz.
uTasker developer and supporter (+5'000 hours experience on +60 Kinetis derivatives in +80 product developments)
uTasker - for more performance and faster, cheaper product development