C8051F120/1/2/3/4/5/6/7
186
Rev. 1.2
a single byte of a multi-byte data set, the data must be moved to temporary storage. The 128-byte sector-size facili-
tates updating data without wasting program memory or RAM space. The 128-byte sectors are double-mapped over
the 128k byte FLASH memory for MOVC reads and MOVX writes only; their addresses range from 0x00 to 0x7F
and from 0x80 to 0xFF (see Figure 16.2). To access the 128-byte sectors, the SFLE bit in PSCTL must be set to logic
1. Code execution from the 128-byte Scratchpad areas is not possible. The 128-byte sectors can be erased individu-
ally, or both at the same time. To erase both sectors simultaneously, the address 0x0400 should be targeted during the
erase operation with SFLE set to ‘1’. See Figure 16.1 for the memory map under different COBANK and SFLE set-
tings.
16.1.2. Erasing FLASH Pages From Software
When erasing FLASH memory, an entire page is erased (all bytes in the page are set to 0xFF). The 128k byte
FLASH memory is organized in 1024-byte pages. The 256 bytes of Scratchpad area (addresses 0x20000 to 0x200FF)
consists of two 128 byte pages. To erase any FLASH page, the FLWE, PSWE, and PSEE bits must be set to ‘1’, and
a byte must be written using a MOVX instruction to any address within that page. The following is the recommended
procedure for erasing a FLASH page from software:
Step 1. Disable interrupts.
Step 2. If erasing a page in Bank 1, Bank 2, or Bank 3, set the COBANK bits (PSBANK.5-4) for the
appropriate bank.
Step 3. If erasing a page in the Scratchpad area, set the SFLE bit (PSCTL.2).
Step 4. Set FLWE (FLSCL.0) to enable FLASH writes/erases via user software.
Step 5. Set PSEE (PSCTL.1) to enable FLASH erases.
Step 6. Set PSWE (PSCTL.0) to redirect MOVX commands to write to FLASH.
Step 7. Use the MOVX instruction to write a data byte to any location within the page to be erased.
Step 8. Clear PSEE to disable FLASH erases.
Step 9. Clear the PSWE bit to redirect MOVX commands to the XRAM data space.
Step 10. Clear the FLWE bit, to disable FLASH writes/erases.
Step 11. If erasing a page in the Scratchpad area, clear the SFLE bit.
Step 12. Re-enable interrupts.
Bank 0
Bank 1
Bank 2
Bank 3
Bank 0
Bank 0
Bank 0
Bank 0
COBANK = 0 COBANK = 1 COBANK = 2 COBANK = 3
SFLE = 0
SFLE = 1
Internal
Address
0x0000
0x7FFF
0x8000
0xFFFF
Undefined
Scratchpad
Areas (2)
0x00FF
Figure 16.1. FLASH Memory Map for MOVC Read and MOVX Write Operations
Summary of Contents for C8051F120
Page 2: ...C8051F120 1 2 3 4 5 6 7 2 Rev 1 2 Notes ...
Page 8: ...C8051F120 1 2 3 4 5 6 7 8 Rev 1 2 26 2 Flash Programming Commands 318 26 3 Debug Support 321 ...
Page 16: ...C8051F120 1 2 3 4 5 6 7 16 Rev 1 2 Notes ...
Page 48: ...C8051F120 1 2 3 4 5 6 7 48 Rev 1 2 ...
Page 98: ...C8051F120 1 2 3 4 5 6 7 98 Rev 1 2 ...
Page 106: ...C8051F120 1 2 3 4 5 6 7 106 Rev 1 2 Notes ...
Page 183: ...C8051F120 1 2 3 4 5 6 7 Rev 1 2 183 Notes ...
Page 184: ...C8051F120 1 2 3 4 5 6 7 184 Rev 1 2 ...
Page 214: ...C8051F120 1 2 3 4 5 6 7 214 Rev 1 2 Notes ...