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

Interrupt priority on UART

Hi

I try to understand where does the interrupt proirity for UART is set.

I see that uarte_1_init() is called from uart_nrfx_uarte.c.

uarte_1_init() is declared from UART_NRF_UARTE_DEVICE(idx)

static int uarte_##idx##_init(const struct device *dev) \
{ \
const struct uarte_init_config init_config = { \
.pseltxd = UARTE_PROP(idx, tx_pin), /* must be set */ \
.pselrxd = UARTE_PSEL(idx, rx_pin), /* optional */ \
.pselcts = UARTE_PSEL(idx, cts_pin), /* optional */ \
.pselrts = UARTE_PSEL(idx, rts_pin), /* optional */ \
}; \
COND_CODE_1(CONFIG_UART_##idx##_ASYNC, \
(UARTE_IRQ_CONFIGURE(idx, uarte_nrfx_isr_async);), \
(UARTE_IRQ_CONFIGURE(idx, uarte_nrfx_isr_int);)) \
return uarte_instance_init( \
dev, \
&init_config, \
IS_ENABLED(CONFIG_UART_##idx##_INTERRUPT_DRIVEN)); \
} \

there UARTE_IRQ_CONFIGURE() is used.

#define UARTE_IRQ_CONFIGURE(idx, isr_handler) \
do { \
IRQ_CONNECT(DT_IRQN(UARTE(idx)), DT_IRQ(UARTE(idx), priority), \
isr_handler, DEVICE_DT_GET(UARTE(idx)), 0); \
irq_enable(DT_IRQN(UARTE(idx))); \
} while (0)

But where is priority defined?

Thanks for an explanation?

Parents
  • Hello, Canastra!

    The priority parameter is passed from the Device Tree node of the UARTE, together with other parameters for the peripheral. Specifically it's a part of the interrupts parameter under "Base properties". The default value for the interrupts parameter is NRF_DEFAULT_IRQ_PRIORITY (translates to 1) assigned in the DTSI of the specific device that is used. You can change the interrupt priority using a DTS overlay in your application. Looking, for example, like this:

    &uart1 {
    	interrupts = <2 NRF_DEFAULT_IRQ_PRIORITY>;
    };

    Hope this makes things more clear!

    Best regards,
    Carl Richard

Reply
  • Hello, Canastra!

    The priority parameter is passed from the Device Tree node of the UARTE, together with other parameters for the peripheral. Specifically it's a part of the interrupts parameter under "Base properties". The default value for the interrupts parameter is NRF_DEFAULT_IRQ_PRIORITY (translates to 1) assigned in the DTSI of the specific device that is used. You can change the interrupt priority using a DTS overlay in your application. Looking, for example, like this:

    &uart1 {
    	interrupts = <2 NRF_DEFAULT_IRQ_PRIORITY>;
    };

    Hope this makes things more clear!

    Best regards,
    Carl Richard

Children
Related