STM32F0xx Standard Peripherals Library: Peripheral’s examples

STM32F0xx Standard Peripherals Library: Peripheral’s examples Copyright 2014 STMicroelectronics

The STM32F0xx Standard Peripherals library provides a rich set of examples covering the main features of each peripheral. All the examples are independent from the software toolchain. These examples run on STMicroelectronics STM320518-EVAL and STM32072B-EVAL evaluation boards and can be easily tailored to any other supported device and development board. Only source files are provided for each example and user can tailor the provided project template to run the selected example with his preferred toolchain.

## How to proceed?

- Copy the files main.c, main.h (if exists), stm32f0xx_it.c, system_stm32f0xx.c, stm32f0xx_it.h, stm32f0xx_conf.h and any other source files from the specified example to your toolchain folder under Projects\STM32F0xx_StdPeriph_Templates. This project folder contains already all toolchain files needed for creating projects for STM32F0xx microcontrollers.
- Open your preferred toolchain
- If needed, add in the project list the additional files required to run the example (refer to your example readme file)
- Rebuild all files and load your image into target memory
- Run the example

## STM32F0xx StdPeriph_Lib Examples

The package contains the following examples:

ADC - CAN - CEC - COMP - CRC - DAC - DMA - EXTI - FLASH - GPIO - I2C - I2S - IWDG - Lib_DEBUG - NVIC - PWR - RCC - RTC - SPI - SYSCFG - SysTick - TIM - USART - WWDG

IP Module |  | Example |
| Name | Brief Description |
ADC |  | ADC_DMA | This example describes how to use the ADC1 and DMA to transfer continuously converted data from ADC1 to memory. |
| ADC_LowPower | This example provides a short description of how to use the ADC peripheral with Auto-delayed conversion mode and Auto-poweroff modes. |
| ADC_AnalogWatchdog | This example describes how to use the ADC analog watchdog to guard continuously on ADC channel. |
| ADC_BasicExample | This example describes how to use the ADC1 to convert continuously the Eval Board potentiometer. The converted voltage is displayed on the Eval Board LCD. |
| ADC_BatteryChargeMonitoring | This example describes how to measure VBAT voltage using ADC1 regular channel 18, the measured value should correspond to VBAT/2. |
CAN |  | CAN_DualFIFO | This example shows how to configure the CAN peripheral to send and receive CAN frames in normal mode and using FIFO0 and FIFO1. |
| CAN_FIFOExtension | This example shows how to configure the CAN peripheral to send and receive CAN frames in normal mode using FIFO0 and FIFO1. This application example shows how to manage the both CAN FIFO as a single FIFO composed by 6 mail boxes. |
| CAN_LoopBack | This example provides a description of how to set a communication with the CANin loopback mode. |
| CAN_Networking | This example shows how to configure the CAN peripheral to send and receive CAN frames in normal mode. The sent frames are used to control Leds by pressing TAMPER push button |
CEC |  | CEC_DataExchange | This example provides a basic communication between two HDMI-CEC devices using interrupts. |
| CEC_ListenMode | This example provides a basic communication between two HDMI-CEC devices using interrupts and an spy CEC device which receives messages addressed to different destination. |
| CEC_MultAddress | This example provides a basic communication between two HDMI-CEC devices using interrupts, which the follower one supports two addresses at the same time. |
COMP |  | COMP_AnalogWatchdog | This example shows how to make an analog watchdog using the STM32F0xx COMPs peripherals in window mode: If the input voltage is above the higher threshold, LD3 and LD1 are turned On. If the input voltage is under the lower threshold, LD2 and LD4 are turned On. If the input voltage is within the thresholds, the MCU remains in STOP mode and all leds are turned Off. |
| COMP_LDR | This example shows how to configure the comparator which can be used in combination with DAC peripheral to mesure the light intensity (using the LDR sensor). |
| COMP_PulseWidthMeasurement | This example shows how to configure the COMP2 peripheral to measure pulse width. This method (measuring signal pulse using comparator is interesting when external signal doesn't respect the VIL and VIH levels). |
| COMP_PWMSignalControl | This example shows how to configure COMP2 peripheral to hold on safe state (low level) TIM2 channels as soon as COMP2 output is set at high level. |
CRC |  | CRC_32BitsCRCMessage | This example aims to show how to use the CRC peripheral in order to compute 32-bit CRC checksum of a message. The CRC peripheral is configured to use the 32-bit CRC polynomial X32 + X26 + X23 + X22 + X16 + X12 + X11 + X10 +X8 + X7 + X5 + X4 + X2+ X +1 with the initialization value set to 0. |
| CRC_8BitsCRCMessage | This example aims to show how to use the CRC peripheral in order to compute 8-bit CRC checksum of a message. The CRC peripheral is configured to use the 8-bit CRC polynomial x8 + x7 + x6 + x4 + x2 + 1 with the initialization value is set to 0 |
| CRC_TwoBoards | This example aims to show how to verify CRC checksum while USART communication between two STM32F0xx boards. |
DAC |  | DAC_ADC | This example describes how to use the ADC1 and DAC to output on DAC_OUT1 sampled values of ADC1. The ADC1 is configured to convert continuously ADC1 channel11 (PC1). The End Of Conversion (EOC) interrupt is enabled and the conversion is triggered by software. |
| DAC_SignalsGeneration | This example provides a short description of how to use the DAC peripheral to generate several signals using DMA controller. When the user presses the KEY push-button, DMA transfers the two selected waveforms to DAC. |
DMA |  | DMA_ADCTIMTransfer | This example provides a description of how to use a DMA channel to transfer continuously a data from a peripheral (ADC1) to another peripheral (TIM3) supporting DMA transfer. |
| DMA_FLASHRAMTransfer | This example provides a description of how to use a DMA channel to transfer a word data buffer from FLASH memory to embedded SRAM memory. |
| DMA_RAMDACTransfer | This example provides a description of how to use a DMA channel to transfer data buffer from RAM memory to DAC. |
| DMA_USARTTransfer | This example provides a basic communication between USART1 and USART2 using DMA2 capability. |
EXTI |  | EXTI_Example | This example shows how to configure an external interrupt line. The EXTI line is configured to generate an interrupt on each falling edge. |
FLASH |  | Flash_Program | This example provides a description of how to program the STM32F0xx FLASH. |
| Flash_WriteProtection | This example provides a description of how to enable and disable the write protection for the STM32F0xx FLASH. |
GPIO |  | GPIO_IOToggle | This example describes how to use GPIO BSRR (Port bit set/reset register) for IO toggling max frequency. |
I2C |  | I2C_EEPROM | This firmware provides a basic example of how to use the I2C firmware library and an associate I2C EEPROM driver to communicate with an I2C EEPROM device (here the example is interfacing with M24LR64 EEPROM) |
| I2C_TSENSOR | This example provides a description of how to use the I2C to communicate with an STLM75 (or a compatible device) I2C temperature sensor is mounted on the STM320518-EVAL board and used to get instantaneous external temperature (-55°C to +125°C). |
| I2C_TwoBoards | This example shows how to use the CPAL library to control I2C devices and communicate between two different boards. |
| I2C_WakeUpFromStop | This example shows how to use the WakeUp from STOP feature of I2C device using the CPAL library. This example requires two boards, one configured in master mode and another one configured in slave mode. |
I2S |  | I2S_DataExchangeDMA | This example provides a description of how to set a communication between two SPIs in I2S mode using DMA and performing a transfer from Master to Slave. |
| I2S_DataExchangeInterrupt | This example provides a description of how to set a communication between two SPIs in I2S mode using interrupts and performing a transfer from Master to Slave. |
IWDG |  | IWDG_Reset | This example shows how to update at regular period the IWDG reload counter and how to simulate a software fault generating an MCU IWDG reset on expiry of a programmed time period. |
| IWDG_WinwdowMode | This example shows how to update at regular period the IWDG reload counter and how to simulate a software fault generating an MCU IWDG reset on expiry of a programmed time period using window mode feature. |
LIB_DEBUG |  | Lib_DEBUG_Example | This example demonstrates how to declare dynamic peripherals pointers used for Debug mode. |
NVIC |  | NVIC_WFI_Mode | This example shows how to enter the system to WFI mode and wake-up from this mode by the User key interrupt. |
PWR |  | PWR_STANDBY | This example shows how to enter the system to STANDBY mode and wake-up from this mode using RTC Alarm. |
| PWR_STOP | This example shows how to enter the system to STOP mode and wake-up using EXTI Line interrupts. The EXTI Line sources are PB8 and RTC Alarm. |
| PWR_CurrentConsumption | This example shows how to configure the STM32F0xx system to measure different Low Power modes current consumption. |
RCC |  | RCC_Example | This example shows how to: - Configure the PLL (clocked by HSE) as System clock source - Use the Clock Security System (CSS) feature to detect HSE failure - Output the System clock on MCO pin |
RTC |  | RTC_Calendar | This example demonstrates and explains how to use the RTC peripheral. As an application example, it demonstrates how to setup the RTC peripheral, in terms of prescaler and interrupts, to be used to keep time and to generate alarm interrupt. |
| RTC_TimeStamp | This example provides a short description of how to use the RTC peripheral and the timeStamp Feature. |
| RTC_Tamper | This example shows how to write/read data to/from RTC Backup data registers and demonstrates the Tamper detection feature. |
| RTC_LSI | This example demonstrates and explains how to use the LSI clock source auto calibration to get a precise RTC clock. |
| RTC_StopWatch | This example illustrates how to use the STM32F0xx new RTC's sub-seconds and Tamper feature (Filter, sampling) features. It simulates a precise chronometer with 2 record times possibilities stored in the Backup registers (2 registers for time (second, minutes and hours) and 5 registers for subsecond). |
| RTC_Timer | This example provides a short description of how to use the RTC peripheral’s with Alarm sub seconds feature to simulate a timer with refresh time equal to 250 ms (1 second/ 8) * 2). |
SPI |  | SPI_MSD | This example provides a basic example of how to use the SPI firmware library and an associate SPI SDcard driver to communicate with an SDcard available on The eval board. |
| DataExchangeDMA | This example provides a small application in which joystick buttons are used to trigger SPI communication and though using SPI firmware library. |
| DataExchangeInterrupt | This example provides a small application in which joystick buttons are used to trigger SPI communication and though using SPI firmware library. |
SYSCFG |  | SYSCFG_PVD | This example shows how to configure the programmable voltage detector. |
SysTick |  | SysTick_Example | This example shows how to configure the SysTick to generate a time base equal to 1 ms. The system clock is set to 48 MHz, the SysTick is clocked by the AHB clock (HCLK). |
TIM |  | TIM_6Steps | This example shows how to configure the TIM1 peripheral to generate 6 Steps. The STM32F0xx TIM1 peripheral offers the possibility to program in advance the configuration for the next TIM1 outputs behaviour (step) and change the configurationof all the channels at the same time. This operation is possible when the COM (commutation) event is used. |
| TIM_7PWMOutputs | This example shows how to configure the TIM1 peripheral to generate 7 PWM signals with 4 different duty cycles (50%, 37.5%, 25% and 12.5%). |
| TIM_ComplementarySignals | This example shows how to configure the TIM1 peripheral to generate three complementary TIM1 signals, to insert a defined dead time value, to use the break feature and to lock the desired parameters. |
| TIM_DMABurst | This example shows how to update the TIM1 channel1 period and the duty cycle using the TIM DMA burst feature. |
| TIM_EncoderMode | This example shows how to configure the TIM peripheral to interface with a encoder sensor. The TIM3 is configured in encoder mode1: Counter counts up/down on TI2 rising edge depending on TI1 level |
| TIM_InputCapture | This example shows how to use the TIM peripheral to measure the frequency of an external signal. |
| TIM_OCActive | This example shows how to configure the TIM peripheral to generate four different signals with four different delays. |
| TIM_OCToggle | This example shows how to configure the TIM3 peripheral to generate four different signals with four different frequencies. |
| TIM_OnePulse | This example shows how to use the TIM peripheral to generate a One pulse Mode after a Rising edge of an external signal received in Timer Input pin. |
| TIM_PWMInput | This example shows how to use the TIM peripheral to measure the frequency and duty cycle of an external signal. |
| TIM_SynchronizationMode | This example shows how to synchronize TIM peripherals in cascade mode. |
| TIM_ADCTrigger | This example describes how to configure the TIM to trigger the ADC conversion. |
| TIM_TimeBase | This example shows how to configure the TIM peripheral in Output Compare Timing mode with the corresponding Interrupt requests for each channel in order to generate 4 different time bases. |
USART |  | USART_Printf | This example shows how to retarget the C library printf function to the USART. This implementation output the printf message on the HyperTerminal using USART1. |
| USART_HyperTerminalInterrupt | This example provides a description of how to use the USART1 with Transmit and Receive interrupts to communicate with the hyperterminal. |
| USART_AutoBaudRate | This example provides a description of how to use the Auto BaudRate capability of the USART via the HyperTerminal. |
| USART_WakeUpFromStop | This example provides a description of how to use the WakeUp from STOP mode capability of the USART via the hyperterminal. |
| DataExchangeDMA | This example provides a small application in which joystick buttons are used to trigger UART communication and though using UART firmware library. |
| DataExchangeInterrupt | This example provides a small application in which joystick buttons are used to trigger UART communication and though using UART firmware library. |
| USART_8xUsartsOneBoard | This example provides a small application in which 8xUsarts are used for a circular communication using interrupts and USART firmware library. |
WWDG |  | WWDG_Example | This example shows how to update at regular period the WWDG counter and how to simulate a software fault generating an MCU WWDG reset on expiry of a programmed time period. |

Back to Top

For complete documentation on STM32 32-bit Microcontrollers platform visit www.st.com/STM32