I'm using this core https://github.com/stm32duino/Arduino_Core_STM32
Any library where I can implement timer interrupts?
STM32 timer interrupt
Re: STM32 timer interrupt
Well timer interrupts are tricky stuff ... but reading the documentation surely helps ...
https://github.com/stm32duino/wiki/wiki ... er-library
https://github.com/stm32duino/wiki/wiki ... er-library
Re: STM32 timer interrupt
As mlundin wrote, check the examples in the HardwareTimer library. The input capture example implements both rollover interrupt and input capture interrupt service routines ("callbacks").
https://github.com/stm32duino/STM32Exam ... putCapture
And again as mlundin wrote, be careful with interrupts, they are more complex to use than non-interrupt code.
https://github.com/stm32duino/STM32Exam ... putCapture
And again as mlundin wrote, be careful with interrupts, they are more complex to use than non-interrupt code.
-
- Posts: 102
- Joined: Thu Feb 27, 2020 7:54 am
- Location: Toronto
Re: STM32 timer interrupt
You can try to use my STM32_TimerInterrupt Library to see if OK for you.
-
- Posts: 36
- Joined: Tue May 09, 2023 10:45 pm
Re: STM32 timer interrupt
khoih-prog I will always take a look at your advices. But my problem is how to register an interrupt vector or pointer from an interrupt event generated by the timer, in my case F1 TIM! or TIM2.
I already tested your library, but it was slow for my purposes and need to have some more control. Maybe because of my own ignorance on this new core, my testing was insufficient, so I will give it a try again. Thank you.
I am working hard to keep it CMSIS coding before I jump to plain C, direct access to registers. HAL is to heavy for my taste.
This is the step I don't know how to solve, It can't be that difficult, but I am not receiving the precise info.
If not, I will switch back to STM32CubeIDE, that I have been using some time ago when I bought my BluePills and ST-Link, and despite the HAL method, I don't have to fight against Arduino IDE, not knowing what resources it is taking for its own purposes, meaning timers for delay(), etc. or if it is still necessary to use AttachInterrupt(), interrupts(), or all of this doesn't work if STM32 is working on the IDE.
I will first will take a look at your library and be back to report. In the meantime, could you please check if there is a grose error I don't see in my code? I would very much apprciate that.
Thank you !
Roberto
I already tested your library, but it was slow for my purposes and need to have some more control. Maybe because of my own ignorance on this new core, my testing was insufficient, so I will give it a try again. Thank you.
I am working hard to keep it CMSIS coding before I jump to plain C, direct access to registers. HAL is to heavy for my taste.
This is the step I don't know how to solve, It can't be that difficult, but I am not receiving the precise info.
The examples you are kindly giving are mostly based based in an F4 or something similar machine (correct me if I'm wrong) , while it takes time to convert and figure out how to adapt your code to the F1 BluePill, with the risk that on top one could do something wrong in the translation. If your library has a simple, straightforward example of a timer interrupting and clearly explaining the method to attach an interrupt handler, I'm going that way and solve the problem.I need a 5 KHz PWM interrupt event generated by the TIM1 or TIM2, with output signal on a pin, say PA8, and an interrupt handler because I need to count pulses on every PWM cycle.
If not, I will switch back to STM32CubeIDE, that I have been using some time ago when I bought my BluePills and ST-Link, and despite the HAL method, I don't have to fight against Arduino IDE, not knowing what resources it is taking for its own purposes, meaning timers for delay(), etc. or if it is still necessary to use AttachInterrupt(), interrupts(), or all of this doesn't work if STM32 is working on the IDE.
I will first will take a look at your library and be back to report. In the meantime, could you please check if there is a grose error I don't see in my code? I would very much apprciate that.
Thank you !
Roberto
Re: STM32 timer interrupt
STM32 examples for timers are for STM32 core, not for a specific MCU. You don't have to adapt anything.
Re: STM32 timer interrupt
Simplify all interrupt programs and reduce the time consumed by interrupt programs.