cancel
Showing results for 
Search instead for 
Did you mean: 

I need pin PA6 setup as PWM using tim3 ch1 in cubeMX for F072C8T. Which gpio mode (Alt_Funct_PP or Alt_Funct_OD) should I select for this pin in TIM3 configuration in cubeMX?

JNguyen
Senior
 
8 REPLIES 8
KnarfB
Principal III

You have to choose the right on depending on your external components. PP=push-pull, OD=open-drain. It only affects the type of driver, not the function.

JNguyen
Senior

I need a PWM out from PA6 using TIM3 PWM CH1. Let me ask this way. What does "GPIO Mode" means in TIM_configuration_GPIOSettings in CubeMX?

Does "Alt_Funct" refer to the timer PWM function? if so, it implies the Timer_PWM engine control the pin (in PP or OD fashion) according to GPIO Mode selection, correct?

KnarfB
Principal III

There are 4 GPIO modes: Input, Output, Analog and Alternate Function. Which alternate function is used is defined in the AFR register. If the PA6 AFR entry is programmed to TIM3_CH1, you are right. See Tables 14 and 15 in STM32F072 data sheet.

hth

KnarfB

JNguyen
Senior

I have PWM signal correctly with either Alt_Funct_PP or Alt_Funct_OD selection. PP makes more sense for our application. However, this is interesting, Alt_Funct_PP selection causes problem on Vref for ADC_IN0 (pin PA0). Alt_Funct_OD selection does not. So I want to make sure I understand Alt_Funct_PP, Alt_Funct_OD selections correctly.

TDK
Guru

Most likely you want push-pull.

Push-pull with both pull up the pin to 3.3V when the pin is set and pull down the pin to GND when the pin is reset.

Open drain will only pull down the pin to GND when the pin is reset. When the pin is set, the output will float and you will need an external or internal pullup to bring it to 3.3V if desired. OD is often used when multiple devices are controlling the same line.

If you feel a post has answered your question, please click "Accept as Solution".
JNguyen
Senior

Agree 100% with TDK. Our PWM signal is not shared. My first choice is PP, since I want to have the pin driven at all time. However, PP selection gives me the problem described in my last post. So the problem involves other area.

TDK
Guru

AF_PP is a valid selection for PWM.

> However, this is interesting, Alt_Funct_PP selection causes problem on Vref for ADC_IN0 (pin PA0).

We're not going to be able to debug much with that amount of information. Since it's a different problem than the original post, consider asking it in a new question along with relevant details and closing this one out.

If you feel a post has answered your question, please click "Accept as Solution".
KnarfB
Principal III

In OD the high side mosfet of the GPIO output driver is off all the time. In PP it switches to on when the output is high, connecting Vdd to the external pad. Current will flow with an external load. So you might want to check at external Vdd vs. Vdda routing. Check that the ADC pin is in analog mode. Check also AN2834 Application note How to get the best ADC accuracy in STM32 microcontrollers.

hth

KnarfB