cancel
Showing results for 
Search instead for 
Did you mean: 

Flash Programming

charles2399
Associate II
Posted on August 31, 2009 at 19:01

Flash Programming

3 REPLIES 3
charles2399
Associate II
Posted on May 17, 2011 at 13:21

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.

swhite
Associate III
Posted on May 17, 2011 at 13:21

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.

gds2
Associate II
Posted on May 17, 2011 at 13:21

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.