This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Tool/software: Code Composer Studio
Hi,
Compiler:Code Composer Studio 9.0.1.
When debugging FLASH erase, enter illegal interrupt problem.
The erase FLASH program is performed as follows:
void vErase()
{
//.....omit
NOP;
NOP;
Boot_FlashErase();
//....omit
}
#pragma CODE_SECTION(Boot_FlashErase, ".TI.ramfunc");
void Boot_FlashErase(void)
{
uint32 u32Index = 0;
uint16 i = 0;
Fapi_StatusType oReturnCheck;
Fapi_FlashStatusType oFlashStatus;
Fapi_FlashStatusWordType oFlashStatusWord;
//EALLOW;
oReturnCheck = Fapi_initializeAPI(F021_CPU0_BASE_ADDRESS, 100);
if(oReturnCheck != Fapi_Status_Success)
{
// Check Flash API documentation for possible errors
Example_Error(oReturnCheck);
}
oReturnCheck = Fapi_setActiveFlashBank(Fapi_FlashBank0);
// Check Flash API documentation for possible errors
if(oReturnCheck == Fapi_Status_Success)
{
for(i = 0; i < EraseSectorNum; i++)
{
// Erase Flash Bank0 sector6
oReturnCheck = Fapi_issueAsyncCommandWithAddress(Fapi_EraseSector,
(uint32 *)(Bzero_Sector5_start + 0x1000 * i));
// Wait until FSM is done with erase sector operation
while (Fapi_checkFsmForReady() != Fapi_Status_FsmReady){}
/* if(oReturnCheck != Fapi_Status_Success)
{
// Check Flash API documentation for possible errors
Example_Error(oReturnCheck);
}*/
}
}
// Read FMSTAT register contents to know the status of FSM after
// erase command to see if there are any erase operation related errors
oFlashStatus = Fapi_getFsmStatus();
if(oFlashStatus != 0)
{
FMSTAT_Fail();
}
// Do blank check
// Verify that Bank0 sector6 is erased. The Erase command itself does a verify as
// it goes. Hence erase verify by CPU reads (Fapi_doBlankCheck()) is optional.
/* oReturnCheck = Fapi_doBlankCheck((uint32 *)Bzero_Sector15_start,
Sector8KB_u32length,
&oFlashStatusWord);
if(oReturnCheck != Fapi_Status_Success)
{
// Check Flash API documentation for error info
Example_Error(oReturnCheck);
}*/
}
void vErase()
{
//.....omit
NOP;
NOP;
NOP;
Boot_FlashErase();
//....omit
}
#pragma CODE_SECTION(Boot_FlashErase, ".TI.ramfunc"); void Boot_FlashErase(void) { uint32 u32Index = 0; uint16 i = 0; Fapi_StatusType oReturnCheck; Fapi_FlashStatusType oFlashStatus; Fapi_FlashStatusWordType oFlashStatusWord; //EALLOW;
Try moving the #pragma to just before the function prototype (instead of the function itself)
See the example in the compiler user's guide (http://www.ti.com/lit/spru514)
Regards
Lori
Hi,Lori
I refer to the example in the compiler guide, and this problem still exists.
Regards
user6394966 said:Why does initializing the API function to perform erasing FLASH enter an illegal interrupt?
This function must be executed from RAM. If your application is loading into flash, then the functions marked with .TI.ramfunc should be copied to RAM and then executed. It sounds like the copy from flash to RAM is not being done. Because of this, the RAM area where this function should be is filled with random values and causes an ITRAP. Please check your project to see if you are doing this copy.
Refer to this page: https://processors.wiki.ti.com/index.php/C2000_Flash_FAQ
Specifically 36. How to copy the Flash API from Flash to RAM to execute it from RAM?
user6394966 said:Why is it ok to add one more NOP statement to the program?
NOP is a "no operation" and can be added freely.
user6394966 said:Adding empty statements only increases storage space. Why does it affect API function execution?
Please explain what is meant by an empty statement?