CB_I2C
15
Notes
In ord er to r ese t the S1CO N.SI flag, the input lin e ENC LR-
BIT must be set to 1 dur ing the write cycle of S1CON.
“data_in” means a data byte is written into an internal regis-
ter. BE and RDE have been grouped to make the diagram
more readable; they could be grouped or generated sepa-
rately in your application.
Once the interrupt flag of the control register (S1CON.SI) is
cleared, the interrupt request line (IRI2C) goes back low
and the CB_I2C interface starts transmitting the slave
address. After the transmission of the last bit (8th) of the
slave ad dress, the CB_I2 C rele ases the S DA lin e to let th e
slave acknowledge its address during the next (9th) SCL
clock puls e. Afte r the ninth SCL c lock pulse the s tatu s reg-
ister (S1STA ) is updated with the a pprop riate v alue (18 H if
the acknowledge has been received, 20H if not), and the
interrupt reques t line goes hig h to highlight the en d of the
first byte transfe r (the interrupt flag, S1CON.S I is also set).
The controller/sequencer driving the CB_I2C interface
should then perform the following tasks:
• read the status regist er (S1STA ) .
If an acknowledge has been received:
• write the next data byte into the data register (S1DAT)
• clear the interrupt flag (S1CON.STA)
It can also:
• set the STOP bit of the control register, to generate a
STOP condition, or
• set the START bit of the control register, to generate a
repeated START condition, or
• set the START and STOP bits of the control register, to
generate a STOP condition, then a START condition.
• If no acknowledge has been received:
• clear the interr upt flag (S1CON.S TA), write the STO P bit
of the control register to generate a STOP condition (or
write the START bit to generate a repeated START
condition).
If the arbitration has been lost, the CB_I2C interface
releases the SDA and SCL lines (to free the I2C bus for the
winnin g mas ter) , gen erat e an inte rrupt reque st ( IRI2C lin e)
and load the value 38H into the status register (S1STA). If
the ass er t a ck no wle dge bit o f th e control r egister i s “1 ” , th e
CB_I2C interface can recognize its own address and gen-
erate an acknowledge in the same I2C bus cycle.
It means , in case of two m asters (called MA and MB) gen-
erating at the same time, the START condition and the
slave address; if MA is calling MB and MB loses the arbitra-
tion, MB will gene rate a START condition, se nd the slave
address, (lose the arbitration), switch into the slave mode,
recogniz e its own slave addre ss and generate an ackno wl-
edge (if S1CON.AA = 1) in the same I2C bus cycle (during
the 9 SCL clock cycles).
For each data byte to send the sequence will be as follows:
• write the data byte into the CB_I2C data register
(S1DAT),
• clear the interrupt request flag (S1CON.SI),
CB_I2C sends data byte...
CB_I2C re lease s the SDA line and generate s the nin th
SCL pulse...
the receiver generates the acknowledge...
CB_I2C generates an interrupt request (IRI2C)...
• read the status register,
• write the next data byte into the data register,
• clear the interrupt flag, etc...
The last data byte transfer will be:
• write the data byte into the CB_I2C data register
(S1DAT),
• clear the interrupt request flag (S1CON.SI),
CB_I2C sends data byte...
CB_I2C re lease s the SDA line and generate s the nin th
SCL pulse...
the receiver generates the acknowledge...
CB_I2C generates an interrupt request (IRI2C)...
• read the status register,
• clear the interrupt request bit (S1CON.SI), set the stop
bit (S1CON.STO),
CB_I2C generates the STOP condition...
Once the STOP condition is detected on the I2C bus,
the stop bit is cleared...
Master Recei ver Mode
Before s tarting the M aster/Receiv er mode, S1 CON.ENS 1
must be “1”. To start a transfer in Master/Receiver mode,
set S1CON.STA to “1” (during the same write cycle of
S1CON, ENS1 must stay “1”, CR2-CR1-CR0 can be used
to select the output baud rate, and AA could be changed). If
AA is set to “1”, in case of a loss of arbitration during the
slave address transfer (and direction bit) onto the I2C bus,
the CB_I2 C will b e a bl e t o r ec og nize its own s lave add re ss
(or a general call) and generate an acknowledge during the
same I2C bus cy cle.
Once S1CON.STA is set to “1”, the CB_I2C will test the I2C
bus and generate a START condition as soon as the bus is
free. When the START cond ition is rec ognized on the I2C
bus, the interrupt request line (IRI2C) goes high and the
status regist er (S1S TA) loads the appro priat e value ( 08H).
The SI flag (in the control register, S1CON) is also set to
stop the CB_I2C. At this time (in response to the interrupt
request), the controller/sequencer which drives the CB_I2C
interface should perform the following actions: