rtic-rs / rtic

Real-Time Interrupt-driven Concurrency (RTIC) framework for ARM Cortex-M microcontrollers

Home Page:https://rtic.rs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

rtic-monotonic on stm32 TIM20 or TIM17

govert-overgaauw-ampel opened this issue · comments

Hi,

I am currently working on a micro-controller project running RTIC on STM32G4. We are using 21 timer channel outputs for PWM. So I i have not a lot of options for using RTIC monotonic except for TIM17 or TIM20. Systick is not an option I require some small delays, so the tick rate needs to be faster.

I tried implementing TIM20 based on the existing implementations, however TIM20 has seperate IRQs for TIM_UP and TIM_CC. This leads to a race condition that triggers the panic "monotonic must have missed an interrupt!". I am not well versed in all the nuances required to implement the monotonic timers. Is it possible with two hardware IRQs instead of one hardware timer IRQ? The abstraction layers only has a single on_interrupt call so both IRQs trigger the same function and check the flags.

TIM17 is another option, however this timer only has a single capture compare, and the current implementations use two capture compares. One for the half period interrupt, and one is set by rtic-monotonics set_compare, enable/disable calls but I am not sure about the functionality and if this is required?

AFAIK this was fixed by #960, so it can be closed I think?