stm32f0xx-hal icon indicating copy to clipboard operation
stm32f0xx-hal copied to clipboard

Cannot acknowledge timer interrupt flag

Open mcbridejc opened this issue 2 years ago • 0 comments

I'm attempting to use a periodic timer using the HAL Timer driver, on an stm32f031, and have hit a limitation.

I can instantiate it and use the driver to setup the desired overflow rate, and then turn on the interrrupt -- so that's easy enough:

let timer = hal::timers::Timer::<pac::TIM16>::tim16(cx.device.TIM16, 1.khz(), &mut rcc);
timer.listen(hal::timers::Event::TimeOut);

I can then create a handler for the TIM16 vector... but now I need to clear the UIF flag, and the only way I can come up with to do it is to steal another copy of the TIM16 register block. One solution is that probably the driver should provide a way to clear the interrupt flags, but it seems to me that a more general solution is to make the tim field (the reg block) public so that if I have a mutable Timer I can manipulate it's registers as well -- this allows for more general extensions of the driver as well as simply clearing the interrupt flag.

Perhaps I am missing something about the intended use here. I'm fairly new to Rust still -- still trying to adapt from C++.

mcbridejc avatar Jun 08 '22 19:06 mcbridejc