Skip to content

Re-evaluate interrupt priority values #472

Closed
@benwaffle

Description

@benwaffle

I am unable to use uart (via printf) in interrupt handlers such as the i2c handler (via Wire.onRequest).

Describe the solution you'd like
I am not sure about all the supported devices, but on the STM32F103, the subpriority is ignored because NVIC_PRIORITYGROUP_4 is used. Currently, the I2C interrupts are set to preemption priority 0. The USART1 preemption priority is also 0. This means that using UART in an interrupt handler will never exit, because HAL_UART_Transmit requires the USART interrupt.

On the other hand, this may be a good idea because using printf() inside an interrupt handler is slow, but interrupt handlers should be really fast.

Currently I can manually do this:

Wire.begin(0x50);
HAL_NVIC_SetPriority(I2C1_ER_IRQn, 1, 0);
HAL_NVIC_SetPriority(I2C1_EV_IRQn, 1, 0);
HAL_NVIC_SetPriority(USART1_IRQn, 0, 0); // usart now has higher priority than i2c

Perhaps we should take a look at all of the interrupt priorities in the code base and decide on a global ordering.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions