I'm trying to operate SPI in the slave mode, and I can't seem to get reliable output from the MSP430 to the master. The master device (an FPGA) sends indices 0x00-0x26, and then 0xFF to indicate the end of transfer. There is a pause equal to the transfer time of one byte between each index. The SPI clock is very slow, ~40KHz.
I wasn't getting reliable data from the MSP430, so I started removing things from the program, thinking that I had a pointer arithmetic error somewhere that was stomping on TXBUF and/or RXBUF. However, now I've got almost nothing in the program except disable the watchdog, set the clock, initialize my GPIO, initialize the SPI, and transmit a fixed byte, and I can't get reliable operation. The byte I'm transmitting (0xA5) looks like it gets shifted. I'm monitoring on an oscilloscope and at first I do indeed get 0xA5, but eventually I start getting 0x4B, 0x2D, 0x5A, 0xB4, 0x96, 0x69, etc.
When I pause in the debugger, I still see 0xA5 in UCA0TXBUF, despite the oscilloscope showing that's not what's transmitted. UCA0RXBUF is also corrupted.
I'm aware of the USCI40 error, and I'm not using UCCKPH. I've also tried the solution there to no avail. Any ideas? Is there an integrity test to run on the MSP430 to make sure the hardware is working properly?
Spi init:
UCACTL1 |= UCSWRST; UCACTL0 = UCCKPL + UCMSB + UCMODE_2 + UCSYNC; // P3SEL for my I/O goes here UCACTL1 &= ~UCSWRST; IE2 = UCA0RXIE + UCA0TXIE; // I have tried just UCA0RXIE, and no interrupts as well UCA0TXBUF = 0xA5;
Rx ISR
if (IFG2 & UCA0TXIFG) { cSpiTxIfg++; UCA0TXBUF = 0xA5; // Also tried UCA0TXBUF = UCA0TXBUF, UCA0TXBUF = UCA0RXBUF }
:
if (IFG2 & UCA0RXIFG) { cS