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.

CC3220SF-LAUNCHXL: Incorrect data at CC3220SF SPI RX while communicating with C2000 (F28379D-LAUNCHXL)

Part Number: CC3220SF-LAUNCHXL
Other Parts Discussed in Thread: CC3220SF, CC3220S

Hi,

I am trying to communicate between CC3220SF (Master) and C2000(Slave) using SPI but not able to perform the duplex communication between two. Below are the details of the issue -  

1. When Master Tx is NULL and Data Transfer from Slave(c2000) to Master(CC3220SF)- 

 transaction.count = SPI_MSG_LENGTH;
        transaction.txBuf = NULL;
        transaction.rxBuf = (void *) masterRxBuffer;

Below is the status - 

Data On Line (MISO) Correct
Data in RX Buffer (CC3220SF) Correct

2. When Master Rx is NULL, Data Transfer from Master (CC3220SF) to Slave(C2000) - 

        transaction.count = SPI_MSG_LENGTH;
        transaction.txBuf = (void *) masterTxBuffer;
        transaction.rxBuf = NULL;

Below is the status - 

Data On Line (MOSI) Correct
Data in RX Buffer (C2000)  Correct

3. When Master Master Rx and Tx Both are not NULL- 

        transaction.count = SPI_MSG_LENGTH;
        transaction.txBuf = (void *) masterTxBuffer;
        transaction.rxBuf = (void *) masterRxBuffer;

Below is the status - 

Data On Line (MOSI) Correct
Data in RX Buffer (C2000)  Correct
Data On Line (MISO) Correct
Data in Rx Buffer (CC3220SF) Incorrect

Data Line Status - 

Incorrect Receive Buffer on (CC3220SF)

Can anyone please help with the issue?

Thanks & Regards,

Kuldeep

  • Are the SPI frame format the same between the two devices? IE. POLx and PHAy? It looks like the CC3220S is just clocking incorrectly based on whatever is set.

  • Hi Sabeeh,

    Below is the configuration for the slave and master for the SPI - 

    In Master(CC3220) - 

     

        /* Open SPI as master (default) */
        SPI_Params_init(&spiParams);
        spiParams.frameFormat = SPI_POL0_PHA1;
        spiParams.transferMode= SPI_MODE_BLOCKING;
        spiParams.bitRate = 250000;
        spiParams.dataSize = 16;
        masterSpi = SPI_open(CONFIG_SPI_MASTER, &spiParams);
        if (masterSpi == NULL) {
            Display_printf(display, 0, 0, "Error initializing master SPI\n");
            while (1);
        }
        else {
            Display_printf(display, 0, 0, "Master SPI initialized\n");
        }

    In Slave (C2000) -

        //
        // Must put SPI into reset before configuring it
        //
        SPI_disableModule(SPIA_BASE);
    
        //
        // SPI configuration. Use a 250kHz SPICLK and 16-bit word size.
        //
        SPI_setConfig(SPIA_BASE, DEVICE_LSPCLK_FREQ, SPI_PROT_POL0PHA1,
                      SPI_MODE_SLAVE, 250000, 16);
        SPI_disableLoopback(SPIA_BASE);
        SPI_setEmulationMode(SPIA_BASE, SPI_EMULATION_FREE_RUN);
    
        //
        // FIFO and interrupt configuration
        //
        SPI_enableFIFO(SPIA_BASE);
        SPI_clearInterruptStatus(SPIA_BASE, SPI_INT_RXFF);
        SPI_setFIFOInterruptLevel(SPIA_BASE, SPI_FIFO_TXEMPTY, SPI_FIFO_RX1);
        SPI_enableInterrupt(SPIA_BASE, SPI_INT_RXFF);
        //
        // Configuration complete. Enable the module.
        //
        SPI_enableModule(SPIA_BASE);

    Is there any issue in above configuration ? I kept both side POL and PHA same as shown above.

    Thank you,

    Best Regards,

    Kuldeep

  • Hi Kuldeep,

    The software setup that you have posted seems correct.

    It seems like the data you're getting back is shifted by a bit or two, ex. 0x40 becomes 0x80. Perhaps there is some hardware issue at hand.

    If you have another SPI device, such as a second cc3220, you could run that as the SPI slave and see if you get the correct data out of the RX buffer with the same CC3220 test code. 

    If you get the correct result, then I would look into the hardware setup you have. While 250,000 is a moderate bitrate for SPI, there is still the possibility or some error due to the actual wiring or other physical setup. You'd have to use an oscilloscope, and not a logic analyzer to see if if your SPI RX signal to the CC3220 satisfies all of the requirements as described in the SPI RX section of the CC3220 datasheet.

    I suggest you try that test of using some other SPI slave and seeing if you get the correct result with the same CC3220 code. That will help narrow down the problem.

    Regards,

    Michael

  • Hi Michael,

    Currently I don't have 2 CC3220SF or other MCU. So, I can't try that. 

    Is there any other way to check the same ?

  • Hi, I don't see anywhere in the C2000 code where polarities are set. Could you please verify that?

  • Hi Sabeeh,

    Below is the function prototype details for the polarity and phase for the c2000 -

    And, in my code of C2000 (Slave) I have the polarity as below - 

    Same for the CC3220SF is as below - 

    Can you please let me know if you are not talking about this?

    Or any mistake is there in the above ?

    Thanks & Regards,

    Kuldeep

  • Yes thanks for pointing that out to me, it all looks okay. 

    As Michael suggested, I would encourage you to use an oscilloscope or another MCU to understand what may be occurring at the physical level. It is clear something is not being clocked in correctly. 

  • Hi Sabeeh, Thanks for your input.

    The issue got resolved after having the different Polarity and Phase settings.

    Thanks

    - Kuldeep