-2

I want to build a project with an STM32G070.

I need a couple of PWM pins.

I look at the datasheet and user manual, and I cannot find anywhere if all pins of if only some are PWM capable and so, which one it is.

I want to know because, if I look at the BluePill, not all pins are PWM.

Can Anyone guide me ?

Wimateeka
  • 2,474
  • 2
  • 16
  • 32
Nitrof
  • 121
  • 1
  • 3
  • 15
  • PWM functionality is carried out by timers on the STM32. So look at the [reference manual](https://www.st.com/resource/en/reference_manual/rm0454-stm32g0x0-advanced-armbased-32bit-mcus-stmicroelectronics.pdf) and look at the timers. Most of them have one or more channels that can do PWM output on a pin. – pmacfarlane Feb 05 '23 at 18:26
  • 1
    Also look at table 12 in the [datasheet](https://www.st.com/resource/en/datasheet/stm32g050c6.pdf). Check out the alternate functions of the pins. Any one that says `TIMx_CHy` is a pin that could be used for PWM. – pmacfarlane Feb 05 '23 at 18:29
  • Thank. I have seen about PWM into timer section but I did not understand the relation with TIMx_CHy. Also to complete information, some pin a also mark with a N ( TIM1_CH1N ). Is that PWM PWM too? – Nitrof Feb 05 '23 at 19:20
  • Yes, some channels have positive and negative PWM outputs. The N version is just the logical NOT of the regular version, I think. (I've never used it.) – pmacfarlane Feb 05 '23 at 19:39
  • Last question, because the timer section of the user manual is pretty long and complete.. lol, : Some pin share the same TIMx_CHy, could they be use at the same time in PWM mode? Not changing the mode or frequency, just the duty cycle ? Thanks – Nitrof Feb 06 '23 at 01:09
  • 1
    Each pin can only have one timer channel. And each timer channel should be assigned to one pin. If you want multiple PWM outputs at the same frequency but with different duty-cycles, that is why there are multiple channels per timer. – pmacfarlane Feb 06 '23 at 07:37

1 Answers1

0

To answer the question - no, not all pins can be configured for PWM. However, most STM32s (including the STM32G070) have multiple timers, many with multiple channels which can generate PWM signals, and these can be mapped to many pins. So it's almost guaranteed that you'll find two spare pins that are not used by other peripherals, that you can use for PWM.

As mentioned, PWM signals are generated by timers. You can consult the reference manual for the STM32G070 to see which timers are available, and which ones have channels that can generate PWM signals. And you can reference the datasheet to see which pins they can be mapped to.

If I was designing a board, I'd create (e.g. in STM32CubeIDE) the crucial peripherals first (e.g. any SPI, I2C, UARTs, etc.) Then I'd see which pins are left over that could be used for PWM. There are bound to be several.

pmacfarlane
  • 3,057
  • 1
  • 7
  • 24