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 assume you are trying to combine:

    \nRF5_SDK_15.2.0_9412b96\examples\peripheral\nrfx_spim
    \nRF5_SDK_15.2.0_9412b96\examples\peripheral\uart 

    1. If SPIM doesn't work as expected, make sure you have a logic analyzer so you can monitor the SPI lines.

    2. You are passing a pointer to the start address in memory of where the data is. To pass the address you may use '&variable'.

    Best regards,
    Kenneth

  • thank you for your reply!

    I only commented out the command to change the mode of the ADS 1192!

    Now we have received data properly!

    However, I would like to obtain hexadecimal data, but ASCII conversion will occur and Japanese katakana will be output.

    should I have to use some conversion function to receive output data in hexadecimal number?

    best regards!!

Reply
  • thank you for your reply!

    I only commented out the command to change the mode of the ADS 1192!

    Now we have received data properly!

    However, I would like to obtain hexadecimal data, but ASCII conversion will occur and Japanese katakana will be output.

    should I have to use some conversion function to receive output data in hexadecimal number?

    best regards!!

Children
Related