English
Language : 

C8051F960-B-GM Datasheet, PDF (246/492 Pages) Silicon Laboratories – Ultra Low Power 128K, LCD MCU Family
C8051F96x
18.1.4. Flash Write Optimization
The flash write procedure includes a block write option to optimize the time to perform consecutive byte
writes. When block write is enabled by setting the CHBLKW bit (FLRBCN.0), writes to flash will occur in
blocks of 4 bytes and require the same amount of time as a single byte write. This is performed by caching
the bytes whose address end in 00b, 01b, and 10b that is written to flash and then committing all four bytes
to flash when the byte with address 11b is written. When block writes are enabled, if the write to the byte
with address 11b does not occur, the other three data bytes written is not committed to flash.
A write to flash memory can clear bits to logic 0 but cannot set them; only an erase operation can set bits
to logic 1 in flash. The Flash Block to be programmed should be erased before a new value is writ-
ten.
The recommended procedure for writing a 4-byte flash block is as follows:
1. Save current interrupt state and disable interrupts.
2. Set the CHBLKW bit (register FLRBCN).
3. Set the PSWE bit (register PSCTL).
4. Clear the PSEE bit (register PSCTL).
5. If writing to an address in Banks 1, 2, or 3, set the COBANK[1:0] bits (register PSBANK) for the
appropriate bank
6. Write the first key code to FLKEY: 0xA5.
7. Write the second key code to FLKEY: 0xF1.
8. Using the MOVX instruction, write the first data byte to the desired location within the 1024-byte
sector whose address ends in 00b.
9. Write the first key code to FLKEY: 0xA5.
10. Write the second key code to FLKEY: 0xF1.
11. Using the MOVX instruction, write the second data byte to the next higher flash address ending in
01b.
12. Write the first key code to FLKEY: 0xA5.
13. Write the second key code to FLKEY: 0xF1.
14. Using the MOVX instruction, write the third data byte to the next higher flash address ending in 10b.
15. Write the first key code to FLKEY: 0xA5.
16. Write the second key code to FLKEY: 0xF1.
17. Using the MOVX instruction, write the final data byte to the next higher flash address ending in 11b.
18. Clear the PSWE bit.
19. Clear the CHBLKW bit.
20. Restore previous interrupt state.
Steps 5–17 must be repeated for each flash block to be written.
Notes:
1. Flash security settings may prevent writes to some areas of flash, such as the reserved area. For a summary of
flash security settings and restrictions affecting flash write operations, please see Section “18.3. Security
Options” on page 247.
2. 8-bit MOVX instructions cannot be used to erase or write to flash memory at addresses higher than 0x00FF.
246
Rev. 1.0