Writing in FMI using RAM function
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2009-12-14 7:43 PM
Posted on December 15, 2009 at 04:43
Writing in FMI using RAM function
Labels:
- Labels:
-
Legacy Products
This discussion is locked. Please start a new topic to ask your question.
3 REPLIES 3
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2011-05-17 1:00 AM
Posted on May 17, 2011 at 10:00
I guess 2 things:
1. first write operation after reset initializes the FPEC for ~2 ms. If you don't wait after the memory write unprotect, FPEC will probably ignore the erase command and following. 2. the 0x00 0x80 content may come from two reasons: a) cached content, not valid in FLASH memory, b) a status from FPEC, because of point 1) - ignored command ''Read Array'' at the time it was issued.Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2011-05-17 1:00 AM
Posted on May 17, 2011 at 10:00
Hi,
I want to erase (and write) sector 7 in bank0. My code is running from the same bank so the functions to erase and write are located in RAM. This is the function I call to erase sector 7Code:
void ErasePLC_Program(void) { printf(''nErase PLC Program ''); SCU_FMICLKDivisorConfig(SCU_FMICLK_Div2);/* FMI @48Mhz */ SCU_AHBPeriphClockConfig(__FMI, ENABLE); SCU_AHBPeriphReset(__FMI, DISABLE); PLC_EraseSector(); //CALL FUNCTION IN RAM !! SCU_FMICLKDivisorConfig(SCU_FMICLK_Div2);/* FMI @48Mhz */ printf(''Donen''); } This is the code in RAMCode:
void PLC_EraseSector(void) { vu32 FMI_Sector = FMI_B0S7; vu32 FMI_Bank = FMI_BANK_0; //FMI Writeprotect disable *(vu16*)FMI_Sector = 0x60; *(vu16*)FMI_Sector = 0xD0; *(vu16*)FMI_Sector = 0xFF; //Erase sector command *(vu16 *)FMI_Sector = 0x20; *(vu16 *)FMI_Sector = 0xD0; /* Write a read status register command */ /* and until operation compeletion */ *(vu16 *)(FMI_Bank) = 0x70; while(!((*(vu16 *)FMI_Bank) & 0x80)); //FMI Writeprotect disable *(vu16*)FMI_Sector = 0x60; *(vu16*)FMI_Sector = 0x01; *(vu16*)FMI_Sector = 0xFF; /* Wait until operation compeletion */ while(!((*(vu16 *)FMI_Bank) & 0x80)); } It does not work. When I debug the program with ULINK, the processor returns to the correct adress after calling the RAMfunction, but there is no code to execute (all replaced by 0x00 and 0x80). What is wrong here ? LucOptions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2011-05-17 1:00 AM
Posted on May 17, 2011 at 10:00
Thanks Edison, I will try this.
Luc