What determines polarity of PWM?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-11-09 12:01 PM
I am finding the documentation to be very difficult to parse through and had a few questions:
- I have PWM set up using TIM2 and one on TIM1. There are no interrupts. I initialized it using CubeMX. Based on my understanding I expect that the output to be low until CCR1 then remain high until ARR but I seem to be having the opposite happening. How do I flip this?
- Where are example programs....I am new to this and have installed CubeMx but nowhere do I seem to be able to access basic examples for each target to be able to get a feel for how things work? (This is very frustrating)
- Labels:
-
STM32CubeMX
-
TIM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-11-09 12:16 PM
Which STM32?
There are two PWM modes, differing in polarity. Read description of TIMx_CCMR1.OC1M in TIM chapter of RM.
Moreover, polarity of PWM can be switched also by setting TIMx_CCER.CCxP. Again, read description of that bit in RM.
Examples are in the directory where Cube (the "library") is installed; there's a "Projects" subdirectory there, and there are examples organized by individual development board. Cube (the "library") is available also on github, for example for examples for the classic 'F4 Disco board you would go to https://github.com/STMicroelectronics/STM32CubeF4/tree/master/Projects/STM32F4-Discovery/Examples
JW
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-11-09 1:02 PM
Some things are hidden, but I think channel polarity is pretty clearly displayed in the interface. Even if you don't know what "high" means exactly, it should be clear the "low" would flip it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-11-09 2:33 PM
Yes I was able to 'guess ' HIGH or LOW but it seems that by changing to PWM1 or PWM2 you get the same results....Not sure why all the bells and whistles
As far as my directory I have no "library" where STM32CubeIDE resides:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-11-09 2:58 PM
> Not sure why all the bells and whistles
The timers are quite complicated. The reference manual, as JW suggests, will let you see the internals if that is what you're interested in.
The Cube repository is stored within C:\Users\USERNAME\STM32Cube\Repository by default.
Timer capabilities are different on different families of chips. It helps if you include your STM32 chip number in your question so the answers can be more relevant.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-11-09 5:19 PM
PMW1 vs PWM2 relates to the phase and whether the signal starts High or Low at zero degrees, and switches at the phase comparison point of the cycle
Tends to be of more consequence when you have multiple channels, and you need duty/phase relationships between them.
The TIM in the STM32 are both frustratingly complex and poorly executed.
Up vote any posts that you find helpful, it shows what's working..
