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.

CC2640R2F: CCXXXX: SPI chip select not toggling even in DMA mode

Part Number: CC2640R2F

I'm using the standard SPI C24XX driver and even in DMA mode, the CS chip select pin is toggling between the bytes:

#include <ti/drivers/SPI.h>
#include <ti/drivers/spi/SPICC26XXDMA.h>

SPICC26XXDMA_Object spiCC26XXDMAObjects[1];

const SPICC26XXDMA_HWAttrsV1 spiCC26XXDMAHWAttrs[1] = {
    {
        .baseAddr           = SSI0_BASE,
        .intNum             = INT_SSI0_COMB,
        .intPriority        = ~0,
        .swiPriority        = 0,
        .powerMngrId        = PowerCC26XX_PERIPH_SSI0,
        .defaultTxBufValue  = 0xFF,
        .rxChannelBitMask   = 1<<UDMA_CHAN_SSI0_RX,
        .txChannelBitMask   = 1<<UDMA_CHAN_SSI0_TX,
        .mosiPin            = Board_SPI0_MOSI,
        .misoPin            = Board_SPI0_MISO,
        .clkPin             = Board_SPI0_CLK,
        .csnPin             = Board_SPI0_CS0,
        .minDmaTransferSize = 3
    },
};

const SPI_Config SPI_config[1] = {
    {
         .fxnTablePtr = &SPICC26XXDMA_fxnTable,
         .object      = &spiCC26XXDMAObjects[0],
         .hwAttrs     = &spiCC26XXDMAHWAttrs[0]
    },
};

const uint_least8_t SPI_count = 1;

Then, I'm using  SPI_transfer(spiHandle0, &t0);

As you can see in the following trace, SP_CS is toggling between the bytes and my sensor doesn't like this:

How can I avoid the toggling of the chip select? I have tried, longer/bigger transfer, it's the same problem.

  • Hi,

    The CSN toggle in this case is controlled by SPI module, and this is enabled due to csnPin assigned to valid DIO.

    There is an option to control CSN by application, and with that, you can control precisely when the CSN is asserted.
    This can be enabled by setting csnPin to PIN_UNASSIGNED.

    Then your application code would be updated to something like:

    GPIO_write( ... CSN ... low ...);
    
    SPI_transfer( 1 );
    SPI_transfer( 2 );
    ...
    SPI_transfer( N );
    
    GPIO_write( ... CSN ... high ...);

    Thanks,
    Toby

  • Thank you for your help.

    - First, my title was not correct. I need the CS pin NOT to toggle between bytes.

    - Secondly, I have already done what Toby suggests but then the amount of time between CS going down and the clock moving is too long (a dozen of us). The sensor datasheets says "During accesses, SPICSN must not be driven low too long (1.6 µs). That would prevent the internal use of SPI and break the timing in the sequencer."

    - Thirdly, according to this question, the CS pin is supposed NOT to toggle between bytes if minDmaTransferSize is probably used. I don't see that despite setting up the variable.

    my question is then: is there a register to force NOT toggling CS during the transfer of bytes? And why am I seeing toggling in DMA mode while according to the question mentioned above there should be no toggle in such case?

  • Is this a custom board or a TI launchpad?

    Do you see the same behavior if you use the SDK SPI example?
    dev.ti.com/.../node

  • It's a custom board indeed. I don't think that a custom PCB is going to change anything about the ability to toggle CS in SPI master mode.

  • Do you see the same behavior if you use the SDK SPI example?
    dev.ti.com/.../node

    (adjusted for which DIOs are used on your board)