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

UARTE can't receive data

I've been playing around with the UART drivers on SDK 15.2.  No issues with the Legacy (w/DMA) however I've tried switching over the NRFX_UARTE driver and I can't get the driver to Recieve data.  The Rx Event is never called in the handler, nor does nrfx_uarte_rx_ready() ever return true?   The only real difference in the driver API's is the legacy driver has the nrf_drv_uart_rx_enable(.) call which isn't in the NRFX_UARTE module.  Is there anything I could have missed that would prevent data receiving on this driver?

p.s. in the sdk_config file I did enabled NRFX_UARTE and NRFX_UARTE0.  Also commented out the Legacy #defines as per requirements for other drivers

Parents
  • Hi,

    Can you post the code you used for configuring UARTE, and setting up the transfers? I'm not sure what the purpose of the function nrfx_uarte_rx_ready() is in the driver, to me it seems that using this function only makes sense to use together with nrfx_uart_rx_enable() in the legacy UART driver for polling UART.

    Best regards,
    Jørgen

  • Did you set the pins in the config? By default, these are set to NRF_UARTE_PSEL_DISCONNECTED.

    I tested this similar code, and I'm able to receive data in the event handler:

    #define UART_RX_BUF_SIZE 10
    static uint8_t my_uart_rx_buffer_assigned[UART_RX_BUF_SIZE] = {0x00};
    
    
    static void my_uarte_event_handler(nrfx_uarte_event_t const * p_event,
                                  void *                     p_context)
    {
        if(p_event->type == NRFX_UARTE_EVT_RX_DONE)
        {
            memset(my_uart_rx_buffer_assigned, 0x00, UART_RX_BUF_SIZE);
        }
    }
    
    int main(void)
    {
        bsp_board_init(BSP_INIT_LEDS);
        nrfx_uarte_t instance = NRFX_UARTE_INSTANCE(0);
        static nrfx_uarte_config_t my_uarte_config = NRFX_UARTE_DEFAULT_CONFIG;
        my_uarte_config.pselrxd = 8;
        my_uarte_config. pseltxd = 6;
    
    
        ret_code_t err_code = nrfx_uarte_init( &instance, &my_uarte_config ,  my_uarte_event_handler );
    
        APP_ERROR_CHECK(err_code);
    
        err_code = nrfx_uarte_rx( &instance,
        (uint8_t*)my_uart_rx_buffer_assigned,
        UART_RX_BUF_SIZE);
        APP_ERROR_CHECK(err_code);
        
    
        while (true) 
        {
            __WFE();
        }
    }

Reply
  • Did you set the pins in the config? By default, these are set to NRF_UARTE_PSEL_DISCONNECTED.

    I tested this similar code, and I'm able to receive data in the event handler:

    #define UART_RX_BUF_SIZE 10
    static uint8_t my_uart_rx_buffer_assigned[UART_RX_BUF_SIZE] = {0x00};
    
    
    static void my_uarte_event_handler(nrfx_uarte_event_t const * p_event,
                                  void *                     p_context)
    {
        if(p_event->type == NRFX_UARTE_EVT_RX_DONE)
        {
            memset(my_uart_rx_buffer_assigned, 0x00, UART_RX_BUF_SIZE);
        }
    }
    
    int main(void)
    {
        bsp_board_init(BSP_INIT_LEDS);
        nrfx_uarte_t instance = NRFX_UARTE_INSTANCE(0);
        static nrfx_uarte_config_t my_uarte_config = NRFX_UARTE_DEFAULT_CONFIG;
        my_uarte_config.pselrxd = 8;
        my_uarte_config. pseltxd = 6;
    
    
        ret_code_t err_code = nrfx_uarte_init( &instance, &my_uarte_config ,  my_uarte_event_handler );
    
        APP_ERROR_CHECK(err_code);
    
        err_code = nrfx_uarte_rx( &instance,
        (uint8_t*)my_uart_rx_buffer_assigned,
        UART_RX_BUF_SIZE);
        APP_ERROR_CHECK(err_code);
        
    
        while (true) 
        {
            __WFE();
        }
    }

Children
No Data
Related