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

Using UARTE0 and UARTE1 in different pins ?

Dear Members,

I saw this example,

https://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.sdk5.v15.2.0%2Fserial_uartes_example.html

I can not find this example on SDK 17,

How can I use UARTE0 and UARTE1 on separate port ? one is for debugging via USB and the other one for communicating with GPS UART ?

Any suggestions ?

Thanks

  • then

    err_code = nrf_libuarte_async_init(&libuarte, &nrf_libuarte_async_config1, uart_event_handler1, (void *)&libuarte);

    void uart_event_handler1(void * context, nrf_libuarte_async_evt_t * p_evt)
    {
        
    }    

    ?

  • Please correct me, it's not responding when I run libuarte1 :

    NRF_LIBUARTE_ASYNC_DEFINE(libuarte, 0, 0, 0, NRF_LIBUARTE_PERIPHERAL_NOT_USED, 255, 3);
    NRF_LIBUARTE_ASYNC_DEFINE(libuarte1, 1, 0, 0, NRF_LIBUARTE_PERIPHERAL_NOT_USED, 255, 3);
    
    
    nrf_libuarte_async_config_t nrf_libuarte_async_config = {
                .tx_pin     = TX_PIN_NUMBER,
                .rx_pin     = RX_PIN_NUMBER,
                .baudrate   = NRF_UARTE_BAUDRATE_115200,
                .parity     = NRF_UARTE_PARITY_EXCLUDED,
                .hwfc       = NRF_UARTE_HWFC_DISABLED,
                .timeout_us = 100,
                .int_prio   = APP_IRQ_PRIORITY_LOW
        };
            
            nrf_libuarte_async_config_t nrf_libuarte_async_config1 = {
                .tx_pin     = SER_APP_TX_PIN,
                .rx_pin     = SER_APP_RX_PIN,
                .baudrate   = NRF_UARTE_BAUDRATE_9600,
                .parity     = NRF_UARTE_PARITY_EXCLUDED,
                .hwfc       = NRF_UARTE_HWFC_DISABLED,
                .timeout_us = 100,
                .int_prio   = APP_IRQ_PRIORITY_LOW
        };
    
    
    err_code = nrf_libuarte_async_init(&libuarte, &nrf_libuarte_async_config, uart_event_handler, (void *)&libuarte);
            err_code = nrf_libuarte_async_init(&libuarte1, &nrf_libuarte_async_config1, uart_event_handler1, (void *)&libuarte1);

  • Hi,

    Have you enabled the second instance of the UARTE in the config file?  

    RixtronixLAB said:
    it's not responding when I run libuarte1

     Be more specific. What exactly happens? What does the init function return? Use the debugger and see if the application asserts somewhere. 

    regards

    Jared 

  • I have enabled UARTE1 1

    //==========================================================
    
    // <h> nrf_libuarte_drv - libUARTE library
    
    //==========================================================
    // <q> NRF_LIBUARTE_DRV_HWFC_ENABLED  - Enable HWFC support in the driver
     
    
    #ifndef NRF_LIBUARTE_DRV_HWFC_ENABLED
    #define NRF_LIBUARTE_DRV_HWFC_ENABLED 0
    #endif
    
    // <q> NRF_LIBUARTE_DRV_UARTE0  - UARTE0 instance
     
    
    #ifndef NRF_LIBUARTE_DRV_UARTE0
    #define NRF_LIBUARTE_DRV_UARTE0 1
    #endif
    
    // <q> NRF_LIBUARTE_DRV_UARTE1  - UARTE1 instance
     
    
    #ifndef NRF_LIBUARTE_DRV_UARTE1
    #define NRF_LIBUARTE_DRV_UARTE1 1
    #endif
    
    // </h> 
    //==========================================================

  • err_code = nrf_libuarte_async_init(&libuarte, &nrf_libuarte_async_config, uart_event_handler, (void *)&libuarte);
    err_code = nrf_libuarte_async_init(&libuarte1, &nrf_libuarte_async_config1, uart_event_handler1, (void *)&libuarte1);

Related