Datasheet
USCI Operation: I
2
C Mode
www.ti.com
17.3.7.4 Interrupt Vector Assignment
USCI_Ax and USCI_Bx share the same interrupt vectors. In I
2
C mode the state change interrupt flags
UCSTTIFG, UCSTPIFG, UCNACKIFG, UCALIFG from USCI_Bx and UCAxRXIFG from USCI_Ax are
routed to one interrupt vector. The I
2
C transmit and receive interrupt flags UCBxTXIFG and UCBxRXIFG
from USCI_Bx and UCAxTXIFG from USCI_Ax share another interrupt vector.
Example 17-1 shows an extract of the interrupt service routine to handle data receive interrupts from
USCI_A0 in either UART or SPI mode and state change interrupts from USCI_B0 in I
2
C mode.
Example 17-1. Shared Receive Interrupt Vectors Software Example
USCIA0_RX_USCIB0_I2C_STATE_ISR
BIT.B #UCA0RXIFG, &IFG2 ; USCI_A0 Receive Interrupt?
JNZ USCIA0_RX_ISR
USCIB0_I2C_STATE_ISR
; Decode I2C state changes ...
; Decode I2C state changes ...
...
RETI
USCIA0_RX_ISR
; Read UCA0RXBUF ... - clears UCA0RXIFG
...
RETI
Example 17-2 shows an extract of the interrupt service routine that handles data transmit interrupts from
USCI_A0 in either UART or SPI mode and the data transfer interrupts from USCI_B0 in I
2
C mode.
Example 17-2. Shared Transmit Interrupt Vectors Software Example
USCIA0_TX_USCIB0_I2C_DATA_ISR
BIT.B #UCA0TXIFG, &IFG2 ; USCI_A0 Transmit Interrupt?
JNZ USCIA0_TX_ISR
USCIB0_I2C_DATA_ISR
BIT.B #UCB0RXIFG, &IFG2
JNZ USCIB0_I2C_RX
USCIB0_I2C_TX
; Write UCB0TXBUF... - clears UCB0TXIFG
...
RETI
USCIB0_I2C_RX
; Read UCB0RXBUF... - clears UCB0RXIFG
...
RETI
USCIA0_TX_ISR
; Write UCA0TXBUF ... - clears UCA0TXIFG
...
RETI
466
SLAU144J–December 2004–Revised July 2013
Universal Serial Communication Interface, I
2
C Mode
Submit Documentation Feedback
Copyright © 2004–2013, Texas Instruments Incorporated