Using The MSSP Module To Interface I C Serial Eeproms With Pic16 Devices
Using The MSSP Module To Interface I C Serial Eeproms With Pic16 Devices
Using the MSSP Module to Interface I2C™ Serial EEPROMs with PIC16 Devices
The 24XXX series serial EEPROMs from Microchip Figure 1 describes the hardware schematic for the
Technology are I2C™ compatible and have maximum interface between Microchip’s 24XXX series devices
clock frequencies ranging from 100 kHz to 1 MHz. The and the PIC16F877A PICmicro microcontroller. The
MSSP module available on many PICmicro® microcon- schematic shows the connections necessary between
trollers provides a very easy-to-use interface for the microcontroller and the serial EEPROM as tested,
communicating with the 24XXX series devices. The and the software was written assuming these connec-
largest benefit of using the MSSP module is that the tions. The SDA and SCL pins are open-drain terminals,
signal timings are handled through hardware rather and therefore require pull-up resistors to VCC (typically
than software. This allows the firmware to continue 10 kΩ for 100 kHz, and 2 kΩ for 400 kHz and 1 MHz).
executing while communication is handled in the back- Also, the WP pin is tied to ground because the write-
ground. This also means that an understanding of the protect feature is not used in the examples provided.
timing specifications associated with the I2C protocol is
not required in order to use the 24XXX series devices
in designs.
RE0 8 33 RB0
RE1 9 32 VDD
RE2 10 31 VSS
VDD 11 30 RD7
VSS 12 29 RD6
OSC1 13 28 RD5
OSC2 14 27 RD4
RC0 15 26 RC7
RC1 16 25 RC6
RC2 17 24 RC5
RC3/SCL 18 23 RC4/SDA
RD0 19 22 RD3
RD1 20 21 RD2
Vcc
A0 1 8 Vcc
24XXXXX
A1 2 7 WP 4.7K 4.7K
A2 3 6 SCL
Vss 4 5 SDA
*SDA and SCL require pull-up resistors (10 kΩ for 100 kHz, 2 kΩ for 400 kHz and 1 MHz).
Note that pins A0, A1 and A2 are not internally connected in some devices.
F OSC ⎞
⎛ ------------------- Note that all of the examples shown in this section
-
⎝ BitRate⎠ make use of the BANKSEL directive, but SSPSTAT,
SSPADD = ------------------------- – 1 SSPADD and SSPCON2 all exist on Bank 1. There-
4 fore, it is more efficient to configure all of these regis-
ters together, so that only one BANKSEL directive is
required.
EXAMPLE 2: SSPADD CONFIGURATION
S
BUS ACTIVITY T
MASTER Control
A
R Byte
T
SDA LINE S1 0 1 0A AA
2 10 0
A
BUS ACTIVITY C
K
BUS ACTIVITY
MASTER Address Address
High Byte Low Byte
SDA LINE x
A A
BUS ACTIVITY C C
K K
x = “don’t care” bit
BUS ACTIVITY S
MASTER T
Data O
P
SDA LINE P
A
C
BUS ACTIVITY K
BUS ACTIVITY S
T Control
MASTER A
R Byte
T
SDA LINE S1 0 1 0A AA
2 10 0
N
BUS ACTIVITY O
A
C
K
S
BUS ACTIVITY T
MASTER Control
A
R Byte
T
SDA LINE S1 0 1 0A AA
2 10 0
A
BUS ACTIVITY C
K
BUS ACTIVITY S
T
MASTER A Control Address
R Byte High Byte
T
SDA LINE S1 0 1 0 AAA0 x
2 1 0
A A
C C
BUS ACTIVITY K K
BUS ACTIVITY S
T S
MASTER A Control Data T
R Byte Byte O
T P
SDA LINE S 1 0 1 0 A A A1 P
2 1 0
A N
C O
BUS ACTIVITY K A
C
K
BUS ACTIVITY
MASTER Data (n) Data (n + 1)
SDA LINE
A A A
BUS ACTIVITY C C C
K K K
BUS ACTIVITY S
T
MASTER Data n + (x-1) Data n + x O
P
SDA LINE P
A N
BUS ACTIVITY C O
K A
C
K
• Microchip believes that its family of products is one of the most secure families of its kind on the market today, when used in the
intended manner and under normal conditions.
• There are dishonest and possibly illegal methods used to breach the code protection feature. All of these methods, to our
knowledge, require using the Microchip products in a manner outside the operating specifications contained in Microchip’s Data
Sheets. Most likely, the person doing so is engaged in theft of intellectual property.
• Microchip is willing to work with the customer who is concerned about the integrity of their code.
• Neither Microchip nor any other semiconductor manufacturer can guarantee the security of their code. Code protection does not
mean that we are guaranteeing the product as “unbreakable.”
Code protection is constantly evolving. We at Microchip are committed to continuously improving the code protection features of our
products. Attempts to break Microchip’s code protection feature may be a violation of the Digital Millennium Copyright Act. If such acts
allow unauthorized access to your software or other copyrighted work, you may have a right to sue for relief under that Act.
10/20/04