2014-11-14 01:39 AM
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. #systick2014-11-14 01:50 AM
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. JW2014-11-14 02:49 AM
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.2014-11-14 04:56 AM
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.
2014-11-14 06:47 PM
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=xxxFLASH_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.2014-11-14 11:32 PM
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.