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.

f021 hangs on Fapi_setActiveFlashBank

Other Parts Discussed in Thread: RM46L852

Hi,


 I'm trying to port my code from Tiva series cpu to Hercules RM46, and I'm trying to implement functionality of EEPROMProgram() and EEPROMRead() on RM46L852 using f021, with no luck.

During device initialization, I'm running following code:

Fapi_StatusType oReturnCheck;

    oReturnCheck = Fapi_initializeFlashBanks(128); /* Example code is assuming operating
    frequency of 128 MHz - which is true */

    if((oReturnCheck == Fapi_Status_Success) &&
            (FLASH_CONTROL_REGISTER->FmStat.FMSTAT_BITS.BUSY != Fapi_Status_FsmBusy)){
        oReturnCheck = Fapi_setActiveFlashBank(Fapi_FlashBank7);
        } else {
            while(1);
        }

This executes ok.

later I execute::

    Fapi_doMarginReadByByte(F021_EEPROM_MAP_BEGIN + 64, (uint32_t *)&pb_token, 128+64+4, Fapi_NormalRead);

this attempts to copy block from flash to ram, starting at pb_token address. This should restore variables I saved previously. Cannot verify if this works as I haven't been able to save anything on flash.


Then, FREERTOS processes are created and scheduler is sarted.

In order to write into flash, I call from one process:

EEPROMProgram(&pb_token, 64,128+48);

Once I do that, relevant process will be stuck (rest of FreeRTOS processes continue to run) and debug variable f021_debug is equal to 1. This means, that the process is stuck on Fapi_setActiveFlashBank(Fapi_FlashBank7);

Why is that, how to debug it?

Thanks,

Andrus Kangro

relevant code from freertos process:

----

#include "f021/f021.h"

volatile int32_t f021_debug = 0;

void Fapi_SectorErase( unsigned int Bank, uint32_t * Sector_Start_Address, unsigned int Freq_In_MHz)
{

    //Fapi_initializeAPI((Fapi_FmcRegistersType *)0xfff87000,Freq_In_MHz);
    f021_debug = 1;
    Fapi_setActiveFlashBank(Fapi_FlashBank7);
    f021_debug = 2;
    Fapi_issueAsyncCommandWithAddress(Fapi_EraseSector, Sector_Start_Address);
    f021_debug = 3;
    while( Fapi_checkFsmForReady() == Fapi_Status_FsmBusy );

}



void EEPROMProgram(uint8_t * source, uint32_t dest, uint32_t bytes){
    //erase sector 0
    Fapi_SectorErase( Fapi_FlashBank7, F021_EEPROM_MAP_BEGIN, 128);
    //program sector 0
    Fapi_BlockProgram( Fapi_FlashBank7, (uint32_t *)(F021_EEPROM_MAP_BEGIN+dest), (unsigned int)(source), bytes, 128);

    }

  • Hello Andrus,

    I've forwarded your question to our Flash API expert so he may help you work through the port from the Tiva device to the Hercules RM device. He will reply to you soon. 

  • Hi Andrus,

    Can you provide the following information :

    1. Are you configuring the Wait states (RWAIT and  EWAIT ) before calling  Fapi_initializeAPI ? If so ,what values are configured?

    2. Does the FreeRTOS process run in a privileged mode? Flash APIs must be run in a privileged mode to allow access to the FMC registers.

    Best Regards,

    Siddharth

     

  • Hi,

    Thank you for looking into this.
    1. I did not configure RWAIT and EWAIT previously.

    I did it now and added relevant lines to initialization section:

        FLASH_CONTROL_REGISTER->FsmWrEna.FSM_WR_ENA_BITS.WR_ENA    = 0x5U;
        FLASH_CONTROL_REGISTER->EepromConfig.EEPROM_CONFIG_BITS.EWAIT = 2;
        FLASH_CONTROL_REGISTER->FsmWrEna.FSM_WR_ENA_BITS.WR_ENA    = 0x2U;

        FLASH_CONTROL_REGISTER->FrdCntl.FRDCNTRL_BITS.RWAIT = 2;

        oReturnCheck = Fapi_initializeFlashBanks(128); /* Example code is assuming operating

    This did not have any effect to this particular issue. My process will still get stuck and f021_debug variable stays at value 1.

    2. All my processes run in privileged mode. xTaskCreate(..) is used to create them.

    regards,

    Andrus Kangro

    2.

  • Hello,

    This same exact thing happened to me while trying to get the F021 FLASH API copied over to RAM using the IAR linker.
    Or - you could see something similar if you are running from FLASH (either intentionally or accidentally) and you are addressing FLASH in the same bank.

    Has anyone got this to run in RAM using IAR?

    Regards,
    johnw