cancel
Showing results for 
Search instead for 
Did you mean: 

Using flash for both program memory and data memory (STM32f205)

evert
Associate
Posted on August 29, 2011 at 16:28

To save external flash I want to use the internal flash for both program and data within the STM32f205. However I learned that during erasing/writing data the CPU is paused. Is this true? is there any solution to reduce this pause time? The erase time can be up to 250ms to erase an 16kb memory block. This is far to much for my application.

Evert Huijben
4 REPLIES 4
Posted on August 29, 2011 at 16:36

To save external flash I want to use the internal flash for both program and data within the STM32f205. However I learned that during erasing/writing data the CPU is paused. Is this true? is there any solution to reduce this pause time? The erase time can be up to 250ms to erase an 16kb memory block. This is far to much for my application.

On the F1 there is a profound stall of the processor if you program/erase/run from Flash, this is the nature of flash arrays, most don't even permit such operation. If the flash array doesn't have two planes you're going to run into the problem. Flash is not a fast memory.

Run your code in RAM.

Put your data in an external flash device, serial/parallel.

Buffer data in RAM, flush to flash when it is convenient.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
evert
Associate
Posted on August 30, 2011 at 08:06

Thank you for the answer

I don't care about the longer eras/write time of the MPU,

However when the MPU is stalled during that time I have an issue.

At any moment in time the MPU has to react on interrupts, no delay is allowed.

Is my conclusion right that the only option is to use external flash?

Posted on August 30, 2011 at 08:27

''Is my conclusion right that the only option is to use external flash?''

There is still the option to run from RAM - only you can say whether that's workable in your particular system...

Posted on August 30, 2011 at 12:55

I don't care about the longer eras/write time of the MPU,

 

However when the MPU is stalled during that time I have an issue.

 

At any moment in time the MPU has to react on interrupts, no delay is allowed.

 

Is my conclusion right that the only option is to use external flash?

 

I enumerated three possible courses of action.

Your choices may be further constrained by information not presented.

You could add external RAM too, but it won't operate single cycle like the internal stuff. Still it would be nano-seconds, not micro/milli seconds.

The stall occurs on reads (instruction, data, literals, etc) against the active flash array/plane, if you don't read from it the processor does not stall. So it's imperative that you don't look at it from anywhere without checking if it is busy. Cache values you need for interrupts in RAM, for example.

The array also has a finite life, you should uses some lazy/deferred write strategy to cache the writes until it is safe for you to delay, like prior to shutdown/sleep or whatever. You can also minimize erase delays, and damage to the array by writing in a journalling fashion, where you write multiple instances of the data structure to the array before erasing it, and always pick the last (most recent) one when reading back the structure.

I believe the STM32F1 part with 1MB of flash (XL) has two flash planes, you should be able to write to one while executing from the second, but I have not personally tried that. Then again, that's probably quite an expensive part, so an external NV memory might still be the cheaper route.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..