0

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.

Skitzafreak
  • 117
  • 3

2 Answers2

1

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_Pin_7;
    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;
    GPIO_Init(GPIOB,&GPIO_InitStructure);
}

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.

Voltage Spike
  • 82,181
  • 41
  • 84
  • 220
  • 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. – Skitzafreak Apr 05 '18 at 18:09
  • if you use OTYPE_PP (push-pull) then you don't need configure PUPD_DOWN – vlk Apr 08 '18 at 12:38
1

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.

Greenonline
  • 2,109
  • 9
  • 26
  • 40
user220998
  • 11
  • 1