Philips Semiconductors
P87LPC778
CMOS single-chip 8-bit microcontroller
Product data Rev. 01 — 31 March 2004 28 of 79
9397 750 12378
© Koninklijke Philips Electronics N.V. 2004. All rights reserved.
8.7.2 Reading I2CON
RDAT — The data from SDA is captured into ‘Receive DATa’ whenever a rising edge
occurs on SCL. RDAT is also available (with seven low-order zeros) in the I2DAT
register. The difference between reading it here and there is that reading I2DAT
clears DRDY, allowing the I
2
C-bus to proceed on to another bit. Typically, the first
seven bits of a received byte are read from I2DAT, while the 8th is read here. Then
I2DAT can be written to send the Acknowledge bit and clear DRDY.
ATN — ‘ATteNtion’ is ‘1’ when one or more of DRDY, ARL, STR, or STP is ‘1’. Thus,
ATN comprises a single bit that can be tested to release the I
2
C-bus service routine
from a ‘wait loop.
DRDY — ‘Data ReaDY’ (and thus ATN) is set when a rising edge occurs on SCL,
except at idle slave. DRDY is cleared by writing CDR = 1, or by writing or reading the
I2DAT register. The following low period on SCL is stretched until the program
responds by clearing DRDY.
8.7.3 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-bus 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.
Table 24: I2CON - I
2
C-bus control register (address D8H) bit description
Bit Symbol Access Description
7 RDAT R The most recently received data bit
CXA W Clears the transmit active flag
6 ATN R ATN = 1 if any of the flags DRDY, ARL, STP, or STP = 1
IDLE W In the I
2
C-bus slave mode, writing a ‘1’ to this bit causes the I
2
C-bus
hardware to ignore the bus until it is needed again
5 DRDY R Data Ready flag, set when there is a rising edge on SCL
CDR W Writing a ‘1’ to this bit clears the DRDY flag
4 ARL R Arbitration Loss flag, set when arbitration is lost while in the transmit
mode
CARL W Writing a ‘1’ to this bit clears the CARL flag
3 STR R Start flag, set when a start condition is detected at a master or
non-idle slave
CSTR W Writing a ‘1’ to this bit clears the STR flag
2 STP R Stop flag, set when a stop condition is detected at a master or
non-idle slave
CSTP W Writing a ‘1’ to this bit clears the STP flag
1 MASTER R Indicates whether this device is currently as bus master
XSTR W Writing a ‘1’ to this bit causes a repeated start condition to be
generated
0 - R Undefined
XSTP W Writing a ‘1’ to this bit causes a stop condition to be generated
Philips Semiconductors
P87LPC778
CMOS single-chip 8-bit microcontroller
Product data Rev. 01 — 31 March 2004 29 of 79
9397 750 12378
© Koninklijke Philips Electronics N.V. 2004. All rights reserved.
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-bus 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-bus 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-bus.
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.
8.7.4 Writing I2CON
Typically, for each bit in an I
2
C-bus 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.)
8.7.5 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-bus 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-bus hardware to ignore the I
2
C-bus
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.
Philips Semiconductors
P87LPC778
CMOS single-chip 8-bit microcontroller
Product data Rev. 01 — 31 March 2004 30 of 79
9397 750 12378
© Koninklijke Philips Electronics N.V. 2004. All rights reserved.
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 ‘1’s to ‘Xmit repeated STaRt’ and CDR tells the I
2
C-bus 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-bus 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-bus 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-bus 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-bus hardware waits for the suitable minimum time and then releases
SDA to HIGH to make the stop condition.
8.7.6 Regarding software response time
Because the P87LPC778 can run at 20 MHz, and because the I
2
C-bus interface is
optimized for high-speed operation, it is quite likely that an I
2
C-bus 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-bus 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-bus service routine may take a long time
to respond to DRDY. Typically, an I
2
C-bus 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-bus service routine. The
programmer need not worry about this very much either, because the I
2
C-bus
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.
Table 25: I2DAT - I
2
C-bus data register (address D9H) bit allocation
Not bit addressable; Reset value: xxH
Bit 7 6 5 4 3 2 1 0
Symbol (R) RDAT-------
Symbol (W) XDAT-------
Table 26: I2DAT - I
2
C-bus data register (address D9H) bit description
Bit Symbol Access Description
7 RDAT R 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 W Sets the data for the next transmitted bit. Writing I2DAT also
clears DRDY and sets the Transmit Active state.
6 to 0 - - Reserved for future use. Should not be set to ‘1’ by user
programs.

P87LPC778FDH,529

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

Products related to this Datasheet