cancel
Showing results for 
Search instead for 
Did you mean: 

GPIO Alternate Mode Pull Up & Pull Down Function

Odoong
Associate

I tried to solve the questions that occurred during the development of STM32 L4 Series through Googling, but I couldn't find anything related, so I'm leaving a post.

 

I understand that even if the built-in Pull Up or Pull Down circuit is enabled, there is no floating state in the output mode, so Pull Up and Pull Down do not affect the state of the pin.

(Because of P-N MOSFET Circuit Structure. See figure below)

Odoong_0-1723439657092.png

However, when using alternative function output mode, the initial state of pin remains high or low according to the pull up or pull down setting until start the alternative function's output.

(For example, using PWM Output Timer & call the HAL_TIM_PWM_Start() not yet.)

 

So I wonder why pull up & pull down operates differently from output mode, even though the same output controller and P-N MOSFET circuit structure are used in alternative function mode.

 

Thanks.

 

 

1 ACCEPTED SOLUTION

Accepted Solutions

Alternate function mode can be input (TIM channel capture input, SPI MISO,... ), or push-pull output  (TIM channel compare output, SPI MOSI, ...), or open-drain output (I2C which is indeed used bi-directionally).

In the above figure, you see a multiplexor in front of the Output Control block. This multiplexor switches between general purpose (ODR register) control and alternate function control of the pin. And, yes, keeping both mosfets open is a valid option.

hth

KnarfB

View solution in original post

3 REPLIES 3
KnarfB
Principal III

The initial mode of almost all pins after reset is Analog Mode, which is a "passive" input mode, no pull-up, no pull-down, the pin is not driven.

Now, when the firmware starts running and reconfigures a pin, this mode will remain until the firmware changes it by writing to the MODER register.

If you want to configure a general purpose output pin, you have the choice between push-pull type (where pull-up/pull-down are indeed useless) or open-drain, type, where a pull-up might come in handy. 

Same if you want to configure a pin as a timer channel output pin. When you change the pin mode, the pin will be immediately controlled by the timer. The safest way is to configure the timer beforehand such that the pin comes up in the right state when you switch the mode.

I don't see a difference here.

Besides this, pull-up/pull-down are of course usefull for general purpose input mode.

see also AN4899 Application note "STM32 microcontroller GPIO hardware settings and low-power consumption"

hth

KnarfB

 

Thank you for your response. GPIO behavior became more clear to me after Power On operation.

However, there are still questions that remain, and I think this is because I haven't been able to clarify what I'm curious about.

 

As you comment, the pin may be in Analog Mode before firmware running. But, when the firmware starts to run, the value will be written in MODER and the device components will be activated/deactivated and will operate as set by the user.

 

At this time, when set to Output Mode + Push & Pull, as shown in the AN4899 document, one of the P-N MOSFETs opens when one of them is closed, and vice versa, the output value has either 3.3V or 0V, and there is no floating state.

Odoong_0-1723447146386.png

(If the output controller sends the same signal to the GATE signal of the P-N MOSFET, only one of them will be OPEN because the NOT Gate is connected to the P-MOSFET side)

 

So, I didn't understand that Pull Up & Pull Down was operating under those conditions because I thought Alternate Function Mode + Push Pull Mode would operate the same way.

Now, however, I wonder if the output controller is sending output to MOSFET to open both P-MOSFET and N-MOSFET until the output of Alternate Function is started under Alternate Function Mode + Push Pull conditions. Is that correct?

 

 

Alternate function mode can be input (TIM channel capture input, SPI MISO,... ), or push-pull output  (TIM channel compare output, SPI MOSI, ...), or open-drain output (I2C which is indeed used bi-directionally).

In the above figure, you see a multiplexor in front of the Output Control block. This multiplexor switches between general purpose (ODR register) control and alternate function control of the pin. And, yes, keeping both mosfets open is a valid option.

hth

KnarfB