Hi.
I'm using RM48L952ZWT.
I'm tring to write the sector 7. but, I failed.
It works good in RM48HDK board. but, My Rm48L952 board is not.
I post my source code. Could you check it?
I'm using CCS5.2.
#include "F021_FMC_LE.h"
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. */
oReturnCheck = Fapi_writeEwaitValue(0x00040000);
oReturnCheck = Fapi_initializeAPI(F021_CPU0_BASE_ADDRESS,80); /* Example code is assuming operating frequency of 160 MHz */
//oReturnCheck = Fapi_doMarginRead((uint32 *)u32StartAddress, (uint32 *)ReplyBuffer, 16, Fapi_NormalRead);
oReturnCheck = Fapi_doMarginReadByByte((uint8 *)u32StartAddress, (uint8 *)ReplyBuffer, 16, Fapi_NormalRead);
if (ReplyBuffer[0] == 0xFF) { 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 */ } } }
Thank you.
Komeco/R&D dept
Seongjin Jeong
Hi Seongjin,
There is an issue using Fapi_writeEwaitValue() before Fapi_initializeAPI() is called as Fapi_GlobalInit.m_poFlashControlRegisters pointer to the Flash memory controller has not been set. Also, Fapi_initializeAPI() will store the current ewait value and if EWAIT is setup after this function, Fapi_setActiveFlashBank() will fail for Fapi_Error_InvalidHclkValue. Additionally, the parameter passed to Fapi_writeEwaitValue() should only be the value you want to set EWAIT to, so you would pass 0x4 instead of the value your code shows.
I would replace Fapi_writeEwaitValue() to the following:
REGISTER(0xfff87288) = 0x00000005; /* enable writes to EWAIT register */ REGISTER(0xfff872B8) = 0x00040002; /* EWAIT=4 */ REGISTER(0xfff87288) = 0x00000002; /* disable writes to EWAIT register */
John Hall
Safety MCU Software Team
If my reply answers your question please click on the green button "Verify Answer"
Seongji,
Could you tell us the status on this thread? If your question has been answered, could you please mark it has "Verified Answer" so we can close this thread.
Best regards,
Jean-Marc
Application Engineer
If my reply answers your question please click on the green button "Verify Answer".