UM1739
configuration option; more detailed information is available in the documentation
provided for each component.
4.
Starting the HAL Library: after jumping to the main program, the application code
calls the HAL_Init() API to initialize the HAL library, and do the following:
a)
b)
c)
d)
5.
Configuring the system clock: the system clock configuration is done by calling the
two following APIs
–
–
6.
Peripheral initialization
a)
b)
c)
d)
7.
Developing your application process: at this stage, your system is ready and you
can start developing your application code.
–
–
–
Configure the Flash prefetch, instruction and data caches (configured by the user
through macros defined in stm32f2xx_hal_conf.h).
Configure the Systick to generate an interrupt each 1 msec, which is clocked by
the HSI (at this stage, the clock is not yet configured and thus the system is
running from the internal HSI at 16 MHz).
Set NVIC Group Priority to 4.
Call HAL_MspInit() callback function defined in the user file stm32f2xx_hal_msp.c
to set the global low-level hardware initializations
HAL_RCC_OscConfig(): configures the internal and/or external oscillators, the
PLL source and factors. The user can choose to configure one oscillator or all
oscillators. In addition, the user can choose to skip the PLL configuration if there is
no need to run the system at high frequency.
HAL_RCC_ClockConfig(): configures the system clock source, Flash latency and
AHB and APB prescaler.
Start by writing the peripheral HAL_PPP_MspInit function. For this function,
proceed as follows:
- Enable the peripheral clock.
- Configure the peripheral GPIOs.
- Configure DMA channel and enable DMA interrupt (if needed).
- Enable peripheral interrupt (if needed).
Edit the stm32f2xx_it.c to call the required interrupt handlers (peripheral and
DMA), if needed.
Implement the callback functions (these functions are called when the peripheral
process is complete or/and when an error occurs), if you plan to use the peripheral
interrupt or DMA.
In the main.c file, initialize the peripheral handle structure, then call the function
HAL_PPP_Init() to initialize the peripheral.
The HAL provides intuitive and ready-to-use APIs to configure the peripheral. The
HAL supports polling, IT and DMA programming model, to accommodate any
application requirements. For more details on how to use each peripheral, refer to
the set of examples available in the firmware package.
If your application has some real time constraints, use the set of examples
showing how to use FreeRTOS and its integration with all Middleware stacks
provided within STM32CubeF2. This is a good starting point for your development.
Important note: take care when using HAL_Delay() function. 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
DocID026120 Rev 2
Getting started
15/19
18
Need help?
Do you have a question about the STM32F2 Series and is the answer not in the manual?
Questions and answers