Connecting serial EEPROMs (Documentation)

App lica tion No te , V 1 .1 , A p r. 2005
AP08006
C868
Interfacing SPI/I2C Serial
EEPROM with C868
Microcontroller
Mic r ocont rollers
N e v e r
s t o p
t h i n k i n g .
Edition 2005-04-01
Published by
Infineon Technologies AG
81726 München, Germany
© Infineon Technologies AG 2006.
All Rights Reserved.
LEGAL DISCLAIMER
THE INFORMATION GIVEN IN THIS APPLICATION NOTE IS GIVEN AS A HINT FOR THE
IMPLEMENTATION OF THE INFINEON TECHNOLOGIES COMPONENT ONLY AND SHALL NOT BE
REGARDED AS ANY DESCRIPTION OR WARRANTY OF A CERTAIN FUNCTIONALITY, CONDITION OR
QUALITY OF THE INFINEON TECHNOLOGIES COMPONENT. THE RECIPIENT OF THIS APPLICATION
NOTE MUST VERIFY ANY FUNCTION DESCRIBED HEREIN IN THE REAL APPLICATION. INFINEON
TECHNOLOGIES HEREBY DISCLAIMS ANY AND ALL WARRANTIES AND LIABILITIES OF ANY KIND
(INCLUDING WITHOUT LIMITATION WARRANTIES OF NON-INFRINGEMENT OF INTELLECTUAL
PROPERTY RIGHTS OF ANY THIRD PARTY) WITH RESPECT TO ANY AND ALL INFORMATION GIVEN
IN THIS APPLICATION NOTE.
Information
For further information on technology, delivery terms and conditions and prices please contact your nearest
Infineon Technologies Office (www.infineon.com).
Warnings
Due to technical requirements components may contain dangerous substances. For information on the types
in question please contact your nearest Infineon Technologies Office.
Infineon Technologies Components may only be used in life-support devices or systems with the express
written approval of Infineon Technologies, if a failure of such components can reasonably be expected to
cause the failure of that life-support device or system, or to affect the safety or effectiveness of that device or
system. Life support devices or systems are intended to be implanted in the human body, or to support
and/or maintain and sustain and/or protect human life. If they fail, it is reasonable to assume that the health
of the user or other persons may be endangered.
C868
Revision History:
2005-04
Previous Version:
2002-04
Page
Subjects (major changes since last revision)
6
Figure 1 is corrected.
V 1.1
V1.0
Controller Area Network (CAN): License of Robert Bosch GmbH
We Listen to Your Comments
Any information within this document that you feel is wrong, unclear or missing at all?
Your feedback will help us to continuously improve the quality of this document.
Please send your proposal (including a reference to this document) to:
[email protected]
AP08006
Interfacing SPI/I2C Serial EEPROM
Introduction
Table of Contents
Page
1
Introduction ................................................................................................... 4
2
Type of EEPROM.......................................................................................... 5
3
Hardware Configuration ................................................................................ 6
4
4.1
4.2
Function Description ..................................................................................... 7
(Re)program EEPROM ................................................................................. 7
Load program from EEPROM to SRAM/XRAM............................................. 8
5
Glossary ........................................................................................................ 9
Application Note
3
V 1.1, 2005-04
AP08006
Interfacing SPI/I2C Serial EEPROM
Introduction
1
Introduction
The C868 microcontroller offers the key feature of interfacing with an external
EEPROM, (re)programing the EEPROM and loading program from EEPROM to onchip SRAM/XRAM.
This application note describes the type of EEPROM supported, the hardware
configuration of the EEPROM with the C868 and the EEPROM functions implemented
by the C868 bootstrap loader. Software (three intel hex files) for this application note
provides SPI EEPROM (re)programming function. I2C EEPROM software routines will
be provided later. Table 1 gives the details of the SPI software.
Table 1
SPI Software for the application note
File Name
RPROTECT.HEX
EPROA5_G.HEX
EPRO00_G.HEX
Application Note
Function
Remove EEPROM write protection.
Program EEPROM with the SRAM content and program
the first byte of EEPROM as 0A5H.
Program EEPROM with the SRAM content and program
the first byte of EEPROM as 00H.
4
V 1.1, 2005-04
AP08006
Interfacing SPI/I2C Serial EEPROM
Type of EEPROM
2
Type of EEPROM
The type of external EEPROM supported is SPI or I2C serial EEPROM. Serial
EEPROM devices offer significant advantages over parallel devices in applications
where lower data transfer rates are acceptable. They also require less board space
and allow microcontroller I/O pins to be conserved. This is valuable to our low pin
count C868 microcontroller. Furthermore, SPI or I2C specification is easy to be
implemented in software. Additionally, please note that only EEPROM in 32-byte page
mode is supported. There is no limitation on the size of the EEPROM. However, as the
SRAM size is 8K, It is suggested to use EEPROM (>=8K bytes) so that all SRAM
content can be loaded to EEPROM.
Application Note
5
V 1.1, 2005-04
AP08006
Interfacing SPI/I2C Serial EEPROM
Hardware Configuration
3
Hardware Configuration
The SPI EEPROM is connected to the C868 microcontroller in three-wire configuration
as shown in Fig.1. In this configuration, the SPI EEPROM serial data in (SI) and serial
data out (SO) are both connected to the same C868 I/O pin, thereby saving a pin. This
is possible because the C868 I/O pins can be dynamically reprogrammed as input or
output.
V DDP
7
1
P 1 .3
CS
H O LD
6
3
SCK
P 1 .1
WP
5
P 1 .2
8
SI
VCC
2
4
SO
GND
240R
V SSP
Figure 1
Three-wire connection to SPI EEPROM
The connection of I2C EEPROM to the C868 is shown in Fig. 2. The address inputs
(A0, A1, A2) can be hardwired either to Vssp (low) or Vccp (high). In this
configuration, they are all hardwired to Vssp to have an address zero. WP (Write
Protect Input Pin) is also tied to Vssp (low) to allow normal write operations. Serial
Clock (SCL) is connected to P1.1 and Serial Data (SDA) is connected to P1.2. SCL
and SDA are both externally pulled up through resistors (3.3K). This is to simulate an
open-drain port behavior which is required by I2C protocol.
VDDP
8
1
A0
VCC
A1
WP
2
7
3
VSSP
3K3
3K3
6
A2
P1.1
SCL
4
5
GND
SDA
P1.2
VSSP
Figure 2
Two-wire connection to I2C EEPROM
Application Note
6
V 1.1, 2005-04
AP08006
Interfacing SPI/I2C Serial EEPROM
Function Description
4
Function Description
Through the C868 bootstrap loader, host PC software and software for this application
note, the user can easily implement (re)programming the EEPROM and loading
program from the EEPROM to SRAM/XRAM.
4.1
(Re)program EEPROM
After boot-up from bootrom, the MCU would try to read the first byte (Password) of
EEPROM. If Password is 0A5H (a dummy code), the MCU would directly load program
from the EEPROM to SRAM/XRAM and then execute from SRAM/XRAM after loading
is completed. Otherwise, it would start serial communication with the host PC. The
host controls the communication by sending special header information, which selects
one of the working modes.
For the first time, the EEPROM is empty, so the MCU would start serial communication
with the host PC. Write Protection of EEPROM must be removed to enable further
EEPROM programming.
Step 1: Select Mode 0: download RPROTECT.HEX to XRAM.
Step 2: Select Mode 1: execute RPROTECT.HEX in XRAM.
Now the EEPROM is writable and can be programmed.
Step 3: Apply a reset and invoke serial communication with the host again.
Step 4: Select Mode 0: download either EPROA5_G.HEX or EPRO00_G.HEX
to XRAM.
Step 5: Select Mode 1: execute code in XRAM.
In this way, EEPROM is programmed with the SRAM content. Pls take note that only
SRAM content 0000H to 1FF7H can be programmed to EEPROM. The last 8 bytes of
SRAM cannot be programmed. If you want to program the first byte of the EEPROM
as the password 0A5H, use the EPROA5_G.HEX; otherwise, use EPRO00_G.HEX.
Application Note
7
V 1.1, 2005-04
AP08006
Interfacing SPI/I2C Serial EEPROM
Function Description
4.2
Load program from EEPROM to SRAM/XRAM
Once EEPROM is programmed with the password 0A5H, after boot-up from bootrom,
the MCU would directly load program from the EEPROM to SRAM/XRAM and then
execute from SRAM/XRAM after loading is completed. Otherwise, loading program
from EEPROM to SRAM/XRAM can be invoked by host command mode 3.
Application Note
8
V 1.1, 2005-04
AP08006
Interfacing SPI/I2C Serial EEPROM
Glossary
5
Glossary
XRAM
Application Note
On-chip ram mapped at address 0FF00H to 0FFFFH
9
V 1.1, 2005-04
http://www.infineon.com
Published by Infineon Technologies AG