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.

Fapi_setActiveFlashBank returns Fapi_Error_InvalidHclkValue

Other Parts Discussed in Thread: F021FLASHAPI

Hello, I try to use flash api for C28x in a F28M35H52C1 device.

this is my code:

Bool PreparaFlash()
{
	FlashGainPump();

	//vedi "flash_c28.c"
	//139-143
	EALLOW;
	FlashEccRegs.ECC_ENABLE.bit.ENABLE = 0;//***************************** NON HO CAPITO, DEVO VERAMENTE AZZERARE ???
	EDIS;

	//vedi "flash_c28.c"
	//150-151
	Fapi_StatusType oReturnCheck = Fapi_initializeAPI(F021_CPU0_BASE_ADDRESS, 150);
	if(oReturnCheck!=Fapi_Status_Success) return(FALSE);

	//vedi "flash_c28.c"
	//174-175
	oReturnCheck = Fapi_setActiveFlashBank(Fapi_FlashBank0);
if(oReturnCheck != Fapi_Status_Success) return(FALSE); return(TRUE); }

when I call Fapi_setActiveFlashBank I get Fapi_Error_InvalidHclkValue.

I read spnu510e.pdf for Fapi_setActiveFlashBank but it says two return values:  Fapi_Status_Success or Fapi_Error_InvalidBank and I not understand.

 

  • Hi Mauro,

    I think you are not using the latest Flash API documentation (SPNU595).  If you download C2000F021FLASHAPI from http://www.ti.com/tool/f021flashapi, you will get latest documentation.  Latest documentation has all the possible return error codes for this function.    

    And the reason you are getting this error is because you might not have initialized the Flash wait-states properly before calling this function.  Please make sure you execute InitFlash() function before calling the set active bank function in API.

    Thanks and regards,

    Vamsi

  • Hi, I've made some mistake.

    I've not defined _C28X and _CONCERTO symbols

    now is ok, but I have another question

  • I have to write a code that perform digital loop driven by interrupt.

    When user perform calibrations I have to write parameters in Flash,

    so if I understand Flash API implications, I have to:

    1. disable interrupt

    2. GainPump

    3.initialize API

    4. set active flash bank

    5. do my operation (for example erase/write)

    6. leave pump

    7. enable interrupt

    is right ?

  • Mauro,

    Your flow looks fine.  

    Thanks and regards,

    Vamsi

  • ok,

    another question:

    all F021 Flash API must be executed under EALLOW permission ?

    In the C28X Concerto example I see EALLOW instruction, but I have no read anything in

    SPNU501E–December 2012–Revised July 2013

     

  • Mauro,

    SPNU501E is Flash API reference guide for Hercules Safety ARM MCUs.

    SPNU595 is the C2000 Flash API reference guide (http://www.ti.com/lit/ug/spnu595/spnu595.pdf).

    In the introduction section it is mentioned that writes to protected mode registers must be enabled before calling Flash API functions.

    Thanks and regards,

    Vamsi 

  • It is necessary to disable interrupts when I program Flash ?

    If I understand program and erase is made by pure hardware, so interrupt doesn't affect FMC operations

  • Mauro,

    Fetches and reads are not allowed from the Flash bank when the Flash bank is being erased or programmed.

    Hence, as long as the interrupt does not cause accesses to Flash (example interrupt vector table or ISR routine) and does not alter Flash configuration (like wait-states, power state of bank and pump), it is OK to keep the interrupts enabled.

    Remember that Flash API functions have to be executed from RAM.

    Thanks and regards,
    Vamsi