S6E2CC/C5/C4/C3/C2/C1 Series Flash Programming Specification, Document Number: 002-04913 Rev. *D
29
1.3.4 Writing to MainFlash Memory in Products Equipped with ECC
This section explains the writing to MainFlash memory in products equipped with ECC.
Because ECC (Error Correction Codes) are attached to each word in this series, writes need to be performed in blocks of
words. Write the data one word at a time by writing two half-words consecutively using the following procedure. If this
procedure is not followed, the data is written to the flash memory without calculating the ECC, and the written data will not
be read correctly.
1. Set the flash access size setting to 16 bits. (FASZR:ASZ="0b01"/DFASZR:DASZ=
”0b01”)
Perform a dummy read, after setting the FASZR/DFASZR register.
2. Issue a write command. Write address = PA, Write data = PD[15:0]
See Section "
" for details on the write command.
3. Read the hardware sequence flags once. Because the correct value might not be read out immediately after issuing a
command, this read value should be ignored.
4. Read the hardware sequence flags until the write has finished.
See Section "
1.3.2.3 Automatic Algorithm Run States
" for details on reading the hardware sequence flags.
5. Issue a write command. Write address = PA+2, Write data = PD[31:16]
At this time, the hardware automatically calculates the ECC codes together with PD[15:0] from step 2, and also
automatically writes the ECC codes at the same time.
6. Read the hardware sequence flags once. Because the correct value might not be read out immediately after issuing a
command, this read value should be ignored.
7. Read the hardware sequence flags until the write has finished.
8. If there is more write data, return to step 2. Once finished writing all of the data, proceed to step 9.
9. Switch to CPU ROM mode. Set the flash access size setting to 32 bits.
(FASZR:ASZ="0b10"/DFASZR:DASZ=
”0b10”)
Perform a dummy read, after setting the FASZR/DFASZR register.
10. Read the value that was written, and check that the correct value can be read. Furthermore, even if the correct value
was read, check the flash error bits (FSTR:ERR) to ensure that there have been no ECC corrections. If an ECC
correction has occurred, erase the flash memory and start again from the beginning.
PA
: Write address (word-aligned)
PD[31:0] : Write data
PD[31:16] : Upper 16 bits of the write data
PD[15:0] : Lower 16 bits of the write data
Notes:
−
The flash access size setting in the DualFlash area is set by the dual flash access size bits (DFASZR:DASZ)
−
You cannot rewrite to the address once you wrote to because the ECC (Error Correction Code) has been changed.
To perform rewriting to the same address, erase the address (sector erase or flash erase) in advance.