2009-08-31 10:01 AM
Flash Programming
2011-05-17 04:21 AM
The document PM0042 states that ''During a write opertion to the Flash memory, any attempt to read the flash memory will stall the bus''. Does this mean that the code performing the write must be executed out of RAM or can the code be executing out of Flash ROM?
If it must be executing our of RAM then the RomCopy linker directive needs to used I assume, if not then the simpler romrun file can be used.2011-05-17 04:21 AM
Quote:
Does this mean that the code performing the write must be executed out of RAM or can the code be executing out of Flash ROM? No, unlike many other processors the STM32 does NOT require that you run out of RAM when erasing/programming the flash. Interrupts etc can be left enabled!!! However the CPU may ''stall'' (i.e. stop executing) for brief periods.2011-05-17 04:21 AM
My observation is that if you erase a flash page and then fetch code from from flash (from a different page of course) to poll the busy bit in the flash register, the cpu shuts down (stalls) for the time it takes to erase the page. So the cpu is stalled (not running) for 20-40ms during an erase (much shorter for a flash write). During the erase time no systick or other interrupts occur and if you use systick irq to attempt to measure the flash erase time, it appears very short.
So if you need to do background work during flash erase (e.g., sending keepalive messages on a usart port every 15ms) then you do need to run from RAM to avoid a long stall. Correct me if I'm wrong on this.