This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

SPIM, recieve on first transmit

ADS1118:

SPIM

How can I recieve the first 16 bits getting transmitted by the slave ? Will MOSI clock out p_txBuf while storing bits to arr_rxBuf if I set TX buffer len to 0, like this:

nrf_drv_spi_transfer(&spi, p_txBuf, NULL, arr_rxBuf, 2);
  • Never mind, I feel silly - I had misunderstood how the driver works. It works as expected now.

    For reference, all data transmitted though MISO is stored in arr_rxBuf, for this case I just had to set

    nrf_drv_spi_transfer(&spi, p_txBuf, 2, arr_rxBuf, 2);
    

    in order to read DATA MSB and DATA LSB.

    For the other case:

    SPIM2

    I just had to call

    nrf_drv_spi_transfer(&spi, p_txBuf, 2, arr_rxBuf, 4);
    

    and DATA MSB, DATA LSB, CONFIG MSB, and CONFIG LSB is recieved in arr_rxBuf[0..3]

Related