STM8S/A Standard Peripherals Library: Peripheral’s examples

 

Copyright 2011 STMicroelectronics

 

The STM8S/A Standard Peripherals library provides a rich set of examples covering the main features of each peripheral. 
Almost exmaples run on all supported STM8S/A 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 STM8/128-EVAL evaluation board 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), stm8s_it.c, s, stm8s_it.h, stm8s_conf.h and any other source files from the specified example to your toolchain folder under Project\Template. This project folder contains already all toolchain files needed for creating projects for STM8S/A 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

STM8S/A  StdPeriph_Lib Examples

The package contains the following examples:

ADC - AWU - BEEP - CAN - CLK - EXTI - FLASHGPIO - I2C - ITC  - IWDG - RST - SPI - TIM - UART - WWDG


IP/Module

Example

Supported devices

Name

Brief Description

 ADC

ADC2_ContinuousConversion

This example provides a short description of how to use the ADC peripheral to convert ADC2 Channel 9 input voltage in Continuous conversion mode with interrupt.

STM8S/A High density 

 AWU

AWU_ActiveHaltMode

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

 Pressing Key button will enter MCU in Halt mode.
 The MCU will then exit from halt mode thanks to the AWU. The wake up time depends  on the AWU peripheral configuration.

ALL

 BEEP

BEEP_3SignalsGeneration

This example provides a short description of how to use the BEEP peripheral:
Each time the key button is pressed the Beeper frequency changes and a corresponding led will be switched on.

ALL

 CAN

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 key push button.

STM8S208
STM8AF52A

 CLK

  CLK_ClockSecuritySystem

This example demonstrates the CSS (clock security system) capability.

ALL

CLK_ClockSelection

This example demonstrates the possibility to select the different clock sources using the joystick available on the evaluation board.

  CLK_MaxSpeed

This example provides two optimal clock configurations
  - Fcpu running at 24Mhz (HSE)
  - Fcpu running at 16Mhz (HSI)

EXTI

EXTI_InterruptPriority

 This example provides a short description of how to use the EXTI peripheral:
  - Configuration of External Interrupt / Falling edge and TLI
  - LEDs are toggling at each interrupt detection

ALL

FLASH

FLASH_ByteReadWriteOperation

This example provides a short description on how to use FLASH  Read/Write/Erase operations on byte

ALL

FLASH_WriteWordOperation

This example provides a short description on how to use FLASH Program word mode

ALL

FLASH_DataProgram

This example provides a description of how to use FLASH Write/Erase Block mode on data eeprom memory.

STM8S/A High density 

GPIO

GPIO_Toggle

This example provides a short description of how to use the GPIO peripheral to toggle Ports Pins infinitely

ALL

 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

ALL

  I2C_DataExchange

This is a typical example of how to use the I2C software library to ensure the steps of an I2C communication between slave Receiver/transmitter and master transmitter/receiver using interrupts.

ALL

ITC

Program

This example shows how to change the software priority of two external  interrupt lines to allow nested interrupt management.

ALL

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

RST

RST_IllegalOpcode

This example provides a short description of how to generate detect and manage an illegal opcode reset.

ALL

SPI

SPI_FastCommunicationMicroSD

This example provides a short description of how to make a communication (Write & Read data) between the SPI and a MicroSD memory card like the one present on the STM8/128-EVAL evaluation board.

ALL

SPI_FullDuplexUART1

This example provides a short description of how to make a master/slave full duplex communication between the SPI and the UART1, the last is configured in master synchronous mode.

ALL except STM8S/A Medium density

SPI_SimplexLCD

This example provides a short description of how to use the SPI firmware library in order to communicate with a monochrome LCD like the one present on the STM8/128-EVAL eval-board by the mean of the associated eval LCD driver.

ALL

TIMs

TIM1_6Steps

This example shows how to configure the TIM1 peripheral to generate 6 Steps.

ALL

TIM1_7PWM_Output

This example shows how to configure the TIM1 peripheral to generate 7 PWM signals with 4 different duty cycles.

ALL

TIM1_ComplementarySignals_DeadTime_Break_Lock

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.

ALL

TIM1_Input_Capture

This example shows how to configure the TIM1 peripheral to capture the internal clock source (LSI).

ALL

TIM1_Sinewave_Generation

This example shows how to use TIM1 to get the variation in sine wave frequency from 65Hz to 45Hz.

ALL

TIM2_OC_ActiveMode

This example shows how to configure the TIM2 peripheral to generate three different signals with three different delays

ALL except STM8S903

TIM2_OC_InactiveMode

This example shows how to configure the TIM2 peripheral to generate 3 different signals with 3 different delays.

ALL except STM8S903

TIM2_PWM_DutyCycleConfiguration

This example shows how to configure the TIM2 peripheral in Pulse Width Modulation mode (PWM).

ALL except STM8S903

TIM4_TimeBase

 This example provides a short description of how to use the TIM4 peripheral to generate time base equal to 1 ms. In this example a "Delay" function is implemented based on the TIM4 time base.

ALL except STM8S903

TIM5_Synchronisation_with_TIM6

This example provides a short description of how to use the TIM5 peripheral synchronized by TIM6. TIM5 is configured as a slave of TIM6.

STM8S903

UART

HalfDuplex

This example provides a basic communication between UART1 and UART3 in Half-Duplex mode using flags.

STM8S/A High density 

HyperTerminal_Interrupt

This example provides a description of how to use the UART1 Transmit and Receive interrupts to communicate with the hyperterminal.

ALL except STM8S/A Medium density

Interrupt

This example provides a basic communication between UART1 and UART3 using interrupts.

STM8S/A High density 

IrDA Receive

This example provides a basic communication USART1 IrDA receive mode. Four leds are used to show which byte is received.

ALL except STM8S/A Medium density

IrDA Transmit

This example provides a basic communication USART1 IrDA transmit mode. Five pins, configured in input floating mode, are used to select the byte to be sent at each pin state change.

ALL except STM8S/A Medium density

MultiProcessor

This example provides a description of how to use the UART1 in multi-processor mode.

ALL except STM8S/A Medium density

Printf

This example shows how to retarget the C library printf function to the UART.
This implementation output the printf message on the Hyperterminal using UART.

ALL

Smartcard

This example provides a description of how to use the UART in Smartcard mode.
The example gives only the possibility to read the ATR and decode it into
predefined buffer.

ALL except STM8S/A Medium density

Synchronous

This example provides a basic communication between UART1 (Synchronous mode) and SPI using flags.

ALL except STM8S/A Medium density

 WWDG

Example

This example shows how to refresh the WWDG counter.

ALL

Back to Top

 

 

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