-
Notifications
You must be signed in to change notification settings - Fork 54
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
TIM1/TIM8 PWM mode not working on STM32L476 #42
Comments
I don't have an answer yet, but am suspicious this is related to them being "advanced control timers". I suspect I'm omitting a step. (Have not used them myself) Are you able to use TIM1 or TIM8 for anything, like triggering an interrupt, or reading its value? |
I was thinking the same, I tried to compare how your hal and stm32-rs/stm32l4xx-hal init. this peripheral but it wasn't easy for me to do so with all the macros. I'll go through the reference manual and check what's missing. I did read the counter value in the loop at some point, I could see it incrementing and resetting:
|
Interesting. I suspect then it has to do with how it's being configured for PWM. I also skimmed the L4xx code - of note, they don't impl TIM1 or 8 for normal timers, and for PWM, TIM1 doesn't appear to be diff from the other ones. |
OK, found something relevant in L4xx hal. Try adding this after timer setup, and see if it works. If it does, I'll update this lib. I haven't checked what these do, but noticed L4xx has this for advanced control timers: let TIM8 = unsafe { &(*PAC::TIM8::ptr()) };
TIM8.bdtr.write(|w| w.moe().set_bit());
TIM8.egr.write(|w| w.ug().set_bit()); |
That did the trick!
That makes sense. Thanks a lot! |
Nice. Fixed on GH. Could you please let me know if that works now without adding that workaround to your code? |
Nvm, issues with this fix for now; need to figure out the best way to do it |
Alright, let me know when it's ready to test! |
Added to errata for now; fix would be more macro mess. |
Hi,
I've been trying to use TIM1 and TIM8 advanced timers on STM32L476 but there seems to be an issue.
The following example doesn't output anything on PC6:
But changing the PWM related lines to use TIM3 on the same PC6 pin works:
Trying to use TIM1 with stm32-rs/stm32l4xx-hal works fine (I couldn't use TIM8, for some reason it doesn't seem implemented):
The text was updated successfully, but these errors were encountered: