Tool/software:
Hello,
I am having issues with erasing and reprogramming the emulated EEPROM area using the F021 library on TMS570LS0714. All API calls return success, but nothing is being erased at address 0xF0200000.
When I include this code in the main function and flash it as the main project, it works with no issues. However, I need to implement this function as a part of an existing project as a secondary project - a small software module that is downloaded over CAN (to flash, not RAM) and executed by the main software. When this is the case it doesn't erase anything.
I'm trying to understand if there is something that protects the bank 7 or prevents it from being erased (in the reference manual SPNU607A and the F021 reference guide SPNU501H) but could not find anything. FBBUSY value before erase is 0x7E which means bank 7 is not busy. I checked the flash pump registers and the fallback power register FBFALLBACK and all pumps are active.
I also tried disabling the IRQs and FIQs before the operation but didn't help.
Below is my code:
#include "sys_common.h"
#include "F021.h"
#define SYS_CLK_FREQ 160
int myFunction(void) {
Fapi_initializeFlashBanks((uint32_t) SYS_CLK_FREQ);
Fapi_setActiveFlashBank((Fapi_FlashBankType)7);
while (FAPI_CHECK_FSM_READY_BUSY != Fapi_Status_FsmReady);
Fapi_enableEepromBankSectors(0xFFFFFFFF, 0xFFFFFFFF);
while (FAPI_CHECK_FSM_READY_BUSY != Fapi_Status_FsmReady);
uint32_t i;
for (i = 0; i < 16; i++) {
Fapi_issueAsyncCommandWithAddress(Fapi_EraseSector, (void*)(0xF0200000 + 0x1000 * i));
while (FAPI_CHECK_FSM_READY_BUSY == Fapi_Status_FsmBusy);
while (FAPI_GET_FSM_STATUS != Fapi_Status_Success);
}
}
The code just runs "fine" all the way to the end as if everything was good, but has zero effect.
Any help would be greatly appreciated. Thanks.
---
Edit:
While diagnosing the issue I wanted to do some manual tries on flash registers and I realized the lines below don't do anything (supposed to edit the WR_ENA register)
uint32_t preVal = *(volatile uint32_t *)0xFFF87288;
*(volatile uint32_t *)0xFFF87288 = (preVal & 0xFFFFFF00) | 0x05;
*(volatile uint32_t *)0xFFF87288 = (preVal & 0xFFFFFF00) | 0x02;
and also these don't work:
FLASH_CONTROL_REGISTER->FsmWrEna.FSM_WR_ENA_BITS.WR_ENA = 0x5U;
FLASH_CONTROL_REGISTER->FsmWrEna.FSM_WR_ENA_BITS.WR_ENA = 0x2U;
So turns out being in the user mode is preventing the code from modifying the memory.