Part Number: TMS320F28075
Other Parts Discussed in Thread: C2000WARE
I have the TMS320F28075 configured as a slave, on a SPI bus with two other devices. If only the TMS320 is selected and transferring data, everything works great. However, when other devices on the SPI bus are selected, the data on the TMS320 is sometimes corrupt. The key word here is sometimes, because the data isn't always corrupt.
Here is a logic capture of what happens:
There are 3 messages sent here. First, TMS320 is selected and that transfer is successful. Then, another device on the bus is selected, that transfer is good too. Then the 3rd transfer, the TMS320 is selected again. The TMS320 receives incorrect data here.

And here is that 3rd message zoomed in:

And here is what the data looks like when I debug (I should see: 0x01 0x01 0x00 0x00 0x00 0x00 0x00):

I know this isn't the best example, since most of the data sent here is 0x00. But I've tried with other messages that have more specific values, and I'll always receive the same thing as the above pic. Plus I have a CRC I use to validate the data, so it's easy to tell when it is incorrect.
This corrupt data only happens immediately after another device on the SPI bus has transferred. So I know it's related to that. If there are no other transfers on the SPI bus, I see no corrupt data. I've tested this by running for 30 minutes with no other devices. I saw no corrupt data.
It's strange, because I have the TMS320 SPI configured to interrupt on the RX buffer being 1. When the other device on the bus transfers data, the TMS320 does not interrupt. So the RX buffer is not getting filled. However, the data is still corrupt. Also, the TMS320 never interferes with other devices' transfers.
Here is how I have my SPI configured on the TMS320:
void McuCommsInit(void)
{
//
// GPIO55 is the SPISOMIA.
//
GPIO_setMasterCore(55, GPIO_CORE_CPU1);
GPIO_setPinConfig(GPIO_55_SPISOMIA);
GPIO_setPadConfig(55, GPIO_PIN_TYPE_STD);
GPIO_setQualificationMode(55, GPIO_QUAL_ASYNC);
//
// GPIO54 is the SPISIMOA clock pin.
//
GPIO_setMasterCore(54, GPIO_CORE_CPU1);
GPIO_setPinConfig(GPIO_54_SPISIMOA);
GPIO_setPadConfig(54, GPIO_PIN_TYPE_STD);
GPIO_setQualificationMode(54, GPIO_QUAL_ASYNC);
//
// GPIO57 is the SPISTEA.
//
GPIO_setMasterCore(57, GPIO_CORE_CPU1);
GPIO_setPinConfig(GPIO_57_SPISTEA);
GPIO_setPadConfig(57, GPIO_PIN_TYPE_STD);
GPIO_setQualificationMode(57, GPIO_QUAL_ASYNC);
//
// GPIO56 is the SPICLKA.
//
GPIO_setMasterCore(56, GPIO_CORE_CPU1);
GPIO_setPinConfig(GPIO_56_SPICLKA);
GPIO_setPadConfig(56, GPIO_PIN_TYPE_STD);
GPIO_setQualificationMode(56, GPIO_QUAL_ASYNC);
SPI_disableModule(SPIA_BASE);
SPI_setConfig(SPIA_BASE, DEVICE_LSPCLK_FREQ, SPI_PROT_POL0PHA0,
SPI_MODE_SLAVE, 2500000, 8);
SPI_disableLoopback(SPIA_BASE);
SPI_enableTalk(SPIA_BASE);
SPI_enableFIFO(SPIA_BASE);
SPI_resetTxFIFO(SPIA_BASE);
SPI_resetRxFIFO(SPIA_BASE);
SPI_enableModule(SPIA_BASE);
SPI_enableInterrupt(SPIA_BASE, SPI_INT_RXFF);
SPI_setFIFOInterruptLevel(SPIA_BASE, SPI_FIFO_TX16, SPI_FIFO_RX1);
Interrupt_register(INT_SPIA_RX, &RxSpiInterrupt);
Interrupt_enable(INT_SPIA_RX);
GPIO_setInterruptPin(57, GPIO_INT_XINT1);
GPIO_setInterruptType(GPIO_INT_XINT1, GPIO_INT_TYPE_BOTH_EDGES);
GPIO_enableInterrupt(GPIO_INT_XINT1);
Interrupt_register(INT_XINT1, &ChipSelectInterrupt);
Interrupt_enable(INT_XINT1);
}
And here is how I am reading out SPI data:
void ReadSpiReceiveData(void)
{
SPI_RxFIFOLevel rxFifoStat = SPI_getRxFIFOStatus(SPIA_BASE);
uint8_t count = 0;
while(rxFifoStat != SPI_FIFO_RXEMPTY)
{
count++;
WriteToBuffer(SPI_readDataNonBlocking(SPIA_BASE));
rxFifoStat = SPI_getRxFIFOStatus(SPIA_BASE);
}
SPI_resetRxFIFO(SPIA_BASE);
}
