cancel
Showing results for 
Search instead for 
Did you mean: 

Compensation for Flash Stalling on STM32F103

eliast1234
Associate II
Posted on April 21, 2015 at 19:11

Hello Guys,

Working with multiple tasks in my project and one of the tasks measuring zero-crossings of power line mains with 5000 smaples/s and delivering detected zero-crossing to another task to be counted. I'have still other task doing other jobs. Some of the tasks are also writing also log data into flash which is also managed with some kind of wear-leveling algo.

The problem is that i'm losing some of the input signal's zero crossings (do not know how many exactly) while one or multiple flash pages are erased (flash stalling).

How should I workaround it? (hint: I have also RTC module that could be used to mease some elapsed time.) What do you think?

Any help is appreciated.

#flash-erasure-stall
5 REPLIES 5
Posted on April 21, 2015 at 19:16

Run all you code from RAM, or stop writing/erasing FLASH. Or consider an XL part with TWO flash banks.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
eliast1234
Associate II
Posted on April 21, 2015 at 19:23

Hello Mr. clive,

Unfortunately, I cannot consider none of the options. The parts are delivered from school lab as it is. It has 128 KB flash and 20KB RAM; 100Kb of flash and almost 18KB of RAM are already in use ;(. I must do any workaround in FW.

I think of measuring stall duration with RTC and then trying to figure out how many crossing I lost and adjusting the count. However, I do not know exactly how I can do that or if it is a good idea.

Posted on April 21, 2015 at 19:27

And that precludes you from running code out of RAM?

Aren't your teachers supposed to provide adequate training and support to permit you to complete the tasks assigned?

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
eliast1234
Associate II
Posted on April 21, 2015 at 19:45

Hello Mr. clive1,

I feel a little embarrased that I do not know how to run code from RAM.

The teachers had trained us in basics. I think she herself does not know ho to solve the current problem and claims the further HW requests are out of budget.

Shall I change the schools?

Posted on April 21, 2015 at 22:17

Shall I change the schools?

Yeah, I think that's a bit of a

http://en.wikipedia.org/wiki/Kobayashi_Maru

, and as much as I'd like to change the parameters of the test, it might be a good learning moment, in that you could probably find some books which would provide a better breath and depth of knowledge.

If you force the hardware to count the zero crossings, the stall from the flash can be masked.

The concept of running from RAM is to copy code into and area of RAM, and jump to it. Though from a whole application perspective this can be a bit complicated. The most simple approach would be to split the application into two pieces, a boot loader residing in FLASH, and app code stored in FLASH, but copied down into RAM by the aforementioned boot loader. You would need enough RAM for both the code, and the static data structures it uses, an allocate them so they don't touch each other.

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