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 - TX shift register

Hi All,
I'm trying to implement simple SPI driver in compatibility mode on TMS570 to do byte by byte transfer. I wish manually to drive the CS lines.
No I have problem that after transefring last byte to SPIDAT0->TXDATA register I can't check when the data are moved from shift register.
I can only check when they are copied from buffer to shift register (with SPIBUF->TXFULL).
How to make sure they are transfered out from shift register? Any ideas?

  • The TXINTFLG/TXFULL  indicates if the buffer is full or empty. Bascially, whether you can write another data to spi buffer. This does not mean the shift register is clear. There may be another work around.

    Assume you use SPICLK phase=0 and polarity=0, so that, the SPI send out the data at the rising edge and receive the data at the falling edge. When you get an RxINTFLG, the transmit should have already been completed for at least half spi clock. You might use this flag to indicate the shift register is clean.

    It is just my thought. Does that make sense?

    Regards,

    Haixiao

  • Thanks for your hint but I figured out different solution.

    Instead of checking for TXFULL I check SPIBUF->RXEMPTY

    If it’s not empty it means that data were shifted from shift register.

    Sample code:

        SPIBUF->DAT0 = valueToTransfer; // Put data to TXBUF

        while (SPIBUF->BUF & SPI_SPIFLG_RXEMPTYFLG) // Wait until byte is received

        {

        }
        dummy = SPIBUF->
    BUF; // Read RXBUF to set RXEMPTY flag  

     

    I guess it’s also OK. Please let me know if you see any potential problems with it.