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

uart communication error in nrf52832

hello,

i am using nrf52832 with sensor which uses uart communication and using sdk 15.2 

int main(void)
{
    uint32_t err_code;
    uint8_t readbuf[50];
    uint8_t buf[10];
    buf[0]=0x49;
    uint8_t buf_len=0;
    uint8_t buf_r[10];
    bsp_board_init(BSP_INIT_LEDS);

    const app_uart_comm_params_t comm_params =
      {
          RX_PIN_NUMBER,
          TX_PIN_NUMBER,
          RTS_PIN_NUMBER,
          CTS_PIN_NUMBER,
          UART_HWFC,
          true,
#if defined (UART_PRESENT)
          UART_BAUDRATE_BAUDRATE_Baud4800

      };

    APP_UART_FIFO_INIT(&comm_params,
                         UART_RX_BUF_SIZE,
                         UART_TX_BUF_SIZE,
                         uart_error_handle,
                         APP_IRQ_PRIORITY_LOWEST,
                         err_code);

    APP_ERROR_CHECK(err_code);




  

        nrf_drv_uart_rx_enable(&app_uart_inst);



       err_code=nrf_drv_uart_rx(&app_uart_inst, readbuf, 50);

  if (err_code == NRF_SUCCESS)
    {
       
         printf("initialising sucesss rx\n");
    }
nrf_drv_uart_tx(&app_uart_inst, buf, 1);
nrf_drv_uart_rx(&app_uart_inst, buf_r, 4);

printf("%x\n",buf_r[0]);
printf("%x\n",buf_r[1]);
printf("%x\n",buf_r[2]);
printf("%x\n",buf_r[3]);

}
 but i could not get my excepted values in rx buffer which is of 3 bytes and values are 0x55,0x79,0x00 i want to know if i can  get up to 3 bytes using this err_code = nrf_drv_uart_rx(&app_uart_inst, readbuf, 3); and i have attached my sdk config file with this 4478.sdk_config.txt

thanks and regards 

manikandan v

  • Hello manikandan v,

    but i could not get my excepted values in rx buffer which is of 3 bytes and values are 0x55,0x79,0x00 i want to know if i can  get up to 3 bytes using this err_code = nrf_drv_uart_rx(&app_uart_inst, readbuf, 3);

    You are not checking the returned error code from your call to nrf_drv_uart_rx - you only check whether it is NRF_SUCCESS specifically.
    Are you consistently seeing the initialising sucesss rx message in your logs? What do your logs say when you run this program?
    The call might be failing, without you knowing it. Please always check returned error codes.

    Please also make sure to have DEBUG defined in the preprocessor defines like shown in the included image:

    This will output a detailed error message to your logger whenever a non-NRF_SUCCESS error code is passed to an APP_ERROR_CHECK.

    Best regards,
    Karl

Related