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

NRF 52840 UART RX fails to receive data from a modem

Hello, I am currently working on a nr52840 s140 Sdk 17.0 (dev kit) and am using the peripheral/uart example code.

The UART TX & RX works perfectly when connecting to a TTL to USB converter with my PC. However, when I try to connect nr52840 with an LTE modem (dev kit), I can see TX transmitted  from the uart_event_handler (APP_UART_TX_EMPTY) but the UART RX never receives any message from the modem.

Here are some more experiments I conducted.

1. Use   TTL to USB converter and the modem --> both TX and RX works perfectly.

2. Use a different mcu to communicate with the modem --> both TX and RX works perfectly.

Based on these two experiments, it looks like somehow nordic fails to receive RX messages due to some wrong configuration.

Is there any suggestion on this issue?

Thank you!

code for initializing UART

uint32_t err_code;
const app_uart_comm_params_t comm_params =
{
RX_PIN_NUMBER,
TX_PIN_NUMBER,
RTS_PIN_NUMBER,
CTS_PIN_NUMBER,
APP_UART_FLOW_CONTROL_DISABLED,
false,
#if defined (UART_PRESENT)
NRF_UART_BAUDRATE_115200
#else
NRF_UARTE_BAUDRATE_115200
#endif
};

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

code for transmitting UART

uint8_t * tx_data = (uint8_t *)("AT\r\n");

for (uint32_t i = 0; i < strlen((char *)tx_data); i++){
app_uart_put(tx_data[i]);
}

code for event handler

static void demo_uart_event_handler(app_uart_evt_t * p_event)
{

if (p_event->evt_type == APP_UART_COMMUNICATION_ERROR){
APP_ERROR_HANDLER(p_event->data.error_communication);
}
else if (p_event->evt_type == APP_UART_FIFO_ERROR){
APP_ERROR_HANDLER(p_event->data.error_code);
}
else{
if(p_event->evt_type == APP_UART_DATA){
uint8_t rx;
app_uart_get(&rx);
push_to_rx_buffer(rx);

}
SEGGER_RTT_printf(0, "p_event->evt_type = %d\n", p_event->evt_type);
}
}

Parents
  • Hello,

    I suggest you look at the implementation in the ble_app_uart example, which sets up the UART with an uart event handler.

    I noticed that you are using the APP_UART_DATA event. This is where you expect to get the data, right? According to app_uart.h line 104:

        APP_UART_DATA,                /**< An event indicating that UART data has been received, and data is present in data field. This event is only used when no FIFO is configured. */

    So this event will not trigger.

    I suggest that you try to look for the APP_UART_DATA_READY event, and look at how this event is handled in main.c in the ble_app_uart example.

    I just noticed that your event handler looks like this. It should work, but make sure that if you add to these checks, that the brackets are correct. It might be tidier to use "else if ( event == EVENT_C) "as well, or even better, a switch case, like in the ble_app_uart example.

    if (event == EVENT_A)
    {
        handle_event_a();
    }
    else if (event == EVENT_B)
    {
        handle_event_b();
    }
    else
    {
        if (event == EVENT_C)
        {
            handle_event_c();
        }
    }
    

    Best regards,

    Edvin

  • Hi Edvin, 

    Thank you for your reply.

    Allow me to add more detail.

    Yes, I expect to get data from  APP_UART_DATA event and I did receive something when the modem boots up (Some string like "APP RDY"). So, if  APP_UART_DATA event will not be triggered, why was I getting some response from the modem in the beginning? 

    I also tried printing  every event in the event handler, but I still failed to receive either APP_UART_DATA_READY or APP_UART_DATA from the modem, except at the beginning.

Reply
  • Hi Edvin, 

    Thank you for your reply.

    Allow me to add more detail.

    Yes, I expect to get data from  APP_UART_DATA event and I did receive something when the modem boots up (Some string like "APP RDY"). So, if  APP_UART_DATA event will not be triggered, why was I getting some response from the modem in the beginning? 

    I also tried printing  every event in the event handler, but I still failed to receive either APP_UART_DATA_READY or APP_UART_DATA from the modem, except at the beginning.

Children
Related