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.

CCS/TMS320F28379D: Synchronizing Manual Control (GPIO) of the SPISTE Signal?

Part Number: TMS320F28379D

Tool/software: Code Composer Studio

When using GPIO to control the SPISTE signal manually, what interrupt or register should be used to indicate the last bit has been shifted out of SPIDAT?

I've used the following and they all cause the GPIO (for SPISTE) to be set too early:

1) while (SpiaRegs.SPIFFTX.bit.TXFFINT == 0) {}

2) while (SpiaRegs.SPIFFTX.bit.TXFFST > 0) {}

3) while (SpiaRegs.SPISTS.bit.BUFFULL_FLAG == 0x1) {}

4) while (SpiaRegs.SPISTS.bit.INT_FLAG == 0) {}

The GPIO (for SPISTE) would be called after the while loop.

Kindly,

Graham

  • Graham,

    In non-FIFO mode, you have to use INT_FLAG flag bit

    In FIFO mode, you have to use SPIFFTXINT flag bit.

    Regards,
    Manoj
  •     std::vector<SpiWord>::const_iterator it;
    
        GPIO_WritePin(61, 0);
    
        for (it = sMultiData.begin(); it != sMultiData.end(); it++)
        {
            // send the data
            SpiaRegs.SPITXBUF = *it;
        }
    
        // This will exit before the data has completely shifted out of SPIDAT
        while (SpiaRegs.SPIFFTX.bit.TXFFINT == 0) {}
    
        GPIO_WritePin(61, 1);

    Manoj,

    It looks like the TXFFINT flag only indicates when there are 0, 1, 2, or 16 words left in the transmit fifo buffer.  Not when the actual data has been shifted out of SPIDAT.  

    When using the TXFFINT flag the GPIO controlled SPISTE ends up turning off 1 spi word too soon, when TXFFIL is set to 0x0.

  • Upon further testing it looks like the following:

    1) In FIFO mode the interrupt flag (TXFFINT) seems to indicate when the transmit FIFO is empty (TX_FIFO_n).  The BUFFULL_FLAG indicates when SPITXBUF is empty and has transferred its contents to SPIDAT.  Not when SPIDAT is done shifting out the data. 

    An interrupt flag signaling SPIDAT has completed is required to manually control the SPISTE via GPIO in FIFO mode.  Otherwise the GPIO controlled SPISTE will be unset early and the data transfer will be incomplete.

    2) In non-FIFO mode the INT_FLAG appears to indicate (via oscilloscope) when the SPITXBUF is empty.  Not when SPIDAT is done shifting out the data.  When waiting for a transmit to complete with:

    SpiaRegs.SPITXBUF = data;
    
    while (SpiaRegs.SPISTS.bit.INT_FLAG == 0x0) {}
    
    // disable SPISTE manually, this will be too early
    GPIO_WritePin(61, 1)

    Is there a way to know when SPIDAT is done shifting out the data to a slave?  Or some other method to synchronize a GPIO controlled SPISTE signal?

    Kindly,

    Graham

  • Graham,

    I have requested C2000 design engineer to look into this. I expect to hear back from them in a week. I shall keep you posted.

    Regards,
    Manoj
  • Hi Manoj,

    Has the design engineer been able to get back to you?

    Kindly,
    Graham
  • Graham,

    Here is the response from the design engineer:-

    • The INT_FLAG in SPISTS register gets set after the transmission of that SPI word is complete
    • A dummy read of the Rx buffer is required to clear the INT_FLAG
    • After INT_FLAG is set, software should add a wait time of 0.5*SPICLK duration before manually disabling STE, to take care of STE hold timing parameter requirement.
    • FIFO mode may not be useful in this case, as there is a requirement to indicate after every word is transmitted.

    Regards,
    Manoj
  • Thanks Manoj,

    It's unfortunate that there is no direct signal or interrupt case to detect when the bits are completely shifted out of the register. Adding a static wait time (0.5 * SPICLK) is not desirable.

    We will be adding additional hardware in order get the SPI functionality we're looking for.

    Thanks for looking into this.

    Kindly,
    Graham