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.

Problem on SPI synchronization

Hi, I have two device (TMS30F28069) which should be able to talk each other with SPI. But I have a synchronization problem and I don't know how to find a good way to do. Igive you a part of code in orderto explain me if you see something really wrong...I've tried a lot of things but nothing work at each time:

Master :

The transmission :

SPI_Emit_CMD(0, 1);

The function :

SPI_Emit_CMD(unsigned int CMD_IN, unsigned int CMD_OUT){

    unsigned int res = 0, k = 0;

    while(res != CMD_OUT){
        SpibRegs.SPITXBUF = CMD_IN;
        while(SpibRegs.SPISTS.bit.INT_FLAG != 1);
        DELAY_US(10);
        res = SpibRegs.SPIRXBUF;
    }

}

Slave :

The transmission :

SPI_Emit_CMD(1, 0);

The function :

SPI_Emit_CMD(unsigned int CMD_IN, unsigned int CMD_OUT){

  unsigned int res = 0;


    while(res != CMD_OUT){
        SpibRegs.SPITXBUF = CMD_IN;
        while(SpibRegs.SPISTS.bit.INT_FLAG != 1);
        //DELAY_US(4);
        res = SpibRegs.SPIRXBUF;
    }

}

I don' understand what is so wrong ? Thank you to help me

  • Hi Cedric,

    In your setup, how does slave communicate to master that it's ready for communication?  

    Regards,

    Vivek Singh

  • Hello,

    In addition of Vivek comment, did you connect SPISTE of Slave to one of the GPIO pin of the Master?

    SPISTE pin of Slave then should be lowered by Master before the transmission.

    In this case, I think you will not missed any bit.

    I have used 2 F28027F (one asSPI  Master and one as Slave) using this method and it works fine (only I used interrupt for receiving the characters in both sides instead of checking the flag).

    Good luck.

    Best regards,

    Maria

  • Hi, everybody,

    I would like to thank you for your answers. In fact with an oscilloscop when a transmission happens everything on MOSI and MISO seems to be OK but I have solved my problem of synchronization by adding another bit (on top of MISO, MOSI,CLK and CS which is SPISTE) to communicate to the master from the slave that this one is ready to read the future transmission...and I thought SPI transmission only needs CLK, MOSI,MISO and CS and not an other GPIO on top of these....For your question, yes I used the SPISTE from slave to a GPIO from the master because the master has a lot of slave so selection is not in option and is OK. But the fact to don't see each other at the good time had really made me crazy. So to answer to Vivek, I thought there was no need to the slave to communicate it was ready to receive and to add another GPIO to transmit this ready state had really surprised me...

    Is there any mean to use an SPI communication with only the four GPIO basics (CLK, MOSI, MISO, and CS) and no interrupt or is it normal to add any GPIO to let know the moment the slave is ready ? Because after this I don't have any other free GPIO, so I can't add anything on my systems which is not problematic at hte moment but maybe in the future...In any case, I would like to thank you to spend your time to answer me ;) Have a good day ;)

    Regards,

    Cédric

  • I was running into the same issue with 2 F28069's and I found this thread. My setup appears to be the same with the master CS (GPIO) going to the slave STE pin, in addition to other SPI signals (CLK, SOMI, SIMO). The data in the slave look correct but out of order, and I have not been able to find an elegant way of synchronize it, until this thread. But, like the OP, I'd like to know if there is any other way to do this instead of having another GPIO to talk back from the slave to the master. It does sound like a kludge to me.

    Thanks,

    Erik