Other Parts Discussed in Thread: TMS570LS3137, HALCOGEN
Tool/software:
Hi TI Team,
I have been using TI MCU tms570ls3137 and want to utilize virtual EEPROM on BANK7. so i have proceeded below steps
I have generated FEE driver code through Halcogen and included FAPI library. while using FAPI library my code is working
i am able to write a byte on flash. but I am restricted to use FAPI and needs to avoid FAPI library. as in snippet code only 2 API are still used from FAPI
Fapi_initializeFlashBanks(180);
Fapi_setActiveFlashBank(Fapi_FlashBank7);
So i can not exclude FAPI library. as Fapi_setActiveFlashBank(Fapi_FlashBank7); FAPI function says set the active flash bank
so i replaced with (FLASH_CONTROL_REGISTER->Fmac.u32Register = Fapi_FlashBank7; //0xFFF87050) but i am not able to
write after setting with this method please see highlighted lines in below code snippet.
So i have various questions
Q1 . Can we write our own API just to avoid FAPI library if yes what is the wrong i am doing. in above line.
Q2. Can you share gthese 2 api defination so that we can come out of FAPI library dependency.
Q3. As i was going through Debugging i found Some Reserve registers are getting reflected ex. (CONFIG_FLOCK) 0x0000055AA (21930) --> 0x000000000 and it is cleared
After Fapi_initializeFlashBanks(180); API and bank7 is selected before Fapi_setActiveFlashBank(Fapi_FlashBank7); please let us know the role of reserved register
since is is not given detail in TRM manual and
before Fapi_initializeFlashBanks(180); call After Fapi_initializeFlashBanks(180); call
Fapi_StatusType oReturnCheck = Fapi_Status_Success;
FwpWriteByteAccessorType * oFwpWriteByteAccessor = FWPWRITE_BYTE_ACCESSOR_ADDRESS;
FwpWriteByteAccessorType * oFwpWriteEccByteAccessor = FWPWRITE_ECC_BYTE_ACCESSOR_ADDRESS;
FwpWriteDWordAccessorType * oFwpWriteDWordAccessor = FWPWRITE_DWORD_ACCESSOR_ADDRESS;
uint8 au8MainDataBuffer[16] = {0x78, 0x17, 0x19, 0x2E, 0x0A, 0xB9, 0x11, 0x70,
0x5F, 0xC1, 0x9C, 0xFD, 0x54, 0x51, 0xED, 0x86};
uint32 u32Index;
Fapi_FmcRegistersType register_of_flash;
tcmflash_config_reg_t init_tcm_valu;
tcmflashGetConfigValue(&init_tcm_valu, InitialValue);
/*
For proper initialization of the device prior to any Flash
operations,
see the device-specific initialization document.
A// Fapi_StatusType oReturnCheck = Fapi_Status_Success;ssumes, unless otherwise noted, device has 144bit wide Flash Banks.
*/
oReturnCheck = Fapi_initializeFlashBanks(180); // Example code is assuming operating frequency of 180 MHz */
tcmflashGetConfigValue(&init_tcm_valu, CurrentValue);//CurrentValue
if((oReturnCheck == Fapi_Status_Success) &&
(FLASH_CONTROL_REGISTER->FmStat.FMSTAT_BITS.BUSY != Fapi_Status_FsmBusy))
{
oReturnCheck = Fapi_setActiveFlashBank(Fapi_FlashBank7); // working with this line
// FLASH_CONTROL_REGISTER->Fmac.u32Register = Fapi_FlashBank7; // not working with this line
tcmflashGetConfigValue(&init_tcm_valu, CurrentValue);//CurrentValue
/* Place specific example code here */
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->Fmac.u32Register = Fapi_FlashBank7; //0xFFF87050
FLASH_CONTROL_REGISTER->Fbse.u32Register = 0xFFFF;
FLASH_CONTROL_REGISTER->Fbprot.u32Register = 0U; /* Enable Level 1 Protection */
/*Unlock FSM registers for writing */
// Fapi_issueAsyncCommandWithAddress(Fapi_EraseSector,(uint32_t*)0xF0204000); /*Sending sector erase command for 8th sector in Bank-1*/
// while( FAPI_CHECK_FSM_READY_BUSY == Fapi_Status_FsmBusy );
// while(FAPI_GET_FSM_STATUS != Fapi_Status_Success);
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 = 0xF0204000;
/* Placing byte at address 0x0102 */
oFwpWriteByteAccessor[0] = 0xA5;
/* 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;
FLASH_CONTROL_REGISTER->FsmCommand.FSM_COMMAND_BITS.FSMCMD = Fapi_EraseSector;
FLASH_CONTROL_REGISTER->FsmExecute.FSM_EXECUTE_BITS.FSMEXECUTE = 0x15U;
FLASH_CONTROL_REGISTER->Faddr.u32Register = 0xF0204000;
/* 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 */
}
}