Hi Vikas,
I'm apologize i can't remember how i solved it.
But i can give you my FTFC command function.
I also remember something about HSRUN clock mode limitation with the FTFC module.
Initialization:
FLASH_DRV_Init(&flash1_InitConfig0, &internalFlash_flashSSDConfig);
if (internalFlash_flashSSDConfig.EEESize == 0) {
FLASH_DRV_DEFlashPartition(&internalFlash_flashSSDConfig, 0x2, 0x4, 0x3, true, true);
}
CSEC_DRV_Init(&csec1_State);
CSEC_DRV_InitRNG();
Prototype:
void executeFlashCommand(uint8_t a_cmd, uint32_t a_addr, uint8_t *a_pageBuffer) __attribute__ ((section(".code_ram")));
Function:
void executeFlashCommand(uint8_t a_cmd, uint32_t a_addr, uint8_t *a_pageBuffer) {
uint8_t v_AddrVec[3];
v_AddrVec[0] = (a_addr & 0x00FF0000) >> 16;
v_AddrVec[1] = (a_addr & 0x0000FF00) >> 8;
v_AddrVec[2] = (a_addr & 0x000000FF) >> 0;
INT_SYS_DisableIRQGlobal();
while ((FTFC->FSTAT & FTFC_FSTAT_CCIF_MASK) == 0);
FTFC->FSTAT = FTFC_FSTAT_ACCERR_MASK | FTFC_FSTAT_FPVIOL_MASK;
FTFC->FCCOB[3] = a_cmd; //Program Phrase command (0x07)
FTFC->FCCOB[2] = v_AddrVec[0]; //Flash address [23:16]
FTFC->FCCOB[1] = v_AddrVec[1]; //Flash address [15:08]
FTFC->FCCOB[0] = v_AddrVec[2]; //Flash address [7:0]
if (a_pageBuffer != NULL) {
FTFC->FCCOB[7] = a_pageBuffer[0]; //data
FTFC->FCCOB[6] = a_pageBuffer[1];
FTFC->FCCOB[5] = a_pageBuffer[2];
FTFC->FCCOB[4] = a_pageBuffer[3];
FTFC->FCCOB[11] = a_pageBuffer[4];
FTFC->FCCOB[10] = a_pageBuffer[5];
FTFC->FCCOB[9] = a_pageBuffer[6];
FTFC->FCCOB[8] = a_pageBuffer[7];
}
FTFC->FSTAT = FTFC_FSTAT_CCIF_MASK; //launch command
while ((FTFC->FSTAT & FTFC_FSTAT_CCIF_MASK) == 0); //wait for done
INT_SYS_EnableIRQGlobal();
}