LPC900-ParallelProgramming-20030625 (1)
LPC900-ParallelProgramming-20030625 (1)
P89LPC900
Microcontroller
Family
Flash
Programming
Specifications
Philips
Semiconductors PHILIPS
Philips Semiconductors Programming Specification
P89LPC900 Family
PIN CONFIGURATION
ICB/P2.0 1 28 P2.7/ICA
OCD/P2.1 2 27 P2.6/OCA
KBI0/CMP2/P0.0 3 26 P0.1/CIN2B/KBI1
OCC/P1.7 4 25 P0.2/CIN2A/KBI2
OCB/P1.6 5 24 P0.3/CIN1B/KBI3
RST/P1.5 6 23 P0.4/CIN1A/KBI4
VSS 7 22 P0.5/CMPREF/KBI5
XTAL1/P3.1 8 21 VDD
CLKOUT/XTAL2/P3.0 9 20 P0.6/CMP1/KBI6
INT1/P1.4 10 19 P0.7/T1/KBI7
SDA/INT0/P1.3 11 18 P1.0/TXD
SCL/T0/P1.2 12 17 P1.1/RXD
MOSI/P2.2 13 16 P2.5/SPICLK
MISO/P2.3 14 15 P2.4/SS
P89LPC900 Family
PIN DESCRIPTION:
NAME
FUNCTION DURING
PIN NAME DURING I/O
PROGRAMMING
PROG.
P1.7 WRITE/READ I Write input
P1.0 SEL0 I Register select 0
P1.1 SEL1 I Register select 1
P3.1 CLK I External clock input
P1.5 RST P Reset
P0.7 D7 I/O Data 7
P0.6 D6 I/O Data 6
P0.5 D5 I/O Data 5
P0.4 D4 I/O Data 4
P0.3 D3 I/O Data 3
P0.2 D2 I/O Data 2
P0.1 D1 I/O Data 1
P0.0 D0 I/O Data 0
VDD VDD P VDD
VSS VSS P GROUND
P89LPC9xx
SEL1 P1.1
VDD +3V
Data
WRITE/READ P1.7 P2 EEPROM
D7:0
P3.1 Clock Input
pulse sequence RST
Vss
P89LPC900 Family
PRODUCT SELECTION
• ISP code protection - The upper 512 bytes of last sector of the device (sector 7 for 8K x 8 devices, sector 3 for 4K
x 8 devices) contains factory provided ISP code which will be erased by erasing this sector. We recommend
that the user be warned that performing a sector erase on this sector will erase the ISP code. The lower 512
bytes can be erased using the page erase function. A programmer manufacturer might wish to offer an option
to "erase all user code except for the ISP code" and "erase all user code including the ISP code"
• User configuration support - Support user erase/programming and reading of Status bit, Boot Vector, UCFG1
(WDT, osc, etc) independent of the user code array. A configuration screen works best.
• Page erase - Erases a single 64-byte page.
• Sector erase - Erases a single sector of 1KB.
• Sector CRC - Provides CRC on a single sector. Compare device CRC with your memory buffer’s CRC.
• Global CRC - Provides CRC on entire user code memory. Compare device CRC with your memory buffer’s CRC.
P89LPC900 Family
Prior to performing any programmer operations it is necessary to activate the code programming mode of the device.
Once in code programming mode, programming operations for this device are accomplished through the use of four
registers: FMCON, FMADRH, FMADRL, and FMDATA.
FMCON (flash memory control register) is used to specifiy operation modes and to read status. FMADRH (flash
memory address high) and FMADRL (flash memory address low) are used to specifiy the address of the memory
location, page, sector, or other resource to be accessed in the flash microcontroller. FMDATA (flash memory data)
contains data to be written to or read from the flash memory or other resource.
Once in code programming mode, these four registers can be read or written by using the WRITE/, SEL1, and SEL0
signals in addition to the databus (Port 0) and the clock. The register selected by the binary combinations for the
select inputs, SEL1 and SEL0, are shown below:
00 read/write FMADRL
01 read/write FMADRH
10 read/write FMDATA
11 read/write FMCON
P89LPC900 Family
FMCON contains status information (read) and is updated by the last operation performed. FMCON contains the
following bits :
Bit Flag Description
Operation Interrupted.Only used in IAP or ISP modes Should never be set in parallel
0 OI programming mode. (If observed in parallel programming mode it is likely that status is not
being read correctly).
Security Violation. Set if operation fails due to security settings. Cycle is
1 SV
aborted.Memory contents are unchanged. CRC output is invalid.
High Voltage Error. Set if error detected in high voltage generation circuits. Cycle
2 HVE
is aborted. Memory contents may be corrupted.
High Voltage Abort.Set if high voltage cycle is aborted due to a Vdd brownout
3 HVA
condition.Memory contents may be corrupted.
4 - unused; reads as a ’1’
5 - unused; reads as a ’1’
6 - unused; reads as a ’1’
7 BUSY Set while a program, erase, CRC calculation, or other operation is in progress.
Table 0.1
Code memory programming uses a 64-byte page register. From 1 to 64 bytes may be loaded into the page register.
This may be followed by a PROG command causing the new page register contents to be programmed into the flash
memory. The page register may not be read. Only page register locations that have been written will be programmed
into the flash array, thus it is not necessary to write to all 64 locations in the page register.
P89LPC900 Family
VDD
tVR tRH
Note Code memory uses 5 pulses, DataEEPROM uses 7 pulses (see text)
RST
tRL
CLK AS NEEDED
P3.1
tRP
BUSY/NOT BUSY
P0.0
SEL1
SEL0
WRITE
P89LPC900 Family
SEL1, SEL0
tAD
D0-D7
D0-D7 Data Output
tAH
tCD
tDS tDH
tCL
CLOCK tAS tCH
P89LPC900 Family
1.Activate the Code Programming Mode, as previously described, if not already performed.
2.Write the "LOAD" command to FMCON. (Note that this clears the page register of any previously loaded data)
3.Write the lower byte of the first address to be loaded into the page register to FMADRL.
4.Write the data to be loaded to the FMDATA register.
5.Provide three clock pulses to P3.1.
6.The address in FMADRL will auto-increment for the next byte. (Since the page is 64 bytes in length, incrementing past the
end of the page will wrap around to the beginning of the same page).
7.Continue writing additional bytes to the page register as desired. You may change to a different address within the page by
repeating this process starting with step 3.
1.Load the page register with the data to be programmed as previously described.
2.Write the lower 8-bits of the page address to FMADRL.
3.Write the upper 8-bits of the page address to FMADRH. Note: writing the upper two bits of FMADRL and the upper address
byte to FMADRH may be included in step 2 of loading the page register, if desired, since the auto-increment of the page
register does not carry beyond the lower 6 bits of FMADRL.
4.Write the PROG command to the FMCON register.
5.Provide a clock pulse to P3.1
6.Read the FMCON register to obtain status.
7.Continue reading, and providing a clock pulse to P3.1, until the interface is either not BUSY or until an error has occured.
P89LPC900 Family
1.Write the upper 8-bits of the sector address to FMADRH. (Note that only FMADRH[4:2] are used here)
2.Write the ERS_S command to the FMCON register.
3.Read the FMCON register to obtain status. Continue reading until the interface is either not BUSY or until an error has
occured.
Erasing a single page
A single page may be erased using the following sequence:
1.Write the lower 8-bits of the page register address to FMADRL. (only FMADRL[7:6] are used)
2.Write the upper 8-bits of the page register address to FMADRH.(only FMADRH[4:0] are used)
3.Write the ERS_P command to the FMCON register.
4.Read the FMCON register to obtain status. Continue reading until the interface is either not BUSY or until an error has
occured.
CRC Calculation
A 32-bit CRC may be performed on either an individual sector (Sector CRC) or the entire user code memory (Global
CRC). Both use the same method for calculating the 32-bit CRC result which is stored in four 8-bit registers. Initially
these four 8-bit registers are cleared when the CRC command (CRC_G or CRC_S) is written to FMCON. For each
byte of code memory in the intended memory range, the following calculation is performed.
Starting with the first byte in code memory, and for each byte in the memory, perform the following CRC calculation:
1. Shift the CRC result (CRC) to the left one bit and save the MSB in the CRC_FLAG.
2. Read the byte from code memory and distribute the eight bits of the code-byte into the 32 bits of the TAP variable as shown
P89LPC900 Family
in the table, below. Unused bits of the TAP variable must be filled with zeros.
is copied into TAP
Code-byte bit position
variable bit position
0 0
1 3
2 5
3 8
4 10
5 13
6 16
7 18
3. XOR the 32-bit TAP variable with the 32-bit CRC variable and save the result in the CRC variable.
4. If the CRC_FLAG (saved in step 1) was a zero, proceed to step 5, else, XOR the CRC variable with 00400007H. Store the
result in the CRC variable.
5. The CRC calculation for THIS byte is finished. and the CRC variable holds the current CRC result. Repeat, starting with
step 1, for each additional byte of code memory.
If the saved MSB =1, the byte from the code memory is XOR with 00400007H. This result is XOR with the 32-bit CRC result. The
result of this operation is stored as the CRC result.
If the saved MSB =0, the byte from the code memory is XOR with the 32-bit CRC result. The result of this operation is stored as
the CRC result.
P89LPC900 Family
1.Write the "LOAD" command to FMCON. (Note that this clears the page register of any previously loaded data)
2.Write the upper 8-bits of the sector address to FMADRH.
3.Write the CRC_S command to the FMCON register.
4.Read the FMCON register to obtain status. Continue reading until the interface is either not BUSY or until an error has
occured.
5.Select FMDATA, with WRITE\ pin low, then provide a clock pulse to P3.1.
6.Read FMDATA to obtain CRC bits 7:0 (no clock)
7.Provide a clock pulse to P3.1.
8.Read FMDATA again to obtain CRC bits 15:8 (no clock)
9.Provide a clock pulse to P3.1.
10.Read FMDATA again to obtain CRC bits 23:16 (no clock)
11.Provide a clock pulse to P3.1.
12.Read FMDATA again to obtain CRC bits 31:24(no clock)
13.Read FMCON and provide one clock pulse to P3.1
Reading Configuration , Boot Vector, Status Byte, Security Bits, Signature Bytes
Devices parameters such as configuration bytes, status byte, boot vector, security bits , and signature bytes may
be read by writing an address of FMADRL and a command to FMCON. These registers have the following
addresses:
P89LPC900 Family
P3.1 to increment the address to the next location. Thereafter, provide ONE clock pulse to P3.1 to increment to the next
location. The auto-increment function will not bypass the unspecified locations 04H through 07H. Thus it will be necessary
to provide clock pulses to increment through these locations. To terminate the auto-increment function read FMCON and
provide one clock pulse to P3.1
The first 4 registers are self-erasing when being updated. The security bytes can only be erased by erasing the
associated sector using an ERS_S or ERS_G command. These registers may be written using the following
sequence:
1.Write the CONF command to the FMCON register.
2.Write the address of the register to be written to the FMADRL register.
3.Write the desired data to the FMDATA register.
4.Read the FMCON register to obtain status. Continue reading until the interface is either not BUSY or until
an error has occured.
Note: Some registers, such as signature bytes, may not be erased and reprogrammed by the user. Security bits that
are programmed will need to be erased by performing a sector or global erase operation prior to re-programming.
(See sector or global erase commands).
P89LPC900 Family
1 0 0
1 0 1 Security violation flag set for program or erase commands. Cycle aborted. Memory
contents unchanged. Global erase is allowed.
1 1 0
1 1 1
P89LPC900 Family
1.This sequence assumes that Data EEPROM programming mode is currently active. If not, activate the Data EEPROM
programming mode as described, above.
2.Steps 3 through 8 store the A8 address bit of the 512 byte EEPROM array. This bit does not need to be programmed for
each byte that is written into the EEPROM array.
3.Drive P0 with 75H.
4.Provide a clock pulse to P3.1 by driving P3.1 to a logic high for 1 uS min, and then driving P3.1 low.
5.Drive P0 with F1H.
6.Provide a clock pulse to P3.1 by driving P3.1 to a logic high for 1 uS min, and then driving P3.1 low.
7.IIf the Data EEPROM address bit, A8, is a one, drive P0 with 01H. If the Data EEPROM address bit, A8, is a zero, drive P0
with 00H.
8.Provide two clock pulses to P3.1.
9.Drive P0 with 75H.
10.Provide a clock pulse to P3.1 by driving P3.1 to a logic high for 1 uS min, and then driving P3.1 low.
11.Drive P0 with F2H.
12.Provide a clock pulse to P3.1 by driving P3.1 to a logic high for 1 uS min, and then driving P3.1 low.
13.Drive P0 with data to be programmed
14.Provide two clock pulses to P3.1.
15.Drive P0 with 75H.
16.Provide a clock pulse to P3.1 by driving P3.1 to a logic high for 1 uS min, and then driving P3.1 low.
P89LPC900 Family
1.This sequence assumes that Data EEPROM programming mode is currently active. If not, activate the Data EEPROM
programming mode as described, above.
2.Drive P0 with 75H.
3.Provide a clock pulse to P3.1 by driving P3.1 to a logic high for 1 uS min, and then driving P3.1 low.
4.Drive P0 with A5H.
5.Provide a clock pulse to P3.1 by driving P3.1 to a logic high for 1 uS min, and then driving P3.1 low.
6.Drive P0 with FFH.
7.Provide two clock pulses to P3.1.
8.Drive P0 with 75H.
9.Provide a clock pulse to P3.1 by driving P3.1 to a logic high for 1 uS min, and then driving P3.1 low.
10.Drive P0 with A4H.
11.Provide a clock pulse to P3.1 by driving P3.1 to a logic high for 1 uS min, and then driving P3.1 low.
12.Drive P0 with 00H.
13.Provide two clock pulses to P3.1.
14.Steps 15 through 20 store the A8 address bit of the 512 byte EEPROM array. This bit does not need to be programmed for
each byte that is written into the EEPROM array.
15.Drive P0 with 75H.
16.Provide a clock pulse to P3.1 by driving P3.1 to a logic high for 1 uS min, and then driving P3.1 low.
17.Drive P0 with F1H.
18.Provide a clock pulse to P3.1 by driving P3.1 to a logic high for 1 uS min, and then driving P3.1 low.
19.IIf the Data EEPROM address bit, A8, is a one, drive P0 with 01H. If the Data EEPROM address bit, A8, is a zero, drive P0
with 00H.
20.Provide two clock pulses to P3.1.
21.Drive P0 with 75H.
22.Provide a clock pulse to P3.1 by driving P3.1 to a logic high for 1 uS min, and then driving P3.1 low.
23.Drive P0 with F3H.
24.Provide a clock pulse to P3.1 by driving P3.1 to a logic high for 1 uS min, and then driving P3.1 low.
25.Drive P0 with address bits A7:A0
26.Provide two clock pulses to P3.1.
27.Drive P0 with 00H.
28.Provide 10 clock pulses to P3.1.
29.Drive P0 with E5H.
P89LPC900 Family
30.Provide a clock pulse to P3.1 by driving P3.1 to a logic high for 1 uS min, and then driving P3.1 low.
31.Drive P0 with F2H.
32.Provide a clock pulse to P3.1 by driving P3.1 to a logic high for 1 uS min, and then driving P3.1 low.
33.Drive P0 with F5H.
34.Provide a clock pulse to P3.1 by driving P3.1 to a logic high for 1 uS min, and then driving P3.1 low.
35.Drive P0 with A0H.
36.Provide a clock pulse to P3.1 by driving P3.1 to a logic high for 1 uS min, and then driving P3.1 low.
37.Sample P2 to obtain the Data EEPROM contents.
38.Repeat steps 15 through 37 to read additional bytes from the Data EEPROM. If the address bit A8 does not need to change
from its previously stored value, steps 15 through 20 may be omitted.
Unless noted elsewhere, datasheet specification of this device are applicable during programming operations.
Revisions
Expanded the product selection table. Changed the ISP sector erase warning to cover 4KB and 8KB devices.
Added comment for read/write of DataEEPROM such that it applies only to the P89LPC932.
Changed the order of events in performing a CRC_S (sector CRC), specifically changed the sequence from
wite CRC_S to FMCON , write FMADRH to: write LOAD to FMCON, write FMADRH, write CRC_S to FMCON.
May 5, 2003