cancel
Showing results for 
Search instead for 
Did you mean: 

systick is stopped? while erasing flash memory

shark
Senior
Posted on November 14, 2014 at 10:39

On stm32f407, Erasing a 128KB flash sector takes about 1 second, but after I finished erasing 1 sector, the systick just happend for 3 times(3 milliseconds), as I config systick as 1000Hz.

Does MCU disable systick internally while flash erasing in progress???As my watchdog relies on systick, so watchdog is triggered if I erase n flash sectors a time. and system time is delayed too.

systick runs normal while programing words in flash.

#systick
5 REPLIES 5
Posted on November 14, 2014 at 10:50

The systick timer is not stopped, but code execution from FLASH is - read RM0090 ch.3.6 ''Erase and program operations''.

Your systick ISR is presumably in FLASH; move it into RAM if you desire it be running during FLASH erase/programming.

JW
chen
Associate II
Posted on November 14, 2014 at 11:49

Hi

As Jan says the Systick IRQ is in Flash.

It may also be wise to have IRQs disabled during Flash upgrade.

Yes, this will stop the SysTick from working.

It may be better during Flash erase/programming to either disable the WDT or make the period larger.

Posted on November 14, 2014 at 13:56

Well it's going to be non-trivial, because ALL the code executing during this ''1-second'' will need to come from RAM, as any fetch/read from FLASH will jam up the processor until the erase completes.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
shark
Senior
Posted on November 15, 2014 at 03:47

Thanks for all of your reply.I know reasons now and know how to patch it.

The misunderstanding arise from:

1. I use older 2011 version of rm0090 without these notes.

2. Your flash driver code is cheatful:

FLASH->CR=xxx

FLASH_WaitForLastOperation()

As I think, your code can check flash status, it should can do my other works too. But these waiting-status code is stalled actually until flash is not busy. 

3. Your mcu hardware is intelligent! Otherwise this kind of software design will die directly if on other hardware platform.

Posted on November 15, 2014 at 08:32

Yeah, but evidently you haven't used many of the common flash devices over the last few decades.

When you read them during program/erase cycles they typically return status information, not bytes from the memory array. If your processor reads and executes those it crashes.

The trick ST uses to insert wait-states for ANY read to the flash array while it is busy. You can read the FLASH CONTROLLER registers without stalling, but you must do it from RAM or ROM.

This is by no means a ''new'' issue, and why some flash solutions use multiple banks where one can be busy while the other is useable. The 2MB F4 part does this.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..