This application note describes the peripheral firmware examples provided for the
STM32F4DISCOVERY Kit.
These ready-to-run examples are provided to help the user get started quickly with
STM32F4xx peripherals and STM32F4DISCOVERY 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/stm32f4-discovery.
Users are advised to first read the document Getting started with software and firmware environments for the STM32F4DISCOVERY Kit (UM1467) to familiarize themselves with the
STM32F4DISCOVERY Kit.
The peripheral firmware examples are provided within the STM32F4DISCOVERY 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 022237 Rev 2
AN3983Peripheral firmware examples description
2 Peripheral firmware examples description
2.1 GPIO toggle example
2.1.1 Purpose
This example shows how to use the GPIO port bit set/reset registers (BSRRL and BSRRH)
for I/O toggling.
2.1.2 Description
In this example:
●GPIOD clock is enabled.
●GPIOD pins 12, 13, 14 and 15 are configured.
●In a while loop, the ODR12, ODR13, ODR14 and ODR15 bits are set in the GPIOD
output data register (ODR) by setting the corresponding bits in the port bit set/reset
register (BSRRL). Then the ODR12, ODR13, ODR14 and ODR15 bits are reset in the
GPIOD output data register (ODR) by setting the corresponding bits in the port bit reset
register (BSRRH).
●A delay is inserted between setting and resetting the GPIOD ODR12, ODR13, ODR14
and ODR15 bits.
When the program is executed, the four LEDs LD3, LD4, LD5 and LD6 are turned ON then
OFF in an infinite loop. The duration between the ON and OFF states corresponds to the
inserted delay.
2.2 EXTI example
2.2.1 Purpose
This example shows how to configure an external interrupt line.
2.2.2 Description
In this example:
●PA0 pin is configured in input floating.
●PA0 is configured to be used as 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), the LED LD4 connected to PD12 is toggled.
Doc ID 022237 Rev 25/19
Peripheral firmware examples descriptionAN3983
2.3 SysTick example
2.3.1 Purpose
This example shows how to configure system tick timer and use it to generate a 1 ms time
base.
2.3.2 Description
In this example:
●The system tick timer is initialized.
●The system tick timer interrupt is enabled in the NVIC.
●The system tick timer/counter starts in free running mode to generate periodical
interrupts.
●The system tick timer interrupt is triggered every 1 ms.
●A Delay function is implemented based on the system tick timer end-of-count event.
The four LEDs LD3, LD4, LD5 and LD6 are toggled with a timing defined by the Delay
function.
2.4 Standby mode example
2.4.1 Purpose
This example shows how to put the system in Standby mode and wake it up from this mode
using the external reset, RTC Alarm A or WKUP pin.
2.4.2 Description
In this example:
●The system tick timer is initialized.
●The system tick timer interrupt is enabled in the NVIC.
●The system tick timer/counter starts in free running mode to generate periodical
interrupts. The system tick timer interrupt is triggered every 250 ms. The LD4 is
toggled, indicating whether the MCU is in Standby or Run mode.
●The EXTI line 1 is configured to generate an interrupt on each rising/falling edge
detected on the PA1 pin. The external interrupt is generated every time the PA1
changes the level (GND or VDD).
–When a falling or rising edge is detected on the EXTI line, an interrupt is
generated. In the EXTI handler routine, the RTC is configured to generate an
Alarm event in 5 seconds, after which the system enters Standby mode causing
the LD4 to stop toggling.
–A rising edge on WKUP pin (User push button) or an external reset will wakeup
the system from Standby. If neither rising edge on WKUP pin (User push button)
nor external RESET are generated within 5 seconds, the RTC Alarm A will wakeup
the system.
6/19Doc ID 022237 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.