Hi,
I have a SPI master that is sending data to a slave MSP430FR2311 over SPI. I have been able to get data in a single byte without issue but I can not get multiple bytes. I have verified with a seperate device that the master is sending the correct data. Currently I use the CS pin to interrupt, turn on the RX interrupt and then take data in in the RX interrupt. There is example code for taking in multiple bytes but all of that example code goes to sleep between bytes, I have to stay up while receiving data. I have tried a couple ways in the RX interrupt to receive data but I always get either garbage data or repeating data.
For reference here are a couple code examples of what I have tried:
Example 1:
#pragma vector=USCI_A0_VECTOR
__interrupt void USCI_A0_ISR(void)
{
RXBuf[cmd_index] = UCA0RXBUF;
cmd_index++;
if(cmd_index >= RXBuf[0]) // check for all byte RX
{
cmd_index = 0;
P1IE |= BIT3; // Enable CS Line
UCA0IE = 0; // Disable USCI_A0 RX interrupt
//__bis_SR_register_on_exit(LPM3_bits | GIE);
}
} //End USCI_A0_VECTOR
Example 2:
#pragma vector=USCI_A0_VECTOR
__interrupt void USCI_A0_ISR(void)
{
RX_count =0;
switch(RX_count)
{
case 0: // RX Byte 1: Packet Length
lengthSPI = UCA0RXBUF;
RX_count += 1;
break;
case 1: // RX Byte 2: CheckSum
CheckSum = UCA0RXBUF;
RX_count += 1;
break;
case 2: // RX Byte 3: RTCMOD Low Byte
Command = UCA0RXBUF;
RX_count +=1;
break;
case 3:
IncrementsHigh = UCA0RXBUF;
RX_count +=1;
break;
case 4:
IncrementsLow = UCA0RXBUF;
RX_count +=1;
break;
case 5:
RTCMODHigh = UCA0RXBUF;
RX_count +=1;
break;
case 6:
RTCMODLow = UCA0RXBUF;
RX_count +=1;
break;
}
if(RX_count >= lengthSPI) // check for all byte RX
{
RX_count = 0;
P1IE |= BIT3; // Enable CS Line
UCA0IE = 0; // Disable USCI_A0 RX interrupt
//__bis_SR_register_on_exit(LPM3_bits | GIE);
}
} //End USCI_A0_VECTOR
Thanks for your help!