This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

MSP430 UART Interrupts: USCIAB0RX_VECTOR,USCIAB0TX_VECTOR

Other Parts Discussed in Thread: MSP430F2132, MSP430WARE

Hello,

i'm wondering when the two ISR are triggered:

USCIAB0TX_VECTOR

USCIAB0RX_VECTOR

Couldn't find any Information about that.

Thank you.

Its about that example of MSP430Ware for MSP430F2132 msp430x21x2_uscib0_i2c_11, this is the I2C Slave Code. The Slave is transmitting 5 Bytes.

#include <msp430.h>

unsigned char *PTxData; 
volatile unsigned char TXByteCtr;
const unsigned char TxData[] = 
{
0x11,
0x22,
0x33,
0x44,
0x55
};

int main(void)
{
  WDTCTL = WDTPW + WDTHOLD; // Stop WDT
  P3SEL |= 0x06; // Assign I2C pins to USCI_B0
  UCB0CTL1 |= UCSWRST; // Enable SW reset
  UCB0CTL0 = UCMODE_3 + UCSYNC; // I2C Slave, synchronous mode
  UCB0I2COA = 0x48; // Own Address is 048h
  UCB0CTL1 &= ~UCSWRST; // Clear SW reset, resume operation
  UCB0I2CIE |= UCSTPIE + UCSTTIE; // Enable STT and STP interrupt
  IE2 |= UCB0TXIE; // Enable TX interrupt

while (1)
{
  PTxData = (unsigned char *)TxData;
  TXByteCtr = 0;
  __bis_SR_register(CPUOFF + GIE); 
  __no_operation(); 

}

#pragma vector = USCIAB0TX_VECTOR
__interrupt void USCIAB0TX_ISR(void)
{
UCB0TXBUF = *PTxData++; // Transmit data at address PTxData
TXByteCtr++; // Increment TX byte counter
}

#pragma vector = USCIAB0RX_VECTOR
__interrupt void USCIAB0RX_ISR(void)
{
UCB0STAT &= ~(UCSTPIFG + UCSTTIFG); 
if (TXByteCtr) 
__bic_SR_register_on_exit(CPUOFF); 

  • I got it. RX is called when the own address is received. Then the TX flag is set and it begins to send byte over byte until master sends an NACK.

  • Drave Dravenburgh said:
    I got it. RX is called when the own address is received.

    Not only.

    I2C is a half-duplex protocol. THat measn, during a transaction there are only either RX or TX interrupts, but never both.

    So someone clever had the idea to put RX and TX into the same interrupt vector that services TX for UARt or SPI, and all status interrupts to the vector that services RX events on SPI or UART mode.

    The RX ISR can also be triggered if a NCK is received after traing to address a slave and not getting an answer, if a stop is received, if arbitration was lost (in multi-master environment) etc.

**Attention** This is a public forum