Philips Semiconductors Product data
P87LPC767
Low power, low price, low pin count (20 pin)
microcontroller with 4-kbyte OTP and 8-bit A/D converter
2002 Mar 25
16
BIT SYMBOL FUNCTION
I2CON.7 RDAT Read: the most recently received data bit.
CXA Write: clears the transmit active flag.
I2CON.6 ATN Read: ATN = 1 if any of the flags DRDY, ARL, STR, or STP = 1.
IDLE Write: in the I
2
C slave mode, writing a 1 to this bit causes the I
2
C hardware to ignore the bus until it
is needed again.
I2CON.5 DRDY Read: Data Ready flag, set when there is a rising edge on SCL.
CDR Write: writing a 1 to this bit clears the DRDY flag.
I2CON.4 ARL Read: Arbitration Loss flag, set when arbitration is lost while in the transmit mode.
CARL Write: writing a 1 to this bit clears the CARL flag.
I2CON.3 STR Read: Start flag, set when a start condition is detected at a master or non-idle slave.
CSTR Write: writing a 1 to this bit clears the STR flag.
I2CON.2 STP Read: Stop flag, set when a stop condition is detected at a master or non-idle slave.
CSTP Write: writing a 1 to this bit clears the STP flag.
I2CON.1 MASTER Read: indicates whether this device is currently as bus master.
XSTR Write: writing a 1 to this bit causes a repeated start condition to be generated.
I2CON.0 Read: undefined.
XSTP Write: writing a 1 to this bit causes a stop condition to be generated.
SU01155
MASTERSTPSTRARLDRDYATNRDAT
01234567
I2CON
Reset Value: 81h
Bit Addressable
1
Address: D8h
XSTPXSTRCSTPCSTRCARLCDRIDLECXA
READ
WRITE
Figure 8. I
2
C Control Register (I2CON)
BIT SYMBOL FUNCTION
I2DAT.7 RDAT Read: the most recently received data bit, captured from SDA at every rising edge of SCL. Reading
I2DAT also clears DRDY and the Transmit Active state.
XDAT Write: sets the data for the next transmitted bit. Writing I2DAT also clears DRDY and sets the
Transmit Active state.
I2DAT.6–0 Unused.
SU01156
RDAT
01234567
I2DAT
Reset Value: xxh
Not Bit Addressable
Address: D9h
XDAT
READ
WRITE
Figure 9. I
2
C Data Register (I2DAT)
Checking ATN and DRDY
When a program detects ATN = 1, it should next check DRDY. If
DRDY = 1, then if it receives the last bit, it should capture the data
from RDAT (in I2DAT or I2CON). Next, if the next bit is to be sent, it
should be written to I2DAT. One way or another, it should clear
DRDY and then return to monitoring ATN. Note that if any of ARL,
STR, or STP is set, clearing DRDY will not release SCL to high, so
that the I
2
C will not go on to the next bit. If a program detects
ATN = 1, and DRDY = 0, it should go on to examine ARL, STR,
and STP.
Philips Semiconductors Product data
P87LPC767
Low power, low price, low pin count (20 pin)
microcontroller with 4-kbyte OTP and 8-bit A/D converter
2002 Mar 25
17
ARL “Arbitration Loss” is 1 when transmit Active was set, but
this device lost arbitration to another transmitter.
Transmit Active is cleared when ARL is 1. There are
four separate cases in which ARL is set.
1. If the program sent a 1 or repeated start, but another
device sent a 0, or a stop, so that SDA is 0 at the rising
edge of SCL. (If the other device sent a stop, the setting
of ARL will be followed shortly by STP being set.)
2. If the program sent a 1, but another device sent a
repeated start, and it drove SDA low before SCL
could be driven low. (This type of ARL is always
accompanied by STR = 1.)
3. In master mode, if the program sent a repeated start,
but another device sent a 1, and it drove SCL low
before this device could drive SDA low.
4. In master mode, if the program sent stop, but it could
not be sent because another device sent a 0.
STR “STaRt” is set to a 1 when an I
2
C start condition is
detected at a non-idle slave or at a master. (STR is not
set when an idle slave becomes active due to a start
bit; the slave has nothing useful to do until the rising
edge of SCL sets DRDY.)
STP “SToP” is set to 1 when an I
2
C stop condition is
detected at a non-idle slave or at a master. (STP is not
set for a stop condition at an idle slave.)
MASTER “MASTER” is 1 if this device is currently a master on
the I
2
C. MASTER is set when MASTRQ is 1 and the
bus is not busy (i.e., if a start bit hasn’t been
received since reset or a “Timer I” time-out, or if a stop
has been received since the last start). MASTER is
cleared when ARL is set, or after the software writes
MASTRQ = 0 and then XSTP = 1.
Writing I2CON
Typically, for each bit in an I
2
C message, a service routine waits for
ATN = 1. Based on DRDY, ARL, STR, and STP, and on the current
bit position in the message, it may then write I2CON with one or
more of the following bits, or it may read or write the I2DAT register.
CXA Writing a 1 to “Clear Xmit Active” clears the Transmit
Active state. (Reading the I2DAT register also does this.)
Regarding Transmit Active
Transmit Active is set by writing the I2DAT register, or by writing
I2CON with XSTR = 1 or XSTP = 1. The I
2
C interface will only drive
the SDA line low when Transmit Active is set, and the ARL bit will
only be set to 1 when Transmit Active is set. Transmit Active is
cleared by reading the I2DAT register, or by writing I2CON with
CXA = 1. Transmit Active is automatically cleared when ARL is 1.
IDLE Writing 1 to “IDLE” causes a slave’s I
2
C hardware to
ignore the I
2
C until the next start condition (but if
MASTRQ is 1, then a stop condition will cause this
device to become a master).
CDR Writing a 1 to “Clear Data Ready” clears DRDY.
(Reading or writing the I2DAT register also does this.)
CARL Writing a 1 to “Clear Arbitration Loss” clears the ARL bit.
CSTR Writing a 1 to “Clear STaRt” clears the STR bit.
CSTP Writing a 1 to “Clear SToP” clears the STP bit. Note that
if one or more of DRDY, ARL, STR, or STP is 1, the low
time of SCL is stretched until the service routine
responds by clearing them.
XSTR Writing 1s to “Xmit repeated STaRt” and CDR tells the
I
2
C hardware to send a repeated start condition. This
should only be at a master. Note that XSTR need not
and should not be used to send an “initial”
(non-repeated) start; it is sent automatically by the I
2
C
hardware. Writing XSTR = 1 includes the effect of
writing I2DAT with XDAT = 1; it sets Transmit Active
and releases SDA to high during the SCL low time.
After SCL goes high, the I
2
C hardware waits for the
suitable minimum time and then drives SDA low to
make the start condition.
XSTP Writing 1s to “Xmit SToP” and CDR tells the I
2
C
hardware to send a stop condition. This should only be
done at a master. If there are no more messages to
initiate, the service routine should clear the MASTRQ
bit in I2CFG to 0 before writing XSTP with 1. Writing
XSTP = 1 includes the effect of writing I2DAT with
XDAT = 0; it sets Transmit Active and drives SDA low
during the SCL low time. After SCL goes high, the I
2
C
hardware waits for the suitable minimum time and then
releases SDA to high to make the stop condition.
Philips Semiconductors Product data
P87LPC767
Low power, low price, low pin count (20 pin)
microcontroller with 4-kbyte OTP and 8-bit A/D converter
2002 Mar 25
18
BIT SYMBOL FUNCTION
I2CFG.7 SLAVEN Slave Enable. Writing a 1 this bit enables the slave functions of the I
2
C subsystem. If SLAVEN and
MASTRQ are 0, the I
2
C hardware is disabled. This bit is cleared to 0 by reset and by an I
2
C
time-out.
I2CFG.6 MASTRQ Master Request. Writing a 1 to this bit requests mastership of the I
2
C bus. If a transmission is in
progress when this bit is changed from 0 to 1, action is delayed until a stop condition is detected. A
start condition is sent and DRDY is set (thus making ATN = 1 and generating an I
2
C interrupt).
When a master wishes to release mastership status of the I
2
C, it writes a 1 to XSTP in I2CON.
MASTRQ is cleared by an I
2
C time-out.
I2CFG.5 CLRTI Writing a 1 to this bit clears the Timer I overflow flag. This bit position always reads as a 0.
I2CFG.4 TIRUN Writing a 1 to this bit lets Timer I run; a zero stops and clears it. Together with SLAVEN, MASTRQ,
and MASTER, this bit determines operational modes as shown in Table 1.
I2CFG.2, 3 Reserved for future use. Should not be set to 1 by user programs.
I2CFG.1, 0 CT1, CT0 These two bits are programmed as a function of the CPU clock rate, to optimize the MIN HI and LO
time of SCL when this device is a master on the I
2
C. The time value determined by these bits
controls both of these parameters, and also the timing for stop and start conditions.
CT0
SU01157
CT1TIRUNCLRTIMASTRQSLAVEN
01234567
I2CFG
Reset Value: 00h
Bit Addressable
Address: C8h
Figure 10. I
2
C Configuration Register (I2CFG)
Regarding Software Response Time
Because the P87LPC767 can run at 20 MHz, and because the I
2
C
interface is optimized for high-speed operation, it is quite likely that
an I
2
C service routine will sometimes respond to DRDY (which is set
at a rising edge of SCL) and write I2DAT before SCL has gone low
again. If XDAT were applied directly to SDA, this situation would
produce an I
2
C protocol violation. The programmer need not worry
about this possibility because XDAT is applied to SDA only when
SCL is low.
Conversely, a program that includes an I
2
C service routine may take
a long time to respond to DRDY. Typically, an I
2
C routine operates
on a flag-polling basis during a message, with interrupts from other
peripheral functions enabled. If an interrupt occurs, it will delay the
response of the I
2
C service routine. The programmer need not worry
about this very much either, because the I
2
C hardware stretches the
SCL low time until the service routine responds. The only constraint
on the response is that it must not exceed the Timer I time-out.
Values to be used in the CT1 and CT0 bits are shown in Table 2. To
allow the I
2
C bus to run at the maximum rate for a particular
oscillator frequency, compare the actual oscillator rate to the f
OSC
max column in the table. The value for CT1 and CT0 is found in the
first line of the table where CPU clock max is greater than or equal
to the actual frequency.
Table 2 also shows the machine cycle count for various settings of
CT1/CT0. This allows calculation of the actual minimum high and
low times for SCL as follows:
SCL min highńlow time (in microseconds) +
6 * Min Time Count
CPU clock (in MHz)
For instance, at an 8 MHz frequency, with CT1/CT0 set to 1 0, the
minimum SCL high and low times will be 5.25 µs.
Table 2 also shows the Timer I timeout period (given in machine
cycles) for each CT1/CT0 combination. The timeout period varies
because of the way in which minimum SCL high and low times are
measured. When the I
2
C interface is operating, Timer I is pre-loaded
at every SCL transition with a value dependent upon CT1/CT0. The
pre-load value is chosen such that a minimum SCL high or low time
has elapsed when Timer I reaches a count of 008 (the actual value
pre-loaded into Timer I is 8 minus the machine cycle count).

P87LPC767FN,112

Mfr. #:
Manufacturer:
NXP Semiconductors
Description:
IC MCU 8BIT 4KB OTP 20DIP
Lifecycle:
New from this manufacturer.
Delivery:
DHL FedEx Ups TNT EMS
Payment:
T/T Paypal Visa MoneyGram Western Union