Other Parts Discussed in Thread: LAUNCHXL2-TMS57012, , HALCOGEN
Dear Support,
I tried to write a single byte into the flash (as it was described in SPNA148). I executed this from RAM also I couldn't see any issue juts the flash hasn't been updated. I also tried to update the EEPROM but I got the same result.
void flash_write_byte(uint32_t address)
{
Fapi_StatusType oReturnCheck = Fapi_Status_FsmReady;
FwpWriteByteAccessorType * oFwpWriteByteAccessor = FWPWRITE_BYTE_ACCESSOR_ADDRESS;
oReturnCheck = Fapi_initializeFlashBanks(160); /* Example code is assuming operating
frequency of 180 MHz */
if ((oReturnCheck == Fapi_Status_Success) && (FLASH_CONTROL_REGISTER->FmStat.FMSTAT_BITS.BUSY
!= Fapi_Status_FsmBusy))
{
oReturnCheck = Fapi_setActiveFlashBank(Fapi_FlashBank7);
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 = 0xF0000111;
/* Placing byte at address 0x0102 */
oFwpWriteByteAccessor[2] = 0xBB;
/* Set command to "Program" */
FLASH_CONTROL_REGISTER->FsmCommand.FSM_COMMAND_BITS.FSMCMD =
Fapi_ProgramData;
/* Execute the Program command */
FLASH_CONTROL_REGISTER->FsmExecute.FSM_EXECUTE_BITS.FSMEXECUTE = 0x15U;
/* re-lock FSM registers to prevent writing */
FLASH_CONTROL_REGISTER->FsmWrEna.u32Register = 0x2U;
/* Wait for FSM to finish */
while (FLASH_CONTROL_REGISTER->FmStat.FMSTAT_BITS.BUSY
== Fapi_Status_FsmBusy)
;
/* Check the FSM Status to see if there were no errors */
if (FLASH_CONTROL_REGISTER->FmStat.u32Register != 0)
{
/* Put Error handling code here */
}
}
}
Also I found other implementation on the forum, I tried the following, but I got the same result:
void flash_write_byte(uint32_t address)
{
Fapi_StatusType oReturnCheck = Fapi_Status_FsmReady;
FwpWriteByteAccessorType * oFwpWriteByteAccessor =
FWPWRITE_BYTE_ACCESSOR_ADDRESS;
uint8_t au8MainDataBuffer[16] = {0xAA, 0x17, 0x19, 0x2E, 0x0A, 0xB9, 0x11, 0x70, 0x5F, 0xC1, 0x9C, 0xFD, 0x54, 0x51, 0xED, 0x86};
uint8_t au8EccDataBuffer[16];
uint32_t *pu32StartAddress = (uint32_t *)(0xF0000111);
uint8_t *p1;
uint8_t *eccp1;
p1 = au8MainDataBuffer;
eccp1 = au8EccDataBuffer;
oReturnCheck = Fapi_initializeFlashBanks(160); /* Example code is assuming operating
frequency of 180 MHz */
if ((oReturnCheck == Fapi_Status_Success) && (FLASH_CONTROL_REGISTER->FmStat.FMSTAT_BITS.BUSY
!= Fapi_Status_FsmBusy))
{
oReturnCheck = Fapi_setActiveFlashBank(Fapi_FlashBank7);
oReturnCheck = Fapi_enableEepromBankSectors(0xF, 0);
while (Fapi_checkFsmForReady() == Fapi_Status_FsmBusy)
;
if ((oReturnCheck == Fapi_Status_Success)
&& (Fapi_checkFsmForReady() != Fapi_Status_FsmBusy))
{
oReturnCheck = Fapi_issueProgrammingCommand(&pu32StartAddress,
p1,
16,
NULL,
0,
Fapi_AutoEccGeneration);
/* Wait for FSM to finish */
while (Fapi_checkFsmForReady() == Fapi_Status_FsmBusy)
;
if ((oReturnCheck == Fapi_Status_Success)
&& (Fapi_checkFsmForReady() != Fapi_Status_FsmBusy))
{
/* Check the FSM Status to see if there were no errors */
if (FLASH_CONTROL_REGISTER->FmStat.u32Register != 0)
{
/* Put Error handling code here */
}
}
}
}
}
Can you help me please? Thank you!
Kind regards,
Keno

