Problem description:
I failed to output PWM with PA7 and PA8 at the same time, but I succeeded in output PWM with PA7 or PA8 alone. Why? How to solve it?
Added:
I use STM32G030C8T6 and arduino IDE2.2.1.
As shown in the figure below, I guess the default PWM timer of PA7 and PA8 is TIM1, which leads to the above problem. Then how to change the default PWM timer of PA7, for example, to TIM3_CH2?
I failed to output PWM with PA7 and PA8 at the same time
-
- Posts: 7
- Joined: Tue Jan 23, 2024 6:52 am
Re: I failed to output PWM with PA7 and PA8 at the same time
PA7 have several other TIM:
https://github.com/stm32duino/Arduino_C ... .c#L95-L99
Simply use the suffixed _ALTx naming, example to use TIM3, use PA7_ALT1.
analogWrite(PA7_ALT1, 128);
https://github.com/stm32duino/Arduino_C ... .c#L95-L99
Simply use the suffixed _ALTx naming, example to use TIM3, use PA7_ALT1.
analogWrite(PA7_ALT1, 128);
-
- Posts: 7
- Joined: Tue Jan 23, 2024 6:52 am
Re: I failed to output PWM with PA7 and PA8 at the same time
非常感谢你!
Thank you very much!
Thank you very much!
-
- Posts: 7
- Joined: Tue Jan 23, 2024 6:52 am
Re: I failed to output PWM with PA7 and PA8 at the same time
analogWriteFrequency(1000);is to set the frequency of all PWM, how to set the frequency of 1 pin separately
Re: I failed to output PWM with PA7 and PA8 at the same time
analogWriteFrequency(); changes frequency for next use of analogWrite(), but it will change frequency for all channels on a timer.changlin1990 wrote: Wed Jan 24, 2024 2:25 am analogWriteFrequency(1000);is to set the frequency of all PWM, how to set the frequency of 1 pin separately
If you use 2 or more pins that use same timer for PWM, frequency will change on all of those pins.
One timer - one frequency.
If you want to use different frequencies, you need to use pins on different timers.