In CPU rewrite mode, the flash memory cannot be read from the CPU. Accordingly, the rewrite control program must be transferred to the RAM area before executing it in that area.
During rewrite control programming, instructions referring to data in the flash memory cannot be used, so the following points should be noted:
For JSR and JMP instructions, the jump addresses are specified to addresses in the flash memory area when source files are assembled.
When jump addresses are designated with labels, specify them to absolute addresses using the following methods.
These methods allow the MCU to pass control on the instructions of the addresses in the RAM area in order to transfer the rewrite control program to the area.
For example, using the labels already defined in the source program, define labels corresponding to the absolute addresses in RAM when the rewrite control program is transferred to the RAM area. Use such labels when the subroutine is called out.
Example) Subroutine call for erase handling (executing JSR instructions)
RAM_SUB_ERASE (absolute address at start of subroutine in RAM area)
= RAM_PROG_TOP (absolute address at start of rewrite program in RAM area)
+ SUB_ERASE (absolute address at start of subroutine in flash memory area)
- PROG_TOP (absolute address at start of rewrite program in flash memory area)
(Statement example in the source program)
RAM_SUB_ERASE = RAM_PROG_TOP + SUB_ERASE - PROG_TOP
NOTE: Each label of RAM_PROG_TOP, SUB_ERASE, and PROG_TOP must be predefined in the source program before stating the above expression (RAM_SUB_ERASE).
Here is another example using JMP instructions.
(The branch addresses of JMP instructions are designated as absolute.)
When statements include a structural descriptive language;
Use of long branches result in the inclusion of JMP instructions when the statements are expanded to assembly language.
To avoid this, use the following formats;
Or use other statement forms such as conditional branches in order to pass control of the instructions of the addresses in the RAM area.