Other Parts Discussed in Thread: C2000WARE
Dear Champs,
I am asking this for our customer.
In the flash API, there is a new command "Fapi_issueBankEraseCommand()" and it has sample implementation below.
In C:\TI\c2000\C2000Ware_4_00_00_00\driverlib\f28003x\examples\flash\flashapi_ex1_programming.c, there are codes below.
oReturnCheck = Fapi_issueBankEraseCommand((uint32 *)u32CurrentAddress, 0x001F);
// Wait until FSM is done with bank erase operation
while (Fapi_checkFsmForReady() != Fapi_Status_FsmReady)
{
//
// Initialize the Erase Pulses to zero after issuing max pulses
//
if(HWREG(FLASH0CTRL_BASE + FLASH_O_ACC_EP) > MAX_ERASE_PULSE)
{
EALLOW;
//
// Enable Flash Optimization
//
HWREG(FLASH0CTRL_BASE + FLASH_O_OPT) = OPT_ENABLE;
HWREG(FLASH0CTRL_BASE + FLASH_O_ERA_PUL) =
HWREG(FLASH0CTRL_BASE + FLASH_O_ERA_PUL) &
~(uint32_t)FLASH_ERA_PUL_MAX_ERA_PUL_M;
//
// Disable Flash Optimization
//
HWREG(FLASH0CTRL_BASE + FLASH_O_OPT) = OPT_DISABLE;
EDIS;
}
}
Questions:
1) Why is it using "while()" to check the FSM status? The user is concerned if it will become an infinite loop or if it may cause long time here. Can the user change it to "if()"?
That is, after oReturnCheck = Fapi_issueBankEraseCommand((uint32 *)u32CurrentAddress, 0x001F);
the user run other non-flash-API related codes and then back to here to check if (Fapi_checkFsmForReady() != Fapi_Status_FsmReady).
If true, then do the same below codes once. If false, then it goes out to run other non-flash-API related codes and then goes back in a while and repeat this if (Fapi_checkFsmForReady() != Fapi_Status_FsmReady) again.
//
// Initialize the Erase Pulses to zero after issuing max pulses
//
if(HWREG(FLASH0CTRL_BASE + FLASH_O_ACC_EP) > MAX_ERASE_PULSE)
{
EALLOW;
//
// Enable Flash Optimization
//
HWREG(FLASH0CTRL_BASE + FLASH_O_OPT) = OPT_ENABLE;
HWREG(FLASH0CTRL_BASE + FLASH_O_ERA_PUL) =
HWREG(FLASH0CTRL_BASE + FLASH_O_ERA_PUL) &
~(uint32_t)FLASH_ERA_PUL_MAX_ERA_PUL_M;
//
// Disable Flash Optimization
//
HWREG(FLASH0CTRL_BASE + FLASH_O_OPT) = OPT_DISABLE;
EDIS;
Do you think it works too? Or do you have any concern that the code has to wait by "while()" and repeat above again and again?
2) The code is driverlib based. Because the user does not use driverlib but use bit-field codes only, would you please provide the above codes in bit-field codes?
That is, changing HWREG to bit-field based codes?
Wayne Huang