Skip to main content
Renesas Singapore - Knowledgebase

Can my program execute out of Flash while writing to Flash?

Latest Updated:10/24/2016


Can my program execute from Flash while writing to Flash?


There are limitations when trying to write to Flash memory. Keep in mind the following points: 

1) Code flash operations are blocking, unlike Data Flash operations which can run in the background.

2) When you are using the Flash module and you have Code Flash programming enabled, the Flash API functions and anything they may call are placed into RAM by the linker.

3) You cannot read ROM (Code Flash) while a Code Flash programming/erase function is in progress. If you do your application will crash.

4) Since Code Flash operations are blocking, you may run from ROM, as your application will be blocked until the operation completes- so there are scenarios where you can make this work.

5) However if you execute a Code Flash operation, a write for example, and you get an interrupt that vectors to a ROM address, you will crash.

6) Similarly in a multithreaded environment you could see the same problem.

7) The following approach to writing to Flash could work, (or you could relocate your vector table to RAM).

a) Disable interrupts

b) Execute a code flash operation

c)Enable interrupts


8) But remember, this statement is always true: If you read ROM (Code Flash) while the Flash is in Programming/Erase mode (ie. a Code Flash operation is in progress), your application will crash.

Suitable Products