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_PuPd = GPIO_PuPd_NOPULL;
    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:

TM_GPIO_Init(
    GPIOH,
    GPIO_Pin_0 | GPIO_Pin_1,
    TM_GPIO_Mode_OUT,
    TM_GPIO_OType_PP,
    TM_GPIO_PuPd_NOPULL,
    TM_GPIO_Speed_High
    );

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?

  • Are they open drain outputs? – Andy aka Jan 31 '17 at 14:37
  • @Andyaka You mean if they only support open drain? Because I configured them as PushPull. – Terraviper-5 Jan 31 '17 at 16:29
  • 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 – Flanker Jan 31 '17 at 16:57
  • @Flanker I seem to not be able to use anything but HAL drivers with STMCubeMX. – Terraviper-5 Jan 31 '17 at 17:31
  • Yes, but HAL is just a wrapper over CMSIS like SPL, you can follow the functions and structures to locate the difference – Flanker Jan 31 '17 at 20:13

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.