This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

SPI Slave comms bit shifted

Other Parts Discussed in Thread: HALCOGEN

Hi,

I'm trying to set up slave communications on a TMS570LS04 launchpad board. I need to be able to send messages out of one SPI port (in this case SPI3) and receive replies from another (SPI2), SPI3CS0 is linked to SPI2CS0.

To test the operation of this I have linked SPI3 - SIMO to SPI2 - SIMO and configured the device using HalCoGen (v04.05.01) with SPI2 configured as the slave. I have called the functions spiTransmitData then spiReceiveData, that were created by HalCoGen, with some dummy data. The code fragment is shown below:

void main(void)
{
/* USER CODE BEGIN (3) */
    RETURN_TYPE AsicInitialised;
    uint16_t srcbuff[5], destbuff[5];


    InitRetries = 0;
    initNVM();


    gioInit();
    spiInit();


    srcbuff[0] = 0x0084;
    srcbuff[1] = 0x0012;

    spiTransmitData(spiREG3, &Format2, 1, srcbuff);
    spiReceiveData(spiREG2, &Format2, 1, destbuff);

    spiTransmitData(spiREG3, &Format2, 1, &srcbuff[1]);
    spiReceiveData(spiREG2, &Format2, 1, &destbuff[1]);

I set a breakpoint on the line following and view the results by hovering the cursor over destbuff. What I see in the first reception is 0x42 and in the second 0x12. So it appears the first byte back is shifted to the right by one bit. I've looked at the signals on a scope and they appear to conform to the timing requirements in the datasheet.

Subsequent data transfers come through ok, but the first one is always wrong. If the data length is changed to 2, then both of the first two bytes are wrong. Only when it does the second (and subsequent) calls to spiReceiveData does the data come through correctly.

Any ideas on what could be going wrong?

The screenshot below shows the clock and the CS0:

The screenshot below is the clock and the SIMO lines:

Regards

Andy