Author Topic: STM32 pins for 2 PWM signals in phase and 180 out of phase  (Read 225 times)

0 Members and 1 Guest are viewing this topic.

Offline ricko_ukTopic starter

  • Super Contributor
  • ***
  • Posts: 1049
  • Country: gb
Hi,
I am new to STM32 and am using a STM32L452RET6 to generate two PWM signals so that they can be configured via software to sometimes work in phase with each other (as if they are the same signal) and some other times to work 180 out of phase (when one is low the other is high and viceversa).

I am currently using PA0 to generate the first PWM. But looking at the datasheet I am not sure which mode and pin could be used for a complimentary signal that could also be in phase just by different configuration.

Could someone please point me in the right direction?

If for some reason it is preferred to use another pair of pins, could you please suggest which ones.

Thank you ‌
« Last Edit: May 29, 2024, 11:30:32 pm by ricko_uk »
 

Offline thm_w

  • Super Contributor
  • ***
  • Posts: 6713
  • Country: ca
  • Non-expert
Re: STM32 pins for 2 PWM signals in phase and 180 out of phase
« Reply #1 on: May 30, 2024, 12:02:00 am »
You can use STM32Cube to look at pin functions. Click on Timers then TIM1 on the left side.
You could use TIM1_CH1 and TIM1_CH1N, then you only need to set the Polarity and one will be inverted from the other or not.

Its also possible to just use another PWM channel, then set the settings for each one to be the same, other than Polarity, eg:
PA0 = TIM2_CH1. PA1, TIM2_CH2.
Profile -> Modify profile -> Look and Layout ->  Don't show users' signatures
 
The following users thanked this post: ricko_uk

Offline ricko_ukTopic starter

  • Super Contributor
  • ***
  • Posts: 1049
  • Country: gb
Re: STM32 pins for 2 PWM signals in phase and 180 out of phase
« Reply #2 on: May 30, 2024, 11:35:08 am »

Thank you thm_w
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf