Hello,
We are running out of Flash Bank 0 and trying to flash Bank 1. We seem to be able to erase fine, but not re-program. When flashing we always fail with register FMSTAT indicating a write timeout (PGM = 1).
To try isolating the problem, I also attempted to write a single byte of data to FB1 using the Flash register interface... and I get the same issue. I'm wondering if someone can give me some insight into what's going on.
Below is the routine I use to flash a single byte to FB1.
void ProgramSingleByte() {
FwpWriteByteAccessorType * oFwpWriteByteAccessor = FWPWRITE_BYTE_ACCESSOR_ADDRESS;
FLASH_CONTROL_REGISTER->Fbprot.u32Register = 1U; /* Disable Level 1 Protection */
/* Enable all sectors of current bank for erase and program. For EEPROM banks with more
than 16 sectors, this must be 0xFFFF */
FLASH_CONTROL_REGISTER->Fbse.u32Register = 0xFFFF;
FLASH_CONTROL_REGISTER->Fbprot.u32Register = 0U; /* Enable Level 1 Protection */
/*Unlock FSM registers for writing */
FLASH_CONTROL_REGISTER->FsmWrEna.u32Register = 0x5U;
/* Set command to "Clear the Status Register" */
FLASH_CONTROL_REGISTER->FsmCommand.FSM_COMMAND_BITS.FSMCMD = Fapi_ClearStatus;
/* Execute the Clear Status command */
FLASH_CONTROL_REGISTER->FsmExecute.FSM_EXECUTE_BITS.FSMEXECUTE = 0x15U;
/* Write address to FADDR register */
FLASH_CONTROL_REGISTER->Faddr.u32Register = 0x00180000U;
//xxx FLASH_CONTROL_REGISTER->Faddr.u32Register = 0x0100U;
/* Placing byte at address 0x0102 */
oFwpWriteByteAccessor[2] = 0xA5;
/* Set command to "Program" */
FLASH_CONTROL_REGISTER->FsmCommand.FSM_COMMAND_BITS.FSMCMD = Fapi_ProgramData;
/* Execute the Program command */
/*
* Immediately after this step is executed the FMSTAT.CSTAT bit (any failure)
* goes high, as does the FMSTAT.PGV (write timeout?)
*/
FLASH_CONTROL_REGISTER->FsmExecute.FSM_EXECUTE_BITS.FSMEXECUTE = 0x15U;
/* re-lock FSM registers to prevent writing */
FLASH_CONTROL_REGISTER->FsmWrEna.u32Register = 0x2U;
}
Thanks.