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

How to enable the uarte RXDRDY interrupt?

Hi, All!

I am using nRF52832, the uart0 tx/rx works well, but the uarte0 can send bytes, but can not receive any bytes. The code as follows, could you help me please?

   #define YTALK_PIN    28

    // gpio
    nrf_gpio_cfg_input(YTALK_PIN, NRF_GPIO_PIN_NOPULL);
    // uarte
    nrf_uarte_txrx_pins_set(NRF_UARTE0, NRF_UARTE_PSEL_DISCONNECTED, YTALK_PIN);
    nrf_uarte_baudrate_set(NRF_UARTE0, UARTE_BAUDRATE_BAUDRATE_Baud115200);
    nrf_uarte_configure(NRF_UARTE0, NRF_UARTE_PARITY_EXCLUDED, NRF_UARTE_HWFC_DISABLED);
    nrf_uarte_enable(NRF_UARTE0);
    
    nrf_uarte_event_clear(NRF_UARTE0, NRF_UARTE_EVENT_RXDRDY);
    nrf_uarte_int_enable(NRF_UARTE0, NRF_UARTE_INT_RXDRDY_MASK);
  
    nrf_uarte_rx_buffer_set(NRF_UARTE0, ytalk_rx_buffer, 10);
    nrf_uarte_task_trigger(NRF_UARTE0, NRF_UARTE_TASK_STARTRX); 


    NVIC_SetPriority(UART0_IRQn, configLIBRARY_LOWEST_INTERRUPT_PRIORITY);
    NVIC_ClearPendingIRQ(UART0_IRQn);
    NVIC_EnableIRQ(UART0_IRQn);

void UART0_IRQHandler(void)
{
    if(nrf_uarte_event_check(NRF_UARTE0, NRF_UARTE_EVENT_RXDRDY)) {
        nrf_uarte_event_clear(NRF_UARTE0, NRF_UARTE_EVENT_RXDRDY);
        nrf_gpio_pin_toggle(29);
        nrf_uarte_task_trigger(NRF_UARTE0, NRF_UART_TASK_STARTRX);
    }
}
    
  

Parents Reply Children
  • No, You should not use instances that share the same peripheral ID at the same time.  Here you can see that both UART0 and UARTE0 has same instance ID of 2.

    Shared resources
    The UARTE shares registers and other resources with other peripherals that have the same ID as the UARTE.
    
    Therefore, you must disable all peripherals that have the same ID as the UARTE before the UARTE can be configured and used. Disabling a peripheral that has the same ID as the UARTE will not reset any of the registers that are shared with the UARTE. It is therefore important to configure all relevant UARTE registers explicitly to ensure that it operates correctly.
    
    See the Instantiation table in Instantiation for details on peripherals and their IDs.

     

  • That explains a lot, my problem has been solved, thank you very much!

Related