# Aren't pull-up / pull-down options documented for STM32F103?

While trying to configure the GPIOs using CMSIS on a NUCLEO-F103RB board, I couldn't seem to find in the reference manual how one is supposed to choose between internal pull-up and pull-down resistors.

Page 160 shows the configuration of the CNF and MODE bits and shows that the bits are the same for pull-up and pull-down. Searching the entire PDF file for "pull-up" and "pull-down" yields no results. The errata also has no mention of this.

Did ST seriously forget to put this information in the manual? If so, how come no one has noticed this? Or am I just being blind?

Anyway, looking at their standard peripheral library, it seems that writing a 1 to the corresponding bit in the GPIO BRR register activates the pull-down resistor, while writing a 1 to the BSRR actives the pull-up resistor:

    /* Reset the corresponding ODR bit */
if (GPIO_InitStruct->GPIO_Mode == GPIO_Mode_IPD)
{
GPIOx->BRR = (((uint32_t)0x01) << pinpos);
}
else
{
/* Set the corresponding ODR bit */
if (GPIO_InitStruct->GPIO_Mode == GPIO_Mode_IPU)
{
GPIOx->BSRR = (((uint32_t)0x01) << pinpos);
}
}


This code can be found in the stm32f10x_gpio.c file.

The information you are looking for is in the manual, but not as obvious as it could be. The table you mentioned on page 160 contains more info:

As you can see, assuming the pin is configured as an input, the value in the ODR registers is the deciding factor as to whether the pin is pull-up or pull-down.

You can set and/or clear all these bits at once by writing a 16-bit value to the appropriate GPIOx_ODR register, or you can set/reset them individually by using the GPIOx_BRR and/or GPIOx_BSRR registers.

Interestingly, the same ODR register controls the pin state (high or low) when the pin is configured as an output.

I've found that I can sometimes learn more about the workings of the STM ARM controllers by reading through their Standard Peripheral Libraries than their reference manuals!

• I like how it was right in front of my eyes and even though I looked at that table so many times I still couldn't see it. facepalm. Thank you.
– Chi
Jan 17, 2017 at 9:01
• @Chi Ha! That happens to me more than I like to admit :) Jan 17, 2017 at 15:01