AnsweredAssumed Answered

Flash driver fails when configuring swap at 180MHz

Question asked by Patrick Lewis on Aug 3, 2016
Latest reply on Aug 4, 2016 by Mark Butcher

When trying to initialize flash swapping for reprogramming purposes, I am failing when calling to execute flash swap configuration commands using the FLASH_SwapControl function in the fsl_flash.c driver file when running my core clock frequency at 180MHz. Note, that it works fine when running at 120MHz. I have verified that my flash clock is divided down by 7 so that it is below the required 28MHz. The code used for configuring the flash is right out of the demo app up for reading/writing flash right up until we configure the swap as shown below:

 

--------------------------------------------

DEMO APP CODE from main function of SDK_2.0_MK26FN2M0xxx18/boards/twrk65f180m/driver_examples/flash/flash_erase_program_verify/flash_erase_program_verify.c

--------------------------------------------

OUR CODE BELOW:

--------------------------------------------

    PRINTF("\r\n");
    activeBlock = (FTFE->FCNFG >> 3) & 0x01;

    if( activeBlock == 0 )
    {
        PRINTF("Program Flash Half 0 (Blocks 0/1) located at address 0x0000\n");
        PRINTF("Executing from Program Flash Half 0 (Blocks 0/1) \n\n");
        settingsAddress =  pflashTotalSize - (3*pflashSectorSize) - pflashSectorSize;
    }
    else
    {
        PRINTF("Program Flash Half 1 (Blocks 2/3) located at address 0x0000\n");
        PRINTF("Executing from Program Flash Half 1 (Blocks 2/3) \n\n");
        settingsAddress =  (pflashTotalSize / 2) - (3*pflashSectorSize) - pflashSectorSize;
    }

    flashSwapAddress = (pflashTotalSize / 2) - pflashSectorSize;
    result = FLASH_SwapControl(&flashDriver, flashSwapAddress, kFLASH_swapControlOptionReportStatus, &flashSwapState);
    if( result != kStatus_FLASH_Success )
    {
        PRINTF("\r\n ERROR flash_SwapControl optionReport Status Result = %d 0x%x", result, result);
    }

................................

MORE UNRELATED CODE

 

The bolded line of code returns a 0x67 from the attempted call of flash_command_sequence. The 0x67 indicates a kFlash_AccessError.

 

Is there something we need to configure in the driver, or something else that needs to be done prior to making this call when running in High Speed mode?

Outcomes