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: SPI - read multiple bytes in one transaction

Part Number: CC2640R2F

Hi,

I`m currently work on project that required read FIFO from sensor (kx222 of Kionix via SPI.

I should read 168 bytes in one transaction of SPI. Meaning that the CS should get low in the start transaction and than I want to generate 168B * 8b clocks in order to read the FIFO.

I`m using TI driver for SPI and I got noticed that when i set the transaction count it is set the CS for each reading. 

How can I make generate more clocks without set the CS again for each transaction ?

  • Hi Ohad,

    When you're setting up your SPI_Transaction, have you selected an appropriate size for the count data field?

    I'd suggest taking a look at the "Use Cases" section in the driver documentation:

    http://software-dl.ti.com/dsps/dsps_public_sw/sdo_sb/targetcontent/tirtos/2_20_00_06/exports/tirtos_full_2_20_00_06/products/tidrivers_full_2_20_00_08/docs/doxygen/html/_s_p_i_c_c26_x_x_d_m_a_8h.html

    -Sy Su

  • Hi, Thanks for the response. I did set the transaction count to the required count. But in that case, i see the CS swinging in thr same count i set. I want to read multiple bytes in one transaction. Let me clirify, I want that the transaction will perform more than 16 clicks, I need 168B * 8 b clocks plusone more clock sycle for the register adrress. The CS sould remain low for the all transaction period.
  • Is there a way to generate more than 16 clocks in one transaction ?

    I want to achieve the following transaction :

    1. Set CS to low.

    2. Send the register address.

    3. generate n clocks (n= the byte count I want to read)

    4. Set the CS to high.

  • Ohad,

    This is what you're trying to do, correct? 

    I have the value 0x75 as if it is the register address. After the register address there are 16 transactions left open while keeping CS low until the end. I don't have anything coming in on the MISO since I have nothing to read from but in your case you'd expect data from whatever you are reading from.

    This is all done with the following. Is there anything different than what you have?:

    SPI_Transaction spiTransaction;
    
    // Init SPI and specify non-default parameters
    SPI_Params_init(&spiParams);
    spiParams.bitRate     = 1000000;
    spiParams.frameFormat = SPI_POL1_PHA1;
    spiParams.mode        = SPI_MASTER;
    
    spiTransaction.count = 17;    // sizeof(rxBuf) could work too
    spiTransaction.txBuf = txBuf; // txBuf with the register address in it
    spiTransaction.rxBuf = rxBuf; // rxBuf empty array of appropriate size
    
    // Open the SPI and perform the transfer
    spiHandle = SPI_open(Board_SPI0, &spiParams);
    SPI_transfer(spiHandle, &spiTransaction);

    -Sy Su