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 is answering to slow (CC2650 7ID)

Other Parts Discussed in Thread: CC2650

I Have the folowing installation:

And I want that the Master sends something to the slave and the slave sends something to the master at same time. But I get this:

D10 = Clock

D9 = Master out Slave in

D8 = Slave out Master in

You can see that the Slave is sending to late (red line).

I´m using TI RTOS and i used several frequences from 1000 Hz up to 4 MHz. And on 4MHz the Slave is sending nothing. On 40kHz the Slave is sending 2 Bytes to late. I´m at loss what to do.

  • Hi Faith,

    From what I see the slave seems to send the same thing as the master but with a delay. Are you trying to send back what you received or is the data "preloaded" in the output buffer of the slave?

    Is it possible to see some code?
    We would need the initialization, how you initiate the communication and the ISR routine to handle the data. (you can use rich formatting to make code more readable in your posts)

    Also, how many tasks are currently running on your CC2650?

    Michel
  • Hi Michel,

    first i´d like to say thank you. I´m new with the CC2650 and I want to learn the SPI communication in the CC2650 therefore I startet with a simple example.   The Master and the Slave are "preloaded" with the same string. The slave is configured to start SPI communication from the beginning (with the option no_spi_timeout). If i push a button in the master they will send his string and should get at the same time the string from the slave. There is nothing more. I have only one Task to simplify the code.

    I have no ISR routine for SPI.  The code is on my home computer but i can write a pseudocode with the right initialization.

    Pseudocode for Slave:

    #define SPI_MSG_LENGTH   14

    unsigned char slaveRxBuffer[SPI_MSG_LENGTH];
    unsigned char slaveTxBuffer[SPI_MSG_LENGTH]="Hello, this is";

    SPI_Handle slaveSpi;
    SPI_Params slaveSpiParams;
    SPI_Transaction slaveTransaction;

    Void slaveTaskFxn (UArg arg0, UArg arg1)

    {

    SPI_transfer(slaveSpi, &slaveTransaction);

    while(1);

    }

    int main(void)

    {

    Task_Params taskParams;

    /* Call board init functions */

    Board_initGeneral();
    Board_initSPI();
    Board_initGPIO();

      

    /* Initialize SPI handle with slave mode */

    SPI_Params_init(&slaveSpiParams);
    slaveSpiParams.bitRate = 4000000;
    slaveSpiParams.frameFormat = SPI_POL0_PHA0;
    slaveSpiParams.mode = SPI_SLAVE;

    slaveSpi = SPI_open(Board_SPI0, &slaveSpiParams);

     /* Initialize slave SPI transaction structure */

    slaveTransaction.count = SPI_MSG_LENGTH;
    slaveTransaction.txBuf = slaveTxBuffer;
    slaveTransaction.rxBuf = slaveRxBuffer;

        

    Task_Params_init(&taskParams);
    taskParams.priority = 2;
    taskParams.arg0 = 1000000 / Clock_tickPeriod;
    taskParams.stackSize = TASKSTACKSIZE;
    taskParams.stack = &task0Stack;
    Task_construct(&task0Struct, (Task_FuncPtr)slaveTaskFxn, &taskParams, NULL);

      

    /* Start BIOS */

    BIOS_start();
    return (0);

    }

    My Pseudocode for Master:

    #define SPI_MSG_LENGTH   14

    unsigned char MasterRxBuffer[SPI_MSG_LENGTH];
    unsigned char MasterTxBuffer[SPI_MSG_LENGTH]="Hello, this is";

     

    SPI_Handle masterSpi;
    SPI_Params masterSpiParams;
    SPI_Transaction masterTransaction;

     

    Void ButtonISR (UArg arg0, UArg arg1)

    {

    SPI_transfer(masterSpi, &masterTransaction);
    while (1);

    }

    int main(void)

    {

       Task_Params taskParams;

       /* Call board init functions */

    Board_initGeneral();
    Board_initGPIO();
    Board_initSPI();

      

    SPI_Params_init(&params);
    params.bitRate = 4000000;
    params.frameFormat = SPI_POL0_PHA0;
    params.mode = SPI_MASTER;

     

       /* Initialize SPI handle as default master */

       masterSpi = SPI_open(Board_SPI0, &params);

      

       /* Initialize master SPI transaction structure */

       masterTransaction.count = SPI_MSG_LENGTH;

       masterTransaction.txBuf = masterTxBuffer;

       masterTransaction.rxBuf = masterRxBuffer;

    /* Start BIOS */

       BIOS_start();

       return (0);

    }

  • Hi Faith,

    If you have the chance, can you attach both the slave and master projects? There are a few things in the pseudo-code that are a bit off and I am not able to accurately reproduce the issue you are seeing.

    Regards,
    Gilbert
  • Thank you for your help.
    I´ve found my mistake. The SPI-Slave have to start (SPI_transfer(..)) more than 300µs earlier than the master(on 4MHz). Otherwise the Slave is not ready and lose some bytes.

    Regards,
    Fatih