SPI Transaction using spi_transceive behaviour

Hi,

I am using nrf52840 , nrf connect sdk 2.6.0

I am  using spi_transceive() to send and receive the data from sensor

I read in Nordic Academy nrf connect sdk intermediate lesson 5 exercise 1  


If we are sending 1 byte then receiving bytes should 2 and first byte is dummy?

Is this is for all sensors.

Thank you in advance

Parents
  • I think you should just try and see what you get. But it is correct. If you use transceive(), it will read and write simultaneously (on the same clock cycles), so when the sensor haven't received any commands up front, then it doesn't know what to reply in the first byte. There is also API that you can use to only read or write. This will use transceive() "under the hood", but take away the garbage data.

    But try to do an spi_transceive(), and compare the data you are seeing with what it says in the datasheet. 

    Best regards,

    Edvin

Reply
  • I think you should just try and see what you get. But it is correct. If you use transceive(), it will read and write simultaneously (on the same clock cycles), so when the sensor haven't received any commands up front, then it doesn't know what to reply in the first byte. There is also API that you can use to only read or write. This will use transceive() "under the hood", but take away the garbage data.

    But try to do an spi_transceive(), and compare the data you are seeing with what it says in the datasheet. 

    Best regards,

    Edvin

Children
No Data
Related