2012-12-19 06:24 AM
I want to use the FLASH to write some data for use after power up.
1. Is there a small section I can use for some bytes (4) without involve with the CODE flash?2. If not how can I take 1 section of the flash and be sure the code won't write to there?3. Where I can fine a sample show me how to select a sector /block it to code write/ write & read from there during the run time?RegardsBar. #flash-on-stm32f2072012-12-19 06:46 AM
For speed and practicality the second 16KB sector might be the most effective.
Depending on your tools you would need to carve out a space in the memory map, via say the target GUI, scatter file, or linker script. It is the linker that places the code. Another approach would be to use the first 16KB sector as a boot loader, and start your application at the third (0x08008000) If you use the internal flash be aware that it will stall CPU execution of code running from flash as you erase/write other areas.2012-12-19 07:27 AM
I suggest to have a look at external serial EEPROMs, especially for commercial applications. They allow byte-wise erase/write, and survive at least 10 times more erase/write cycles, compared to Flash.
2012-12-20 05:10 AM
2012-12-20 06:04 AM
I think that's the hope & pray strategy, where they know the code isn't big enough to intrude into the space they are playing with.
Normally you'd have to describe two ROM regions (IROM1, IROM2 say) with a gap between them. In your example you could also shrink the size of the singular region so the area being erased/written/read is above the limit the compiler/linker is using. Remember these are limits expressed to the software, and the hardware functions as before. In other situations you'd use high memory addresses, but frankly the 128KB sectors are SO SLOW to erase (couple of seconds worst case according to docs) that you have totally lost real-time responsiveness, and peripherals will over/under run. The best time to do erasing is probably at reset, and/or have your writes to flash ''journal'' over the already blank areas, rather than have the saved parameters in a fixed location, ie find the last written values. Be aware that current F2 parts have a die with 1MB of flash on them.