I am doing some work with an STM32F4-Discovery board, and I am trying to get some simple usage out of the GPIO Pins. However there is a weird problem I am having, that I don't know how to fix.

I am using IAR Embedded Workbench as my IDE, and for some reason the only GPIO Pins I seem to be able to enable are those on the B-Bus. If I go to enable a pin on any of the other buses and go to set the pin high and low, the volt meter I have hooked up doesn't register anything.

Additionally, there are a few pins on the board that seem to be stuck at a high voltage, which seems weird to me. Some pins were outputting ~3V before I had even enabled them, or set them high. Are these pins broken? Or is there a way to set them low? Attempting to enable the GPIO Pin and setting it low has not worked for me, so I am unsure of what to do here.


closed as unclear what you're asking by Chris Stratton, bitsmack, JRE, RoyC, Finbarr May 7 at 5:23

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    \$\begingroup\$ Please provide a MCVE and a concrete list of pins you've tested and found stuck low/high. \$\endgroup\$ – berendi Apr 6 '18 at 8:03
  • \$\begingroup\$ I'm voting to close this question because it has been abandoned with critical information missing for over a year and as a result is unanswerable by anything other than guesses. \$\endgroup\$ – Chris Stratton May 2 at 16:50

Make sure you configure the pins properly

> {
    RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOB, ENABLE);
    GPIO_InitTypeDef GPIO_InitStructure;
    GPIO_InitStructure.GPIO_Pin =   GPIO_Pin_0 |
                            GPIO_Pin_1 |
                            GPIO_Pin_2 |
                            GPIO_Pin_3 |
                            GPIO_Pin_4 |
                            GPIO_Pin_5 |
                            GPIO_Pin_6 |
    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
    GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
    GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_DOWN;
    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;

Source: Using I/O ports on STM32

Then write to the port. You could have also burned the pin out or ESD'ed the pin, try a few different ports\pins.

The STM32F's usually configure their ports as high-Z on wakeup/reset, with a high impedance meter its possible to measure anything without setting the pin to a determined output. If you put an external 20k pulldown to ground and still measured 3.3V then I'd believe your meter.

  • \$\begingroup\$ Yeah, I added the 20k pull down to the Pins where I was measuring ~3V without enabling them, and I am still measuring that 3V on my meter. \$\endgroup\$ – Skitzafreak Apr 5 '18 at 18:09
  • \$\begingroup\$ if you use OTYPE_PP (push-pull) then you don't need configure PUPD_DOWN \$\endgroup\$ – vlk Apr 8 '18 at 12:38

Some pins have alternate functions for the JTAG and SW interfaces. JTAG pins are pulled up or pulled down at reset. To use those pins you have to configure the AFIO_MAPR register, or define a macro according to compiler.


Not the answer you're looking for? Browse other questions tagged or ask your own question.