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

How to Receive data with SPI from sensor and output with UART

Hi!!

I would like to receive data from the sensor via SPI using nrf 52832 DK and output data with UART.

It is now possible to add the function of uart to the spi sample code of SDK 14.0.0 and run it only with uart.

However, it is not possible to receive data from the sensor and output it with uart

I think that it is outputting the contents of an empty array.

How can I receive data from an external sensor via spi and output data with uart?

I mainly send and receive SPI and send uart data with the following code

best regards!!!



void SPITxDummy(unsigned char Data)
{
nrf_gpio_pin_clear(22); //CS pin low
nrf_drv_spi_transfer(&spi, &Data, 1, m_rx_buf, 1);
nrf_delay_us(50);
}

while (1)
{
SPITxDummy(0x00); //Dummy Data
app_uart_put(m_rx_buf[0]);
nrf_delay_ms(200);

}

Parents
  • Hi!

    I do not know how to solve the two problems

    1.I checked m_rx_buf to store the value of MISO after sending the dummy signal, but nothing was stored.

    Why is not the value from MISO stored in m_rx_buf?

    2.Also, in nrf_drv_spi_transfer used for sending and receiving spi data, the type received must be uint8_t *, the type of app_uart_put to be sent in uart must be uint8_t, what should you do if it matches the same type?

    I believe that solving this problem will lead to successful transmission and reception of data from external sensors.

    thank you in advanced!!!!

     

Reply
  • Hi!

    I do not know how to solve the two problems

    1.I checked m_rx_buf to store the value of MISO after sending the dummy signal, but nothing was stored.

    Why is not the value from MISO stored in m_rx_buf?

    2.Also, in nrf_drv_spi_transfer used for sending and receiving spi data, the type received must be uint8_t *, the type of app_uart_put to be sent in uart must be uint8_t, what should you do if it matches the same type?

    I believe that solving this problem will lead to successful transmission and reception of data from external sensors.

    thank you in advanced!!!!

     

Children
No Data
Related