Other Parts Discussed in Thread: MSP430FR5969
I'm using the MSP430FR5969 device as a SPI master and have an issue with the UCTXIFG using the following code:
#pragma vector=USCI_B0_VECTOR
__interrupt void HW_SpiServiceInterrupt(void)
{
uint8_t c;
// FOR DEBUG USE ONLY
P1OUT |= BIT3;
switch(__even_in_range(UCB0IV, USCI_SPI_UCTXIFG))
{
// No RX/TX interrupt pending
case USCI_NONE:
// Only here for optimization purposes
break;
// Receive interrupt pending
case USCI_SPI_UCRXIFG:
// Buffer the received SPI byte
fbInsert(&spi_rx_buf, UCB0RXBUF);
break;
// Transmit interrupt pending
case USCI_SPI_UCTXIFG:
// Write next available out-bound byte to SPI transmit register
if ( fbRemove(&spi_tx_buf, &c) )
{
// FOR DEBUG USE ONLY
P1OUT |= (BIT5);
UCB0TXBUF = c;
// FOR DEBUG USE ONLY
P1OUT &= ~(BIT5);
}
// Clear the SPI transmit register if nothing to send and
// disable the transmit interrupt to prevent wasted cycles
else
{
// FOR DEBUG USE ONLY
P1OUT |= (BIT4);
UCB0TXBUF = 0; // ONLY WORKS IF THIS LINE INCLUDED
UCB0IE &= ~UCTXIE;
// FOR DEBUG USE ONLY
P1OUT &= ~(BIT4);
}
break;
default:
break;
}
// FOR DEBUG USE ONLY
P1OUT &= ~BIT3;
}
The code works sending the desired data contained in the spi_tx_buf (a circular buffer) and a null byte (0x00) after the buffer has emptied. The following diagram shows the DEBUG CODE stimulus for one byte (a 0x00 in this case) being sent plus the null byte. This cycle repeats when another byte is inserted into the spi_tx_buf and the UCTXIE is turned on again.
The problem occurs when the line UCB0TXBUF = 0; is removed from the ISR. Only the initial byte in the spi_tx_buf is transmitted, but nothing ever again. I've verified the UCTXIE is re-enabled (see signal P1.2 in figure).
Below is the updated capture when the line UCB0TXBUF = 0; is removed:
Notice the extra pulses on the P1.2 probe which indicate the UCTXIE was re-enabled, yet the ISR is never invoked.

