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.

Unable to successfully write to FEE on RM48x

Other Parts Discussed in Thread: HALCOGEN

Hello,

I am looking into the use of bank 7 on the RM48 HDK flash for storage of runtime fault histories in my application. I have create a simple project in CCS v5 with a barebones HALcogen generated set of drivers. The drivers have a heartbeat output on PWM0 Het1 pin 15 only. All others are disabled.

I have taken example code that comes with v2.0 of the F021 FEE API as copied below but have not been able to successfuly show that memory at address oxF0200000 is being written to.

Can anyone help get my initialisation of the RM48 correct such that I can start saving the info to bank 7?

Thanks

Jamie

/* Include Files */

#include "sys_common.h"
#include "system.h"

/* USER CODE BEGIN (1) */
#include "f021.h"
#include "het.h"
/* USER CODE END */

/** @fn void main(void)
*   @brief Application main function
*   @note This function is empty by default.
*
*   This function is called after startup.
*   The user can use this function to implement the application.
*/

/* USER CODE BEGIN (2) */
/* USER CODE END */

void main(void)
{
/* USER CODE BEGIN (3) */

    /*FEE ROUTINE */

    Fapi_StatusType oReturnCheck = Fapi_Status_Success;
        uint32 u32StartAddress = 0xF0200000U;
        uint8 au8MainDataBuffer[16] = {0x78, 0x17, 0x19, 0x2E, 0x0A, 0xB9, 0x11, 0x70, 0x5F, 0xC1, 0x9C, 0xFD, 0x54, 0x51, 0xED, 0x86};
        //uint32 u32Index;

         /*
                                Add device specific initialization here, including, but not limited to:
                                pll initialization, setting up RWAIT/EWAIT value, etc.

                                Assumes, unless otherwise noted, device has 144bit wide Flash Banks.
        */
        REGISTER(0xfff87288) = 0x00000005; /* enable writes to EWAIT register */
        REGISTER(0xfff872B8) = 0x00040002; /* EWAIT=4 */
        REGISTER(0xfff87288) = 0x00000002; /* disable writes to EWAIT register */

        oReturnCheck = Fapi_initializeAPI(F021_CPU0_BASE_ADDRESS,180);  /* Example code is assuming operating frequency of 180 MHz */

        if((oReturnCheck == Fapi_Status_Success) && (Fapi_checkFsmForReady() != Fapi_Status_FsmBusy))
        {
           oReturnCheck = Fapi_setActiveFlashBank(Fapi_FlashBank7);

         if(oReturnCheck == Fapi_Status_Success)
         {
                oReturnCheck = Fapi_issueProgrammingCommand((uint32 *)u32StartAddress,au8MainDataBuffer,16,0,0,Fapi_AutoEccGeneration);
         }

           /* Wait for FSM to finish */
           while(Fapi_checkFsmForReady() == Fapi_Status_FsmBusy);

              /* Check the FSM Status to see if there were no errors */
           if (Fapi_getFsmStatus() != 0)
           {
               /* Put Error handling code here */
           }
        }
    hetInit();
    while(1);
/* USER CODE END */
}

  • Hi Jamie,

    Thanks for your post. We will get back to you at the earliest possible.

    Regards,

    Praveen

  • Hi Jamie,

    You may have to enable the sector for program/erase using the Fapi_enableEepromBankSectors(in this case) function before you initiate an operation.

    Please try it and let us know

    Regards,

    Praveen 

  • Hello Praveen,

    Thanks for the reply.

    With the addition of enabling the EEPROM bank sectors I have successfully written to the EEPROM on the HDK at runtime. function I call is shown below.

    However, I am not having repeated success with the program command. It is typically failing after I write to the EEPROM once. The status register FMSTAT is showing bits 4 and 5 as being set (FMSTAT=48) which the API guide lists as the CSTAT and INVDAT. From Table8 in the guide (SPNU501D) is seems that the problem is the INVDAT bit specifically:

    "Invalid Data. When set, the bit indicates that the user attempted to program a "1" where a "0" was already present. This bit is cleared by the clear status command."

    Do you know why changing a value in my au8MainDataBuffer after the first successful write would result in an INVDAT failure? It is not clear to me why writing  a 1 over a 0 would be considered invalid?

    static void use_Fapi(void)
    {
        /*FEE ROUTINE */

        Fapi_StatusType oReturnCheck = Fapi_Status_Success;
        uint32 u32StartAddress = 0xF0200010U;
        uint8 au8MainDataBuffer[16] = {0x21, 0x21, 0x21, 0x21, 0x0A, 0xB9, 0x11, 0x70, 0x5F, 0xC1, 0x9C, 0xFD, 0x54, 0x51, 0xED, 0x86};


        REGISTER(0xfff87288) = 0x00000005; /* enable writes to EWAIT register */
        REGISTER(0xfff872B8) = 0x00040002; /* EWAIT=4 */
        REGISTER(0xfff87288) = 0x00000002; /* disable writes to EWAIT register */

        oReturnCheck = Fapi_initializeAPI(F021_CPU0_BASE_ADDRESS,200);  /* Example code is assuming operating frequency of 180 MHz */

        if((oReturnCheck == Fapi_Status_Success) && (Fapi_checkFsmForReady() != Fapi_Status_FsmBusy))
        {
            oReturnCheck = Fapi_setActiveFlashBank(Fapi_FlashBank7);

            oReturnCheck = Fapi_enableEepromBankSectors(0x000F,0x0);
            if(oReturnCheck == Fapi_Status_Success)
            {
                oReturnCheck = Fapi_issueProgrammingCommand((uint32 *)u32StartAddress,au8MainDataBuffer,16,0,0,Fapi_AutoEccGeneration);
            }
            else
            {
                gioSetBit(hetPORT1,31,1);
            }

            /* Wait for FSM to finish */
            while(Fapi_checkFsmForReady() == Fapi_Status_FsmBusy);
            uint32 fsmstatus = Fapi_getFsmStatus();
            /* Check the FSM Status to see if there were no errors */
            if (Fapi_getFsmStatus() != 0)
            {
                gioSetBit(hetPORT1,31,1);
            }
        }
        else
        {
            gioSetBit(hetPORT1,31,1);
        }
    }/* end useFapi */


  • I am going to repost this as specific to the INVDAT error status. My actual routine for wriiting to 'clean' EEPROM is working. See previous post for the cut and paste of my working routine.

  • You have to erase sector before programing the same segment of eeprom.

    You can program data at addres1 and then at adress2 but you can't do this at adress1 twice without erasing sector (if addres1 and addres2 are in same sector).