Skip to main content
Visitor II
October 16, 2020
Solved

Cannot get STM32MP157C-DK2 LED 7 flashing from STM32

  • October 16, 2020
  • 2 replies
  • 1056 views

Trying and failing to toggle LED 7 of the STM32MP157C-DK2 from the STM32. The IOC file indicates that PH7 is configured as GPIO. The mode is Output Push Pull, the GPIO Pull-up/Pull-down state is No pull-up and no-pull-down. The Maximum output speed is Low. I have added the following lines to the following lines to main.c:

while (1)

{

HAL_GPIO_TogglePin(GPIOH, GPIO_PIN_7);

HAL_Delay(1000);

  /* USER CODE END WHILE */

The code is executing but the LED is not changing state. I looked in the MX_GPIO_Init() on the STM32 side and there appears to be no code to setup the GPIO port:

static void MX_GPIO_Init(void)

{

 /* GPIO Ports Clock Enable */

 __HAL_RCC_GPIOC_CLK_ENABLE();

 __HAL_RCC_GPIOH_CLK_ENABLE();

}

I looked in the CA7 side at the kernel dts file and could find no reference to GPIO H7. From what I read in the documentation I thought the STM32CubeIDE was supposed to generate the setup code for this port. I am using the OpenSTL v2.0.0 Starter Kit image.

Does anyone have any clue how to resolve this problem?

    This topic has been closed for replies.
    Best answer by PatrickF

    For pure GPIOs (i.e. not assigned to a functional IP), you should assign to Cortex-M4 using right-click:

    0693W000004KHEuQAO.png

    2 replies

    AStev.2Author
    Visitor II
    October 16, 2020

    The LED works if I manually add the required code (below), so now I am wondering why the IDE is not generating this for me - it used to do this with the standalone CubeMX:

        GPIO_InitTypeDef GPIO_InitStruct;

       GPIO_InitStruct.Pin = GPIO_PIN_7;

       GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;

       GPIO_InitStruct.Pull = GPIO_PULLUP;

       GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;

       HAL_GPIO_Init(GPIOH, &GPIO_InitStruct);

    PatrickFAnswer
    Technical Moderator
    October 19, 2020

    For pure GPIOs (i.e. not assigned to a functional IP), you should assign to Cortex-M4 using right-click:

    0693W000004KHEuQAO.png