Hello,
I am using MSP430FR5969 and I have problem while setting up SPI on eUSCI A1 to communicate with H3LIS331DL accelerometer. It works flawlessly on eUSCI B0 but it will be used for RF module. As soon as I connect accelerometer to SPI, program gets stuck on while (UCA1STATW & UCBUSY);. This happens only when I try to read two bytes without releasing chip select pin. Logic analyser shows that everything is ok, values sent and received are ok, but microcontroller stuck thinking that the operation is in progress. When I disconnect accelerometer this problem disappear but only after MCU reset. I tried to change almost everything in SPI config registers, tried all combinations of reading and writing SPI buffer and no effect. It always gets stuck on UCBUSY.
Simplified code follows:
// Configure GPIO
P4DIR |= BIT3; // CS pin
P4OUT |= BIT3;
P2SEL1 |= BIT5 | BIT6 |BIT4; // USCI_A1 operation
// Configure USCI_A1 for SPI operation
UCA1CTLW0 = UCSWRST; // **Put state machine in reset**
UCA1CTLW0 |= UCMST | UCSYNC | UCCKPL | UCMSB; // 4-pin, 8-bit SPI master
// Clock polarity high, MSB
UCA1CTLW0 |= UCSSEL__SMCLK; // ACLK
UCA1BR0 = 0x02; // /2
UCA1BR1 = 0; //
UCA1MCTLW = 0; // No modulation
UCA1CTLW0 &= ~UCSWRST; // **Initialize USCI state machine**
P4OUT&= ~BIT3;
while (!(UCA1IFG & UCTXIFG));
UCA1TXBUF = (READ_REG + WHO_AM_I);
while(!(UCA1IFG & UCRXIFG));
value = UCA1RXBUF;
while (!(UCA1IFG & UCTXIFG));
UCA1TXBUF = 0x00;
while(!(UCA1IFG & UCRXIFG));
value = UCA1RXBUF;
while (UCA1STATW & UCBUSY); <- stuck here
P4OUT|= BIT3;