01.04.2014 Views

Preliminary C8051F120/1/2/3 C8051F124/5/6/7 - KEMT FEI TUKE

Preliminary C8051F120/1/2/3 C8051F124/5/6/7 - KEMT FEI TUKE

Preliminary C8051F120/1/2/3 C8051F124/5/6/7 - KEMT FEI TUKE

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>C8051F120</strong>/1/2/3<br />

<strong>C8051F124</strong>/5/6/7<br />

<strong>Preliminary</strong><br />

tates updating data without wasting program memory or RAM space. The 128-byte sectors are double-mapped over<br />

the 128k byte FLASH memory for MOVC reads and MOVX writes only; their addresses range from 0x00 to 0x7F<br />

and from 0x80 to 0xFF (see Figure 15.2). To access the 128-byte sectors, the SFLE bit in PSCTL must be set to logic<br />

1. Code execution from the 128-byte Scratchpad areas is not possible. The 128-byte sectors can be erased individually,<br />

or both at the same time. To erase both sectors simultaneously, the address 0x0400 should be targeted during the<br />

erase operation with SFLE set to ‘1’. See Figure 15.1 for the memory map under different COBANK and SFLE settings.<br />

Figure 15.1. FLASH Memory Map for MOVC Read and MOVX Write Operations<br />

SFLE = 0 SFLE = 1 Internal<br />

COBANK = 0 COBANK = 1 COBANK = 2 COBANK = 3<br />

Address<br />

0xFFFF<br />

Bank 0 Bank 1 Bank 2 Bank 3<br />

Undefined<br />

0x8000<br />

0x7FFF<br />

Bank 0 Bank 0 Bank 0 Bank 0<br />

Scratchpad<br />

Areas (2)<br />

0x00FF<br />

0x0000<br />

15.1.2. Erasing FLASH Pages From Software<br />

When erasing FLASH memory, an entire page is erased (all bytes in the page are set to 0xFF). The 128k byte<br />

FLASH memory is organized in 1024-byte pages. The 256 bytes of Scratchpad area (addresses 0x20000 to 0x200FF)<br />

consists of two 128 byte pages. To erase any FLASH page, the FLWE, PSWE, and PSEE bits must be set to ‘1’, and<br />

a byte must be written using a MOVX instruction to any address within that page. The following is the recommended<br />

procedure for erasing a FLASH page from software:<br />

Step 1. Disable interrupts.<br />

Step 2. If erasing a page in Bank 1, Bank 2, or Bank 3, set the COBANK bits (PSBANK.5-4) for the<br />

appropriate bank.<br />

Step 3. If erasing a page in the Scratchpad area, set the SFLE bit (PSCTL.2).<br />

Step 4. Set FLWE (FLSCL.0) to enable FLASH writes/erases via user software.<br />

Step 5. Set PSEE (PSCTL.1) to enable FLASH erases.<br />

Step 6. Set PSWE (PSCTL.0) to redirect MOVX commands to write to FLASH.<br />

Step 7. Use the MOVX instruction to write a data byte to any location within the page to be erased.<br />

Step 8. Clear PSEE to disable FLASH erases.<br />

Step 9. Clear the PSWE bit to redirect MOVX commands to the XRAM data space.<br />

Step 10. Clear the FLWE bit, to disable FLASH writes/erases.<br />

Step 11. If erasing a page in the Scratchpad area, clear the SFLE bit.<br />

Step 12. Re-enable interrupts.<br />

Page 174<br />

DS008-0.8-AUG02 © 2002 Cygnal Integrated Products, Inc.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!