English
Language : 

UPSD3354DV-40U6 Datasheet, PDF (137/272 Pages) STMicroelectronics – fast 8032 MCU with programmable logic
UPSD33xx
I2C interface
23.13.1
Interrupt Service Routine (ISR)
A typical I2C interrupt service routine would handle a interrupt for any of the four
combinations of Master/Slave and Transmitter/Receiver. In the example routines above, the
firmware sets global variables, I2C_master and I2C_xmitter, before enabling interrupts.
These flags tell the ISR which one of the four cases to process. Following is pseudo-code for
high-level steps in the I2C ISR:
Begin I2C ISR <I2C interrupt just occurred>
Clear I2C interrupt flag:
● S1STA.INTR = 0
Read status of SIOE, put in to variable, status
● status = S1STA
Read global variables that determine the mode
● mode <= (I2C_master, I2C_slave)
If mode is Master-Transmitter
) Bus Arbitration lost? (status.BLOST=1?)
t(s If Yes, Arbitration was lost:
c ● S1DAT = dummy, write to release bus
du ● Exit ISR, SIOE will switch to Slave Recv mode
ro If No, Arbitration was not lost, continue:
P ACK recvd from Slave? (status.ACK_RESP=0?)
te If No, an ACK was not received:
le ● S1CON.STO = 1, set STOP bus condition
so ● <STOP occurs after ISR exit>
b ● S1DAT = dummy, write to release bus
- O ● Exit ISR
) If Yes, ACK was received, then continue:
t(s ● S1DAT = xmit_buf[buffer_index], transmit byte
uc Was that the last byte of data to transmit?
d If No, it was not the last byte, then:
ro ● Exit ISR, transmit next byte on next interrupt
P If Yes, it was the last byte, then:
te● S1CON.STO = 1, set STOP bus condition
le <STOP occurs after ISR exit>
so ● S1DAT = dummy, write to release bus
Ob ● Exit ISR
Doc ID 9685 Rev 7
137/272