Renesas rl78 User Manual

Page of 1004
 
RL78/G1A 
CHAPTER  25   FLASH  MEMORY 
25.8.3  Procedure for accessing data flash memory 
The data flash memory is stopped after a reset ends.  To access the data flash, make initial settings according to the 
following procedure. 
 
<1>  Set bit 0 (DFLEN) of the data flash control register (DFLCTL) to 1. 
<2>  Wait for the setup to finish for software timer, etc. 
 
The time setup takes differs for each flash operation mode for the main clock. 
 
<Setup time for each flash operation mode> 
• HS (High speed main):   5 
μ
• LS (Low speed main):   720 ns 
• LV (Low voltage main):   10 
μ
<3>  After the wait, the data flash memory can be accessed. 
 
Cautions  1.  Accessing the data flash memory is not possible during the setup time. 
<R> 
 
2.  Transition to the STOP mode is not possible during the setup time.  To enter the STOP mode 
during the setup time, clear DFLEN to 0 and then execute the STOP instruction. 
 
3.  The high-speed on-chip oscillator should be kept operating during data flash rewrite.  If it is 
kept stopping, operate the high-speed on-chip oscillator clock (HIOSTOP = 0) and execute the 
data flash library after 30 
μ
s have elapsed. 
<R> 
 
After initialized, the data flash memory can be read by using a CPU instruction or can be read/written by using a data 
flash library. 
<R> 
If the DMA controller operates when the data flash memory is accessed, however, follow one of these procedures: 
 
(A) Suspending/forcibly terminating DMA transfer 
Before reading the data flash memory, suspend DMA transfer of all the channels used.   
After setting the DWAITn bit to 1, however, wait at least for the duration of three clocks (f
CLK
) before reading the 
data flash memory.  After reading the data flash memory, lift the suspension of transfer by clearing the DWAITn bit 
to 0. 
Or, forcibly terminate DMA transfer in accordance with the procedure in 15.5.5  Forced termination by software 
before reading the data flash memory.  Resume DMA transfer after the data flash memory has been read. 
(B)  Access the data flash memory by using the newest data flash library. 
(C)  Insertion of NOP 
Insert an NOP instruction immediately before the instruction that reads the data flash memory. 
<Example> 
MOVW  
HL,!addr16  
; Reads RAM. 
NOP  
 
; Insert NOP instruction before reading data flash memory. 
MOV  
A,[DE]  
; Read data flash memory. 
 
If a high-level language such as C is used, however, the compiler may generate two instructions for one code.  In 
this case, the NOP instruction is not inserted immediately before the data flash memory read instruction.  
Therefore, read the data flash memory by (A) or (B) above. 
 
Remarks 1.  n: DMA channel number (n = 0, 1) 
 
2.  f
CLK
: CPU/peripheral hardware clock frequency 
 
R01UH0305EJ0200  Rev.2.00 
 
 
823  
Jul 04, 2013