TI E2E Community
Stellaris® ARM® Microcontrollers
Stellaris® ARM® LM3S Microcontrollers Forum
Problem programming the flash (Register FMC) (LM3S9B92)
I have a problem programming the flash memory of my LM3S9B92. I want to store programm parameters in the flash to prevent some data loose.
I have found a little c-funktion in the stellarisware examples to store data using the flash registers FMA,FMD and FMC.
#define FLASH_FMC_WRKEY 0xA4420000
#define FLASH_FMC_WRITE 0x00000001
void internalFlashProgramm(unsigned long ulDstAddr, unsigned char *pucSrcData, unsigned long ulLenght)
unsigned long ulLoop;
for (ulLoop =0; ulLoop < ulLength; ulLoop+=4)
HWREG(FLASH_FMA)=ulDstAddr + uLoop;
HWREG(Flash_FMD) = *(unsigned long*)(pucSrcData + ulLoop);
HWREG(Flash_FMC) = Flash_FMC_WRKEY | Flash_FMC_WRITE;
while(HWREG(FLASH_FMC) & FLASH_FMC_WRITE)
I dont have problems with compiling the code.
My problem is that the FMA and FMD register are written with the correct values but the FMC register has the value 0x00000000 . But without this register I cannot write data to the flash.
I hope somebody can help me with this problem!
I did some testing and it looks like the FMC_WRKEY part of the register never shows up when you read FMC. If you set a breakpoint after the write and look at FMC in memory, you will see 0, because the breakpoint does not stop the write from completing. If you read FMC into a variable directly after the write, you should see it as 0x00000001. Have you checked the flash location that you're trying to write to see if a write has completed?
Won't the code stall until the write is complete if it's executing from flash?
I have checked the flash location (0xF800 to 0xF814) and the values there are 0x00000000. I do not know what default values they have but this is not the data i want to store in there.
You must erase a flash block before you can write to it.
All content and materials on this site are provided "as is". TI and its respective suppliers and providers of content make no representations about the suitability of these materials for any purpose and disclaim all warranties and conditions with regard to these materials, including but not limited to all implied warranties and conditions of merchantability, fitness for a particular purpose, title and non-infringement of any third party intellectual property right. TI and its respective suppliers and providers of content make no representations about the suitability of these materials for any purpose and disclaim all warranties and conditions with respect to these materials. No license, either express or implied, by estoppel or otherwise, is granted by TI. Use of the information on this site may require a license from a third party, or a license from TI.
TI is a global semiconductor design and manufacturing company. Innovate with 100,000+ analog ICs andembedded processors, along with software, tools and the industry’s largest sales/support staff.