Tool/software: Code Composer Studio
We are trying to interface to a SPI chip on USCI A1. The Busy flag on the USCA1STATW never negates. We have SPI devices on BO and B1 that work fine.
//////////////////////////////////////////////////////////////////////////////////
// Send_SPI sends a character out the SPI and simultaneously receives one
//
//////////////////////////////////////////////////////////////////////////////////
unsigned char Send_SPI(unsigned char chan, unsigned char data)
{
unsigned char rslt;
switch(chan)
{
#ifdef HAS_USCI_A0
case USCI_A0: // If data sent out uscia0
UCA0TXBUF = data; // place data to send in transmit buffer
while(UCA0STATW & 0x01); // wait for busy flag to clear
rslt = UCA0RXBUF; // read the received data back
break;
#endif
#ifdef HAS_USCI_A1
case USCI_A1: // If data sent out uscia0
UCA1TXBUF = data; // place data to send in transmit buffer
while(UCA1STATW & 0x01); // TODO wait for busy flag to clear
rslt = UCA1RXBUF; // read the received data back
break;
#endif
#ifdef HAS_USCI_B0
case USCI_B0: // If data sent out uscia0
UCB0TXBUF = data; // place data to send in transmit buffer
while(UCB0STATW & 0x01); // wait for busy flag to clear
rslt = UCB0RXBUF; // read the received data back
break;
#endif
#ifdef HAS_USCI_B1
case USCI_B1: // If data sent out uscia0
UCB1TXBUF = data; // place data to send in transmit buffer
while(UCB1STAT & 0x01); // wait for busy flag to clear
rslt = UCB1RXBUF; // read the received data back
break;
#endif
}
return(rslt);