nrf52832 UART data reception from another MCU and printing it over serial terminal

Hi, currently I am working with a TI mmWave radar which gives integer value as output. When I try to fetch this data via UART TX and RX pins, they are not received and printed properly. Instead, an unknown value is printed over serial terminal. Is there any way to overcome this? I have already tried receiving, storing and printing a character data with the board but it is not the same for integer. how to fix this?

Note:

Radar tx    -    nrf52832dk rx

Radar rx   -     nrf52832 dk tx

vcc      -     3.3v

gnd        -     gnd

  • Hello,

    When I try to fetch this data via UART TX and RX pins, they are not received and printed properly. Instead, an unknown value is printed over serial terminal. Is there any way to overcome this?

    This sounds to me like it might be an issue with the parsing of the received data.
    Is everything else working as expected, apart from the received values not being as expected? I.e there is no errors or failures otherwise?

    Could you provide some examples of these unknown values, and the range that you would have expected them to be in?
    My suspicion is that your sent integers are interpreted as char on the receiving end, for instance.
    To isolate where in the communication this happens you can print the data received from your sensor in the device log, as well as pushing it to the UART. This way you can verify if the issue is that your serial terminal is parsing it incorrectly, or if the value is incorrect in the nRF.

    Best regards,
    Karl

  • Thanks for the reply. Yes. Except this everything is working fine. For example, i tried to receive the data "hello world" from the radar module. I received each character, stored it in an array and printed it. It worked perfectly. But when I try to receive the values 4 and 10 from the module, I am not able to print the same value. I am attaching the code for your reference.

    int main(void)
    {
    uint32_t err_code;
    bsp_board_init(BSP_INIT_LEDS);


    const app_uart_comm_params_t com_params =
    {
    RX_PIN_NUMBER,
    TX_PIN_NUMBER,
    RTS_PIN_NUMBER,
    CTS_PIN_NUMBER,
    UART_HWFC,
    false,
    NRF_UART_BAUDRATE_115200

    };

    APP_UART_FIFO_INIT(&com_params, UART_RX_BUF_SIZE, UART_TX_BUF_SIZE, uart_err_handle, APP_IRQ_PRIORITY_LOWEST, err_code);


    APP_ERROR_CHECK(err_code);

    printf("UART Receiver\n");

    while(true)
    {

    uint32_t cr;

    uint32_t data[20];
    int i=0;

    app_uart_get(&cr);


    if(cr!=0)
    {

    data[i] = cr;
    i++;
    // for (int j = 0; data[j] != '\0'; j++) {
    printf("%d",data[i]);
    // }
    nrf_delay_us(1000000);

    // }

    }

    }
    }

  • Can you please help me in this? I am actually receiving a binary data over UART. I need to print the corresponding integer value but I am stuck.

    Thanks

  • Hello,

    Jayasurya K said:
    Thanks for the reply.

    No problem at all, I am happy to help! :) 

    Jayasurya K said:
    Yes. Except this everything is working fine. For example, i tried to receive the data "hello world" from the radar module. I received each character, stored it in an array and printed it. It worked perfectly. But when I try to receive the values 4 and 10 from the module, I am not able to print the same value. I am attaching the code for your reference.

    I am glad to read that everything else is working fine - this strengthens my suspicion that this issue is with the parsing of the data, and not with the application/data itself.
    Could you clarify what you mean when you say 'print' here, do you mean print in the log, or in your serial monitor?
    In case of the former, please try to use printf("%#08x\n", i); for your printing of the data to verify that it is the correct value.
    In case of the latter, please check if your serial monitor has an option to show the received data directly without parsing it as char.

    For future reference, please use the Insert -> Code option when sharing code here on DevZone.

    Best regards,
    Karl

  • Hi Karl,

    Thanks and sorry for the delayed reply. After few corrections, we were able to make radar module to give live values in form of characters. Now the issue is,  when I try to receive a data "Hello World" from the module, we are able to receive each character, store and then print them. Now, the module sends live updated data "4, 0, 0, 0, 0" in character format. When we tried to receive this using the nRF52 with same code, it was not possible. What are we missing here? What should be done in order to receive the live data from radar module? Please clarify for us on this. Here are the UART configurations.

    Baud rate: 115200 
    Parity bit: none
    Hardware flow control: disabled
    Stop bits: 1
    UART instance: UART0
Related