I'm using 4 LEDs connected to different pins on STM32F4 Discovery: PA6, PD8, PH0, PD1. All of these pins have been configured as output with same function:

void initPins(uint32_t ahb_gpio, GPIO_TypeDef * gpio, uint16_t gpio_pin)
    GPIO_InitTypeDef GPIO_InitDef;
    RCC_AHB1PeriphClockCmd(ahb_gpio, ENABLE);
    GPIO_InitDef.GPIO_Pin = gpio_pin;
    GPIO_InitDef.GPIO_Mode = GPIO_Mode_OUT;
    GPIO_InitDef.GPIO_OType = GPIO_OType_PP;
    GPIO_InitDef.GPIO_Speed = GPIO_Speed_100MHz;
    //Initialize pins
    GPIO_Init(gpio, &GPIO_InitDef);


initPins(RCC_AHB1Periph_GPIOA, GPIOA, GPIO_Pin_6);
initPins(RCC_AHB1Periph_GPIOD, GPIOD, GPIO_Pin_8);
initPins(RCC_AHB1Periph_GPIOH, GPIOH, GPIO_Pin_0);
initPins(RCC_AHB1Periph_GPIOD, GPIOD, GPIO_Pin_1);

The three pins on GPIOA and GPIOD work as they should, but I can't get pin on GPIOH to work. I tried also connecting 5th LED to PH1 and configuring it as output but it's no use, it won't work either. I also tried using TM GPIO library to configure pins:

    GPIO_Pin_0 | GPIO_Pin_1,

but it won't work either. I see these two pins can be used also for oscillator. Is that interfering with their configuration? Does anybody know why these pins are not working?

  • \$\begingroup\$ Are they open drain outputs? \$\endgroup\$ – Andy aka Jan 31 '17 at 14:37
  • \$\begingroup\$ @Andyaka You mean if they only support open drain? Because I configured them as PushPull. \$\endgroup\$ – Terraviper-5 Jan 31 '17 at 16:29
  • \$\begingroup\$ I would suggest to generate start-up code with STM32CubeMX and compare your clock configuration code with generated one. Remember to set PH0 and PH1 as output in CubeMX \$\endgroup\$ – Flanker Jan 31 '17 at 16:57
  • \$\begingroup\$ @Flanker I seem to not be able to use anything but HAL drivers with STMCubeMX. \$\endgroup\$ – Terraviper-5 Jan 31 '17 at 17:31
  • \$\begingroup\$ Yes, but HAL is just a wrapper over CMSIS like SPL, you can follow the functions and structures to locate the difference \$\endgroup\$ – Flanker Jan 31 '17 at 20:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.