This application note describes the peripheral firmware examples provided for the
STM32F0DISCOVERY Kit.
These ready-to-run examples are provided to help the user get started quickly with
STM32F0xx peripherals and STM32F0DISCOVERY board hardware. Preconfigured
projects for EWARM, MDK-ARM, TrueSTUDIO and TASKING toolchains are provided for
each example.
These examples are included in the firmware applications package available for download
on www.st.com/stm32f0discovery.
Users are advised to first read the document Getting started with software and firmware environments for the STM32F0DISCOVERY Kit (UM1523) to familiarize themselves with the
STM32F0DISCOVERY Kit.
Ta bl e 1 lists the microcontrollers and development tools concerned by this application note.
Table 1.Applicable products and tools
TypeApplicable products
MicrocontrollersSTM32 F0 series Entry-level Cortex™-M0 microcontrollers
Development toolsSTM32F0DISCOVERY evaluation board and discovery kit
The peripheral firmware examples are provided within the STM32F0DISCOVERY firmware
applications package and are located in the \Project folder as shown in Figure 1.
Figure 1.Hardware environment
1. VX.Y.Z refer to the package version, for example, V1.0.0.
To run an example, open the project with your preferred toolchain, compile, load and run it.
Some examples may require additional hardware such as an oscilloscope. For further detail
about the required hardware, refer to the readme file provided within each example.
4/19Doc ID 022897 Rev 2
AN4062Clock configuration
2 Clock configuration
The peripheral examples provided within STM32F0-Discovery Kit Firmware package are
configured to run at 48 MHz, using HSI as the clock source.
However, the user can modify this configuration to use HSE (crystal or bypass mode) as the
clock source, which needs some hardware modification on the discovery kit hardware.
The "system_stm32f0xx.c" file provided within each example was customized for use with
the discovery kit, allowing the user to select one of the three configurations below (by uncommenting the adequate define).
2.1 PLL_SOURCE_HSI
The HSI clock signal is generated from an internal 8 MHz RC Oscillator and can be used
directly as a system clock, or divided by 2 to be used as a PLL input.
The HSI RC oscillator has the advantage of providing a clock source at low cost (no external
components). It also has a faster startup time than the HSE crystal oscillator. However, even
with a calibration, the frequency is less accurate than an external crystal oscillator or a
ceramic resonator.
Note:This is the default configuration.
2.2 PLL_SOURCE_HSE
The high speed external clock signal (HSE) can be generated from two possible clock
sources:
●HSE external crystal/ceramic resonator
●HSE user external clock
The HSE crystal is not provided with the discovery kit. Some hardware modifications are
necessary to connect this crystal.
For more details, refer to section "4.7 OSC clock" in "STM32F0 discovery kit User manual
(UM1525)".
2.3 PLL_SOURCE_HSE_BYPASS
In this mode, the HSE is bypassed with an external clock (fixed at 8 MHz, coming from STLink circuit). It is used to clock the PLL, and the PLL is used as the system clock source.
Some hardware modifications are necessary to bypass the HSE with the clock coming from
the ST-Link circuit.
For more details, refer to section "4.7 OSC clock" in "STM32F0 discovery kit User manual
(UM1525)".
Doc ID 022897 Rev 25/19
Peripheral firmware examples descriptionAN4062
3 Peripheral firmware examples description
3.1 GPIO toggle example
3.1.1 Purpose
This example shows how to use the GPIO port bit set/reset registers (BSRR and BRR) for
I/O toggling.
3.1.2 Description
In this example:
●GPIOC clock is enabled.
●GPIOC pins 8 and 9 are configured.
●In a while loop, the ODR8 and ODR9 bits are set in the GPIOC output data register
(ODR) by setting the corresponding bits in the port bit set/reset register (BSRR). Then
the ODR8 and ODR9 bits are reset in the GPIOC output data register (ODR) by setting
the corresponding bits in the port bit reset register (BRR).
●A delay is inserted between setting and resetting the GPIOC ODR8 and ODR9 bits.
When the program is executed, the two LEDs, LED3 and LED4, are turned ON then OFF in
an infinite loop. The duration between the ON and OFF states corresponds to the inserted
delay.
3.2 EXTI example
3.2.1 Purpose
This example shows how to configure an external interrupt line.
3.2.2 Description
In this example:
●PA0 pin is configured in input floating.
●PA0 is configured to be used as an external interrupt source line 0 (EXTI0).
●The EXTI line 0 is configured to generate an interrupt on each rising edge detected on
the PA0 pin. The interrupt is triggered every time the User push-button is pressed.
●In the NVIC (nested vectored interrupt controller), the EXTI line 0 interrupt priority is
configured and the interrupt is enabled.
When the program is executed and the user pushes on the User push-button (EXTI0
interrupt routine), LED3 and LED4 connected to PC9 and PC8 are toggled.
6/19Doc ID 022897 Rev 2
Loading...
+ 13 hidden pages
You need points to download manuals.
1 point = 1 manual.
You can buy points or you can get point for every manual you upload.