Using the G431RB mounted on the Nucleo board.
Can't port the example code for TIM2 pwm output to TIM1???
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-07-31 03:32 PM
STM32Cube\Repository\STM32Cube_FW_G4_V1.2.0\Projects\NUCLEO-G431RB\Examples_LL\TIM\TIM_PWMOutput
This project runs fine. However, it uses TIM2. I tried to port to TIM1 so I could be interrupted every 10 periods, rather than have to count them in an isr. I did allthe obvious things. Any tricks? My project outputs nothing. I relocated to PA1 from PA5, and made the required changes. No go. What additional init is required for TIM1 that is missing from TIM2?
Solved! Go to Solution.
- Labels:
-
STM32G4 Series
-
TIM
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-07-31 05:57 PM
SET_BIT(TIM1->BDTR, TIM_BDTR_MOE);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-07-31 03:56 PM
> What additional init is required for TIM1 that is missing from TIM2?
For TIM1, the TIMx_BDTR_MOE bit needs set to have a PWM output. Only advanced timers (TIM1/TIM8/TIM20) have this bit.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-07-31 04:05 PM
+1
And TIM2 being 32-bit vs TIM1 16-bit on many STM32
Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-07-31 04:07 PM
If you need to see my version of attempting to port to TIM1, let me know please.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-07-31 04:44 PM
> If you need to see my version of attempting to port to TIM1, let me know please.
Well the MOE bit is the only gotcha. So if it's not that, you have something basic wrong.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-07-31 04:53 PM
Thanks guys. As a long time fan of the Three Stooges (Larry, Curly, and Moe), I should of known!
Once I validate that this is the only Gotcha, I'll update.
These short acronyms get me everytime.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-07-31 05:41 PM
I must be using the wrong include files. Same ones as for TIM2 probably don't work for TIM1? No signs of MOE or TIMx_BDTR
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-07-31 05:57 PM
SET_BIT(TIM1->BDTR, TIM_BDTR_MOE);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-07-31 06:00 PM
Definitely defined in the CMSIS include file: