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.

Failed to write EEPROM in RM42L432

Other Parts Discussed in Thread: RM42L432

Hello,

I met a problem that it was failed when I write EEPROM via F021 API for RM42L432.

Source code:

void e2prom_program(void)
{
    uint8_t dbuf[8] = {0, 1, 2, 3, 4, 5, 6, 7};
    uint8_t eccbuf[2] = {0, 0};

    Fapi_StatusType oReturnCheck = Fapi_Status_Success;

    /*  Enable Bank 7 (EEPROM)  */
    if(oReturnCheck == Fapi_Status_Success){
        oReturnCheck = Fapi_setActiveFlashBank(Fapi_FlashBank7);
    }
    /*  Enable Sect 0 in Bank 7  */
    if(oReturnCheck == Fapi_Status_Success){
        oReturnCheck = Fapi_enableEepromBankSectors(0x01U, 0x00U);
    }
    /*  Waiting for FSM ready     */
    while(FAPI_CHECK_FSM_READY_BUSY != Fapi_Status_FsmReady){
    }

    /*  Clear status register    */
    oReturnCheck = Fapi_issueAsyncCommand(Fapi_ClearStatus);
    if(oReturnCheck != Fapi_Status_Success)
        return;

    /* Write data    */
    oReturnCheck = Fapi_issueProgrammingCommand((uint32_t *)0xF0200000U, dbuf, 8U, eccbuf, 2, Fapi_AutoEccGeneration);

    /*  Waiting for completed   */
    while(FAPI_CHECK_FSM_READY_BUSY == Fapi_Status_FsmBusy){
    }

    /*  It's OK     */
    if(FAPI_GET_FSM_STATUS == 0){
        /* LED on */
        gioSetBit(gioPORTA, 2, 1);
    }
}

Result:FMSTAT = 0x00001010,   CSTAT = 1 (Command failed)   PGV = 1 (Timeout)

Additional: After function "Fapi_issueProgrammingCommand" returned,its return value is "Fapi_Status_Success"

  • Did you ever call Fapi_initializeFlashBanks() and did you execute the above code with privilege?
  • Did you ever call  Fapi_initializeFlashBanks() and did you execute the above code with privilege?

    Also, was this address range erased before you attempted to program?

  • Dear Anthony, I had already call Fapi_initializeFlashBanks() with privilege.

    See below code:

    void e2prom_init(void)
    {
        Fapi_StatusType oReturnCheck = Fapi_Status_Success;

        /* Set EWAIT */
        FAPI_WRITE_EWAIT(3U);

        /*  Enable Blank 7   */
        if(oReturnCheck == Fapi_Status_Success){
           oReturnCheck = Fapi_setActiveFlashBank(Fapi_FlashBank7);
        }
        /*  Initialize E2PROM  (Blank 7)  */
        if(oReturnCheck == Fapi_Status_Success){
           oReturnCheck = Fapi_initializeFlashBanks(64);
        }
    }

    Is it right?

  • Xiaobin,

    It's reveresed from the flowchart in 5.3 Recommended Program Flow of the SPNU501G F021 Flash API guide;
    initialize banks should come before set active flash bank.

    Don't know if changing this fixes anything but its' best to start by following the documented procedure carefully.