For designers of STM8L microcontroller applications, it is important to be able to replace
easily one microcontroller type by another one in the same product family. Migrating an
application to a different microcontroller is often needed when product requirements grow,
putting extra demands on the memory size and on the number of I/Os.
However, to achieve cost reduction objectives, the user may need to switch to smaller
components and to shrink the PCB area. This application note aims at analyzing the steps
required to migrate from an existing STM8L-based design to any one of the other
microcontroller types in the fast-growing STM8L family.
This application note groups all the most important information and provides a list of the
fundamental aspects.
The information included in this document can also be extremely useful in a first STM8
design. Studying the issues in this phase can allow the user to adapt from the beginning his
design to any future requirement.
To benefit fully from the information in this application note, the user should be familiar with
the STM8L microcontroller family. The STM8L family reference manuals (RM0013 and
RM0031), the STM8L datasheets, and the STM8L Flash program memory / data EEPROM
programming manual (PM0054) are available from www.st.com.
This application note is divided into four main sections:
■ Section 1: STM8L family compatibility: This section presents a first-level view of the
different aspects of the STM8L family architecture that must be taken into account for a
new design or migration. The microcontroller blocks and peripherals are grouped and
identified either as “compatible” or “compatible with minor limitations”.
■ Section 2: Planning for migration: This section gives an overview of common migration
cases. It provides a checklist of items which are potentially impacted by each case to allow
the user to quickly analyze which subjects have to be anticipated.
■ Section 3: Block-by-block compatibility: This section focuses on the migration
between different packages and details the pin-to-pin compatibility between all STM8L
sub-families.
■ Section 4: Peripheral pinout through all STM8L sub-families. This section shows the
The STM8L family is one of a growing number of different STM8 microcontroller families.
All these STM8 microcontroller families are based on a common robust and low-cost 8-bit
high performance core with a rich set of enhanced peripherals. This ensures a high level of
compatibility within the STM8L ‘world’, especially in terms of software development,
compilers, debugging environment, programming tools and driver libraries.
The STM8L product family offers a wide choice of memory sizes and package types to fit
different application requirements as closely as possible. Consequently, when there are new
requirements on the application side, it can make sense to switch to another STM8L type
with different memory capacity or package size.
The STM8L family includes a product line divided into two main sub-families:
●STM8L15x/STM8L16x sub-family of microcontrollers with different memory densities,
packages and peripherals.
–The low density STM8L15x devices are the STM8L151C2/K2/G2/F2,
STM8L151C3/K3/G3/F3 microcontrollers with a 4-Kbyte or 8-Kbyte Flash memory
density.
–The medium density STM8L15x devices are the STM8L151C4/K4/G4,
STM8L151C6/K6/G6, STM8L152C4/K4/G4 and STM8L152C6/K6/G6
microcontrollers with a 16-Kbyte or 32-Kbyte Flash memory density.
–The medium+ density STM8L15x devices are the STM8L151R6 and
STM8L152R6 microcontrollers with a 32-Kbyte Flash memory density. They offer
a wider range of peripherals than the medium density devices.
–The high density STM8L15x devices are the STM8L151x8 and STM8L152x8
microcontrollers with a Flash memory density equal to 64 Kbytes. They offer the
same peripheral set as medium+ density devices.
–The high density STM8L162x devices are the STM8L162x8 microcontrollers
where the Flash memory density is equal to 64 Kbytes. They offer the same
peripheral set as high density STM8L152 devices plus the AES hardware
accelerator.
●STM8L10x low density sub-family where the Flash memory density ranges between 4
and 8 Kbytes. The STM8L10x MCUs are ideal for cost-sensitive applications with low
code density.
Both sub-families provide a complete set of essential peripherals. STM8L10x devices target
applications requiring reduced cost, lower memory capacity, fewer GPIOs and less
advanced features.
The wide range of available pin-counts and package sizes is discussed in Chapter 3.1:
Package pinout.
6/63Doc ID 16993 Rev 3
AN3139STM8L family compatibility
All STM8L family microcontrollers use the same application development tools:
●Embedded single wire interface module (SWIM)
●Software integrated development environment (IDE) tools including assembler,
simulator, debugger, programmer:
–ST Visual Develop (ST)
–Ride (Raisonance)
–IAR
●In-circuit debugging and programming tools
–STIce from ST (full hardware emulator)
–ST-Link from ST
–RLink from Raisonance (low cost debug/programming tool)
●Starter kits and evaluation boards
●C compiler and assembler tool chains (Cosmic, Raisonance, IAR)
●Firmware libraries (peripheral control examples, MISRA or class B compliance, touch
sensing)
●Application notes
By using a common development environment, you significantly reduce code maintenance
effort and shorten the time-to-market, especially in cases when an application has to be
migrated from one STM8 microcontroller to another.
By using the drivers provided in the STM8L firmware library to interface with the hardware, it
becomes reasonably straightforward to move the application firmware from one STM8L
product to another. The principle job is analyzing the details on the hardware side, taking
care of the placement and availability of the peripheral I/O functions in the pinout. More
details can be obtained in the STM8L datasheet and further in this document in Section 3.1:
Package pinout.
Figure 1: STM8L family block diagram gives an overview of the STM8L blocks and their
compatibility level, as discussed in the next sections.
Table 1.Overview of STM8L family peripherals
Peripheral
RAMUp to 1.5 KbytesUp to 2 KbytesUp to 2 KbytesUp to 4 Kbytes
Flash
Program
memory
STM8L10xSTM8L15x/STM8L16x
Low density
STM8L10x
Up to 8 Kbytes From 4 to 8 Kbytes
Low density
STM8L15x
Medium
density
STM8L15x
From 16 to
32 Kbytes
Medium+/High density STM8L15x/
High density STM8L16x
32 Kbytes in medium+ density devices
64 Kbytes in high density devices
(STM8L15x/16x)
Doc ID 16993 Rev 37/63
STM8L family compatibilityAN3139
Table 1.Overview of STM8L family peripherals (continued)
STM8L10xSTM8L15x/STM8L16x
Peripheral
Data
EEPROM
Interrupt
C L K Ye sYe sYe sYe s
AWUYes
RTC
B e e pYe sYe sYe sYe s
I W D G Ye sYe sYe sYe s
WWDGNot availableYesYesYes
C O M PYe sYe sYesYe s
RI &
SYSCFG
Low density
STM8L10x
Up to 2 Kbytes in
Flash program
memory
Size configurable
by option byte
Up to 26 Peripheral
interrupt vectors
Not availableYesYesYes
Not availableYesYesYes
Low density
STM8L15x
Up to 1 Kbytes in
separate memory
array;
Fixed size
Up to 32 Peripheral
interrupt vectors
Not availableNot availableNot available
Medium
density
STM8L15x
Up to 1 Kbytes
in separate
memory array;
Fixed size
Up to 32
Peripheral
interrupt vectors
Medium+/High density STM8L15x/
High density STM8L16x
Up to 2 Kbytes in separate memory
Fixed size
Up to 32 Peripheral interrupt vectors
array;
GPIO
EXTI
DMA
ADCNot availableADC1ADC1ADC1
DAC
TIM
Infrared
Interface
IRTIM
I2CI2CI2C1I2C1I2C1
Up to 30I/Os
(GPIOA..D)
Up to 29 external
interrupt lines
Not available
Not availableDAC1 channelDAC 1 channelsDAC 2channels
Basic TIM4
General-purpose
TIM2/3
Ye sYe sYe sYe s
Up to 41 I/Os
(GPIOA..F)
Up to 40 external
interrupt lines
DMA1 with 4
channels
Basic TIM4
General-purpose
TIM2/3
Up to 41 I/Os
(GPIOA..F)
Up to 40
external
interrupt lines
DMA1 with 4
channels
Basic TIM4
General-
purpose TIM2/3
Advanced-
control TIM1
Up to 68 I/Os (GPIOA..F) in high
density devices
Up to 67 external interrupt lines
DMA1 with 4 channels
Basic TIM4
General-purpose TIM2/3/5
Advanced-control TIM1
8/63Doc ID 16993 Rev 3
AN3139STM8L family compatibility
Table 1.Overview of STM8L family peripherals (continued)
STM8L10xSTM8L15x/STM8L16x
Peripheral
SPISPISPI1SPI1SPI1/SPI2
USARTUSARTUSART1USART1USART1/USART2/USART3
LCDNot availableYesYesYes
AES
1. Available on high-density STM8L16x devices only.
Low density
STM8L10x
Not availableNot availableNot availableYes
Low density
STM8L15x
Medium
density
STM8L15x
Medium+/High density STM8L15x/
High density STM8L16x
(1)
1.2 Fully compatible blocks
The STM8L family embeds a set of system blocks which are by definition common to all
products. Those blocks are identical, so they have the same structure, registers and control
bits. There is no need to perform any software change to keep the same functionality at the
application level after migration. When external components are needed (e.g. Vcap
capacitor) no change is required from one product to another. All the features and behaviors
remain the same. These blocks are shown in Figure 1: STM8L family block diagram.
Fully compatible parts and peripherals are:
●STM8 core
●Debug / SWIM module
●Power-on reset (POR)
●Voltage regulator
●Low speed internal RC (LSI)
●High speed internal RC (HSI)
●Independent watchdog
●Timers (TIM2, TIM3 and TIM4)
●IR (infrared interface)
1.3 Blocks that are compatible with minor exceptions
Some of the peripherals or functional blocks can have differences in their electrical
parameters, structure, registers, control bits or other minor aspects but not in their main
functionality.
peripherals are not available in STM8L10x devices.
SPI2, USART2 and USART3 are not available in low and medium density STM8L15x
devices.
The AES peripheral is available only in high density STM8L16x devices.
The AWU peripheral is not available in STM8L15x devices and is replaced by the RTC, so
this aspect can also be considered as an incompatibility.
The following functional blocks can be considered as compatible with only a few negligible
differences:
●GPIO (I/O capabilities)
●Interrupt management (interrupt vectors)
●Power control (wakeup from low power mode)
●I2C1 (true open drain)
●SPI1
●USART1
●Internal memories (Flash, SRAM, EEPROM)
You can find more details about these blocks in Chapter 3: Block-by-block compatibility
analysis. You can also refer to Figure 1: STM8L family block diagram.
1.4 Blocks that are compatible with significant exceptions
A few peripherals have additional features or less important functionalities compared to the
same peripheral in another STM8L sub-family. For these particular peripherals you have to
adapt the software drivers and check all possible hardware dependencies.
The peripheral and functional blocks in the following list are compatible with significant
exceptions. The package pinout is high on the list as this aspect requires special attention:
●Package pinout
●CLK
●COMP
●ADC
●DAC
●LCD
●RTC
You can find more details in Section 3: Block-by-block compatibility analysis. You can also
refer to Figure 1: STM8L family block diagram.
10/63Doc ID 16993 Rev 3
AN3139STM8L family compatibility
)NTERNAL2#OSCILLATOR
-(Z
)NTERNAL2#OSCILLATOR
K(Z
%XTERNAL2#OSCILLATOR
-(Z
#/-0
34-#ORE
)/S
)NFRAREDINTERFACE
)NTERRUPTCONTROLLER
37)-DEBUGMODULE
%XTERNAL2#OSCILLATOR
K(Z
#LOCK
CONTROLLER
AND#33
2ESETBLOCK
6OLTAGEREGULATOR
0/2 0$2 "/2 06$
!DDRESSANDDATABUS
!DDRESSANDDATABUS
&LASH
MEMORY
2!-
MEMORY
4)-
%%02/-
MEMORY
"OOT2/-
MEMORY
)7$'
!75
$!#
!$#
,#$
24#
77$'
30)
30)
)#
$-!
&ULLYCOMPATIBLE
#OMPATIBLEWITHMINOREXCEPTIONS
#OMPATIBLEWITHSIGNIFICANTEXCEPTIONS
,EGEND
-36
53!24
53!24
53!24
4)-
4)-
!%3
Figure 1.STM8L family block diagram
1. LCD, ADC1, WWDG, RTC, DAC, DMA, Boot ROM and AWU are fully compatible but not present in all
STM8L devices.
1.5 Firmware library
The peripheral compatibility throughout STM8L MCU families promotes platform design and
eases significantly the migration from one product line to the other. The software support is
Doc ID 16993 Rev 311/63
STM8L family compatibilityAN3139
however essential during development time. Extensive software libraries are available for
both STM8L10x, STM8L15x and STM8L16x devices, providing the user with a hardware
abstraction layer (HAL) for all MCU resources. Moreover, there is not a single control/status
bit that is not covered by a C function or an API.
The software library covers three abstraction levels, and it includes:
1.A complete register address map with all bits, bit fields and registers declared in C. By
providing this map, the software library makes the designers’ task much lighter and,
even more importantly so, it gives all the benefits of a bug-free reference mapping file,
thus speeding up the early project phase.
2. A collection of routines and data structures in API form, that covers all peripheral
functions. This collection can directly be used as a reference framework, since it also
includes macros for supporting core-related intrinsic features and common constant
and data type definition. Moreover, it is compiler agnostic and can therefore be used
with any existing or future toolchain. It was developed using the MISRA C automotive
standard.
3. A set of examples covering all available peripherals (35 examples so far for the
STM8L10x sub-family, 35 for the STM8L15x sub-family), with template projects for the
most common development toolchains. With the appropriate hardware evaluation
board, only a few hours are needed to get started with a brand new microcontroller. It is
then up to you to choose how to use the library. You can either pick up the files useful
for the design, use examples to get trained or quickly evaluate the product. You can
also use the API to save development time.
Let us now have a look at the few key files and concepts. Two separate libraries support the
STM8L10x and STM8L15x devices. In the file names below, you simply need to replace the
“stm8l1xx_” prefix by “stm8l10x” or “stm8l15x” depending on the chosen product.
●stm8l1xx_.h
This file is the only header file that must be included in the C source code, usually in main.c.
This file contains:
–data structures and address mapping for all peripherals
–macros to access peripheral register hardware (for bit manipulation for instance),
plus STM8 core intrinsics
–a configuration section used to select the device implemented in the target
application. You also have the choice to use or not the peripheral drivers in the
application code (that is code based on direct access to registers rather than
through API drivers)
●stm8l1xx_conf.h
This is the peripheral driver configuration file, where you specify the peripherals you want to
use in your application, plus a few application-specific parameters such as the crystal frequency.
●stm8l1xxx_it.c
This file contains the template IRQ handler to be filled, but this is already the first
development step.
Once you have understood the above operating principle and file organization, for simple
applications, you could virtually switch from one product to the other without referring to the
reference manual. Figure 2: STM8L10x code example and Figure 3: STM8L15x code exam-
ple show the initialization code (using the firmware library) for STM8L10x and STM8L15x
products, respectively.
12/63Doc ID 16993 Rev 3
AN3139STM8L family compatibility
Figure 2.STM8L10x code example
Figure 3.STM8L15x code example
All parameters are identical, and the procedure is similar with two function calls for both configuration and startup.
The main difference is the additional peripherals of the same type that are added in the
STM8L15x sub-family:
●when migrating from STM8L10x sub-family to STM8L15x sub-family, the additional
peripheral must be added in every firmware library function as the first parameter (refer
to Figure 3)
●when migrating from STM8L15x sub-family to STM8L10x sub-family, the additional
peripheral given as the first parameter in every firmware library function must be
removed (refer to Figure 2)
Another difference in the SPI peripheral is the CRC capability which is supported only in the
STM8L15x devices. In the above example (Figure 3.), the CRC polynomial “0x07” is explicitly defined. This CRC polynomial parameter must be removed from the “init” function in the
case of a migration from the STM8L15x sub-family to the STM8L10x sub-family.
The following table shows an overview of the firmware library compatibility between the two
sub-families STM8L10x and STM8L15x/STM8L16x and between the different peripherals of
the STM8L15x/STM8L16x sub-family. It describes the differences in terms of:
1.New features like the IrDA, Smartcard, Halfduplex and DAC dual channel features
2. Common features but with different implementations, like the comparator and CLK
initialization.
Doc ID 16993 Rev 313/63
STM8L family compatibilityAN3139
To migrate from the STM8L10x sub-family to the STM8L15x/STM8L16x sub-family when
using the communication peripherals (SPI, I2C or USART), you have to add the additional
peripheral of the same type as the first parameter in every function used from the firmware
library. A full compatibility, in terms of function parameter names, is guaranteed for all
common features.
14/63Doc ID 16993 Rev 3
Table 2.STM8L firmware library compatibility
STM8L10xSTM8L15x/STM8L16x
AN3139STM8L family compatibility
Doc ID 16993 Rev 315/63
Peripheral
Flash
Low density STM8L10x Low density STM8L15xMedium density STM8L15x