Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-evaluate interrupt priority values #472

Closed
benwaffle opened this issue Mar 15, 2019 · 1 comment · Fixed by #503
Closed

Re-evaluate interrupt priority values #472

benwaffle opened this issue Mar 15, 2019 · 1 comment · Fixed by #503

Comments

@benwaffle
Copy link
Contributor

benwaffle commented Mar 15, 2019

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.

@fpistm
Copy link
Member

fpistm commented Mar 15, 2019

It's funny, I just watched this point this week. I even asked @LMESTM what were the rules on mbed if any :)

In a general way, I think, only systick should be at 0.

@fpistm fpistm self-assigned this Mar 15, 2019
@fpistm fpistm added this to To do in STM32 core based on ST HAL via automation Mar 15, 2019
fpistm added a commit to fpistm/Arduino_Core_STM32 that referenced this issue Apr 19, 2019
Can be redefined thanks variant.h or build_opt.h
Fix stm32duino#472

Signed-off-by: Frederic.Pillon <frederic.pillon@st.com>

[USBD] Allow IRQ priority redefinition

Signed-off-by: Frederic.Pillon <frederic.pillon@st.com>
fpistm added a commit to fpistm/Arduino_Core_STM32 that referenced this issue Apr 19, 2019
Can be redefined thanks variant.h or build_opt.h
Fix stm32duino#472

Signed-off-by: Frederic.Pillon <frederic.pillon@st.com>
STM32 core based on ST HAL automation moved this from To do to Done Apr 21, 2019
fpistm added a commit that referenced this issue Apr 21, 2019
Can be redefined thanks variant.h or build_opt.h
Fix #472

Signed-off-by: Frederic.Pillon <frederic.pillon@st.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

Successfully merging a pull request may close this issue.

2 participants