Tool/software: Code Composer Studio
Hi,
I'm trying to use F021 Flash API to erase the flash then load a new program.
1-) I copy some code on the RAM memory.
2-) I run this code to clear the flash.
void erase() { uint32_t s = 0; Fapi_StatusType r = Fapi_initializeFlashBanks(128); ENABLE_CPU_PRIVILEGE_MODE; Fapi_FlashBankSectorsType type; r = Fapi_getBankSectors(Fapi_FlashBank0, &type); while (FAPI_CHECK_FSM_READY_BUSY != Fapi_Status_FsmReady); s = FAPI_GET_FSM_STATUS; r = Fapi_setActiveFlashBank(Fapi_FlashBank0); r = Fapi_enableMainBankSectors(32); while (FAPI_CHECK_FSM_READY_BUSY != Fapi_Status_FsmReady); uint32_t* flash = (uint32_t*)(0x00014000); r = Fapi_issueAsyncCommandWithAddress(Fapi_EraseSector, flash); while( FAPI_CHECK_FSM_READY_BUSY == Fapi_Status_FsmBusy ); do { s = FAPI_GET_FSM_STATUS; }while(s != Fapi_Status_Success); DISABLE_CPU_PRIVILEGE_MODE; }
From the memory browser view, I can see that the memory for this banking sector is filled with 1.
3-) I try to write something in the flash
void program() { uint32_t s = 0; Fapi_StatusType r = Fapi_initializeFlashBanks(128); ENABLE_CPU_PRIVILEGE_MODE; while (FAPI_CHECK_FSM_READY_BUSY != Fapi_Status_FsmReady); s = FAPI_GET_FSM_STATUS; r = Fapi_setActiveFlashBank(Fapi_FlashBank0); r = Fapi_enableMainBankSectors(32); while (FAPI_CHECK_FSM_READY_BUSY != Fapi_Status_FsmReady); uint8_t tmp[8]={0}; r = Fapi_issueProgrammingCommand((uint32_t*)(0x00014000), tmp, 8, 0, 0, Fapi_AutoEccGeneration); while( Fapi_checkFsmForReady() == Fapi_Status_FsmBusy ); do { s = Fapi_getFsmStatus(); //0x00001010 }while(s != Fapi_Status_Success); DISABLE_CPU_PRIVILEGE_MODE; }
Fapi_issueProgrammingCommand failed to write in the flash memory.
In FMSTAT register, PGV is set to 1.
The documentation states :
Program verify When set, indicates that a word is not successfully programmed after the maximum allowed number of program pulses are given for program operation.
I don't understand why writing fails.
Thanks