I am using MSP430F2274 to communicate via SPI-B with another microcontroller. MSP430 is the master and I have a problem with polling the receive buffer flag - it seems it is not set when the data is available but immediately after the UCB0TXBUF is filled in with data. Anyway, I have the problem that the other controller gets all data correctly and the return slave MISO messages are read sometimes with 50%, and sometimes 10% accuracy.
The setup code is:
P3SEL |= 0x0E; // P3.3,2, 3.1 USCI_B0 option select
// P3DIR |= 0x01; // P3.0 output direction
UCB0CTL0 = UCMSB + UCMST+ UCSYNC ;
UCB0CTL1 |= UCSSEL_2;
UCB0BR0 = 0x04*4;
UCB0BR1 = 0;
IE2 |= UCB0RXIE;
UCB0CTL1 &= ~UCSWRST;
The polling part is:
while (!(IFG2 & UCB0RXIFG)) ;
SPI_Slave->bmsg= UCB0RXBUF;
Is there anything I am missing or do wrong in the setup or flags use ?