GPIO_IOToggle Example Description

How to configure and use GPIOs through the HAL API.

PA.05 IO (configured in output pushpull mode) toggles in a forever loop. On NUCLEO-C031C6 board this IO is connected to LED4.

In this example, HCLK is configured at 48 MHz.

Notes

  1. Care must be taken when using HAL_Delay(), this function provides accurate delay (in milliseconds) based on variable incremented in SysTick ISR. This implies that if HAL_Delay() is called from a peripheral ISR process, then the SysTick interrupt must have higher priority (numerically lower) than the peripheral interrupt. Otherwise the caller ISR process will be blocked. To change the SysTick interrupt priority you have to use HAL_NVIC_SetPriority() function.

  2. The example needs to ensure that the SysTick time base is always set to 1 millisecond to have correct HAL operation.

Keywords

System, GPIO, Input, Output, Alternate function, Push-pull, Toggle

Directory contents

Hardware and Software environment

How to use it ?

In order to make the program work, you must do the following :