STM8L15x/16x/05x/AL31_L Standard Peripherals Library: Peripheral’s examples

 

Copyright 2014 STMicroelectronics

 

The STM8L15x/16x/05x/AL31_L Standard Peripherals library provides a rich set of examples covering the main features of each peripheral. 
Almost exmaples run on all supported STM8L15x/16x devices. However some of them are device specific due to peripheral availability constraint.
All the examples are independent from the software toolchain. These examples run on STMicroelectronics STM8152x-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), stm8l15x_it.c, s, stm8l15x_it.h, stm8l15x_conf.h and any other source files from the specified example to your toolchain folder under Project\STM8L15x_StdPeriph_Template. This project folder contains already all toolchain files needed for creating projects for STM8L15x/16x 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 the target memory

  • Run the example

STM8L15x/16x/05x/AL31_L StdPeriph_Lib Examples

The package contains the following examples:

ADC - AES CLK - COMPDAC DMA - EXTI - FLASHGPIO - I2C - ITC  - IWDG LCD - PWR - RTC - SPI  - TIM - USART - WWDG


IP

Example Name

Example Description

Supported STM8L15x  Devices

AES

AES_EncryptDecrypt

This example provides a short description of how to configure the AES

hardware accelerator to encrypt then to decrypt text and to check that

decrypted text  corresponds to the original text.

STM8L16x High

Density

AES_KeyDerivation

This example provides a short description of how to use the AES hardware 

accelerator to perform key derivation. Using this mode avoids to re-perform

key derivation when processing multiple data-block.

STM8L16x High

Density

AES_MultipleBlockEncryptDecrypt

Use AES to encrypt then to decrypt  data greater than 16 bytes (128 bits)

STM8L16x High

Density

 ADC

ADC_IT

Use ADC1 to convert continuously Channel 3 using interrupt. Conversion is

triggered by software. Converted value is displayed on Dot matrix LCD

All

ADC_DMA

Use ADC1 scan mode to convert continuously Channel 3 and Channel 24.

Conversion is triggered by TIM1. Converted values are displayed on Dot

matrix LCD

High Density

Medium Density

Medium Density +

ADC_AnalogWatchdog

Use ADC1 to convert continuously Channel 3 in polling mode. Two leds are

used to indicate if the converted value exceeds the Analog watchdog

thresholds or not.

All

ADC_IDD_Measurement

This example provides a short description of how to use the ADC peripheral

to measure IDD in Run and Halt modes by using the IDD measurement circuit

available on the STM8L152x-EVAL board.

All

CLK

CLK_SYSCLKSwitch

This example demonstrates how to switch the System clock from one source

to another.

All

COMP

COMP2_AnalogVoltageMonitoring

Use ADC1 and COMP2 to monitor analog voltage

High Density

Medium Density

Medium Density +

COMP2_FrequencyMeasurement

Use Comparator 2 to measure external signal frequency and duty cycle.

High Density

Medium Density

Medium Density +

COMP2_PWMSignalControl

Use Comparator 2 to control PWM signals of TIM1

High Density

Medium Density

Medium Density +

COMP_AnalogWatchdog

Use COMP1 and COMP2 in window mode to make an analog watchdog.

All

COMP1_Halt

Use Comparator1 to exit the device from Halt mode. The device mode (run

or halt) is reported by LED1..4.

All

DAC

DAC_Noise&TriangleGenerator

Use DAC Noise and Triangle Generator feature

High Density

DAC_SignalsGeneration

Use DAC with DMA to generate square, triangular, sinusoidal and sin card

signals

High Density

Medium Density

Medium Density +

DMA

DMA_ADCtoTIM

Use DMA to change TIM1 duty cycle depending on ADC1 converted value.

High Density

Medium Density

Medium Density +

DMA_ChannelsPriority

Use DMA to transfer data with different channels priorities

High Density

Medium Density

Medium Density +

DMA_WFE

Use DMA to transfer during wfe low power mode.

All

DMA_WFI

Use DMA to transfer during wfe low power mode.

All

DMA_USARTtoRAM

Use DMA to transfer continuously data received by USART1 to RAM with

(data) real time display on LCD

All

EXTI

EXTI_IOControl

Use GPIO and EXTI to detect interrupt on pushbuttons.

All

FLASH

Data_Program

How to program the STM8L15x FLASH Data Memory

All

GPIO

GPIO_Toggle

Use the GPIO to toggle an IO.

All

I2C

I2C_EEPROM

Use the I2C1 software library and  an associate I2C1 EPROM driver to

communicate with an I2C1 EEPROM device. The data to write into the I2C1

EEPROM is entered by user from the HyperTerminal.

All

I2C_TSENSOR

Use the I2C1 to communicate with  an STLM75 I2C temperature sensor that

is mounted on  the STM8L1526-EVAL board. The measured temperature is

displayed on LCD dot matrix and the device enter in active halt mode after

~30s the RTC generate an interrupt to w

All

I2C_DataExchange

Use two boards to ensure the steps of an I2C communication between slave

and master. Data lenght, addressing mode, use of I2C safe procedure are

configurable. Data sent from master to Slave is sent back from slave to master

and data consistency check is made

All

I2C_JoystickPlay

Use joystick buttons to tigger I2C communication. At each joystick button

press in master board correponds an action in the slave side

All

ITC

ITC_SoftwarePriority

This example shows how to change the software priority of two external

interrupt lines to allow nested interrupt management.

High Density

Medium Density

Medium Density +

IWDG

IWDG_Example

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.

All

LCD

LCD_SegmentsDrive

Use the STM8L15x LCD embedded  controller to drive an glass LCD (7

digit). In this example the device enters Halt mode and exit  (in infinite loop)

by the RTC wake-up interrupt then a message is displayed on the glass LCD.

High Density

Medium Density

Medium Density +

PWR

PWR_PVD_Halt

Use PVD to monitor VDD power supply and put the device in Halt mode

when VDD < PVD level

All

PWR_WFI

Enter WFI mode and exit with EXTI Line or RTC wake-up interrupts

High Density

Medium Density

Medium Density +

RTC

RTC_ChronoSubSecond

Use RTC as a chronometer

High Density

RTC_PeriodicWakeup500ms

Use RTC periodic Wakeup unit to toggle leds each 500ms

High Density

RTC_Tamper1Detection

Use RTC Tamper1 Filter feature

High Density

RTC_WakeUpLPMode

Use RTC wake up from Low power Mode

High Density

Medium Density

Medium Density +

RTC_Calendar

Use the RTC peripheral’s calendar for Time,  Date and Alarm management

All

SPI

SPI_FLASH

Use the SPI1 firmware library and an associate SPI FLASH driver to

communicate with an M25P128 FLASH.

The data to write into the SPI FLASH is entered by user from the

HyperTerminal.

All

SPI_SlaveDMA

Use SPI1 as Slave receiver in DMA mode, data to be sent to SPI1 is entered

by user from the HyperTerminal.

All

SPI_MSD

Use the SPI1 and an associated driver to communicate with a MicroSD card

All

TIMs

TIM1_6Steps

Use TIM1 to generate 6 step PWM signals using the commutation event.

High Density

Medium Density

Medium Density +

TIM1_ComplementarySignals

Use the TIM1 peripheral to generate 6 complementary PWM signals with

dead time insertion, break capability and lock option

High Density

Medium Density

Medium Density +

TIM1_DMA

Use DMA1 with TIM1 Update request to transfer data from memory to

TIM1 CCR1 register

High Density

Medium Density

Medium Density +

TIM1_PWMInput

Use the TIM1 to measure the frequency and duty cycle of an external signal

High Density

Medium Density

Medium Density +

TIM1_PWMOutput

Use the TIM1 peripheral to generate three signals with different frequencies

High Density

Medium Density

Medium Density +

TIM1_DMABurstMode

Use DMA to transfer data in Burst mode from RAM buffer to TIM1

High Density

Medium Density

Medium Density +

TIM1_Synchro

How to synchronize TIM1 with TIM2 and TIM3 using TIM1 update event

High Density

Medium Density

Medium Density +

TIM2_TRIGLSE

Generate PWM signal using LSE clock source for TIM2 counter

All

TIM4_TimeBase

Use the TIM4 peripheral to generate 1 ms time base using update interrupt

All

USART

USART_HyperTerminal_DMA

Use the USART1 DMA to communicate with the HyperTerminal

All

USART_HyperTerminal_Interrupts

Use the USART1 interrupts to communicate with the HyperTerminal

All

USART_IrDA

Use the USART1 in a basic IrDA communication receive/transmit  mode.

All

USART_MultiProcessor

Use the USART in multi-processor mode.

All

USART_Printf

Retarget the C library printf() and getchar() functions to the USART

All

WWDG

WWDG_Example

WWDG counter refresh and simulation of WWDG reset

All


Back to Top

 

 

For complete documentation on STM8 8-bit Microcontrollers platform visit www.st.com