nRF52832 SPI tx rx

Hi

I'm developing nRF52832.

I have a question about SPI communication.(\nRF5_SDK_17.0.0\examples\peripheral\spi I don't understand, so I ask questions.)

I want to read sensor data through SPI communication, but I don't know how to separate Tx and Rx into nrf_drv_spi_transfer.

Example.

1-1. If I want to read the 0x00 register address, is it right to set it up like below?

1-2. When I read the 0x00 register address, do I have to read the register address + 0x00?

2-1. Is this the right way to use data through SPI?

Thank you.

Parents Reply Children
  • Hi

    Also for nrf_drv_spi_transfer:

    The first buffer and length is the data you send, then the second buffer and length is the one you receive.

    In other words, the transfer function will be called once for both TX and RX.

    Then when the spi_event_handler is called , you can read data from your RX register,

    So to read the WHOAMI register from your sensor, my guess is that you can use our SPI example and change the following two things:

    Change initialization to match your sensor.

    Change the TEST_STRING "nordic" to TEST_STRING [1,0,0,0,0,0,0,0]  (1 for read and register address is 0)

    For more info on our SPI master driver, see our SPI master documentation.

    Does this work for you?

    Regards,
    Sigurd Hellesvik

Related