AN4088
Application note
Migrating between STM32F1 and STM32F0 series microcontrollers
Introduction
For designers of STM32 microcontroller applications, it is important to be able to easily
replace one microcontroller type by another within the same product family. One key
advantage of STM32 microcontrollers is their simplified porting thanks to a strong focus on
compatibility across the portfolio. Migrating an application to a different microcontroller is
often needed to fulfill higher product requirements more demanding on memory size or with
increased number of I/Os. Cost reduction is another reason for change to smaller
components and shrunk PCB area.
This application note is written to help users with the analysis of the steps required to
migrate from an existing STM32F1 series device to an STM32F0 series device. It gathers
the most important information and lists the mandatory aspects that users need to address.
To migrate an application from STM32F1 series to STM32F0 series, users have to analyze
the hardware migration, the peripheral migration and the firmware migration.
To benefit fully from the information included in this application note, users should be
familiar with the STM32 microcontroller family. Refer to the following documents available
from
www.st.com.
STM32F1xx family reference manuals (RM0008 and RM0041), STM32F1xx product
datasheets, and STM32F1xx Flash programming manuals (PM0075, PM0063 and
PM0068).
STM32F0xx family reference manuals (RM0091 and RM0360) and STM32F0xx
product datasheets.
For an overview of the whole STM32 series and a comparison of the different features of
each STM32 product series, please refer to AN3364
Migration and compatibility guidelines
for STM32 microcontroller applications.
Table 1
lists the microcontrollers and development tools addressed by this application note.
Table 1. Applicable products
Type
Microcontroller
STM32F0 series,
STM32F1 series.
Part numbers
Note:
The following notational convention is used in the rest of the document:
STM32F0xx is used instead of STM32F0xxxx when referring to products of STM32F0
series, and STM32F1xx is used instead of STM32F1xxxx when referring to products of
STM32F1 series.
February 2015
DocID023072 Rev 3
1/71
www.st.com
1
Contents
AN4088
Contents
1
Hardware migration from STM32F1 to STM32F0
series . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
Boot mode compatibility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
Peripheral migration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
3.1
3.2
3.3
3.4
3.5
3.6
3.7
3.8
3.9
3.10
3.11
3.12
3.13
3.14
3.15
3.16
3.17
STM32 product cross-compatibility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
System architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
Memory mapping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
Reset and clock controller (RCC) interface . . . . . . . . . . . . . . . . . . . . . . . 14
DMA interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
Interrupt vectors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
GPIO interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
EXTI source selection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
Flash interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
ADC interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
PWR interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
Real-time clock (RTC) interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
SPI interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
I2C interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
USART interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
CEC interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
USB interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
2
3
4
Firmware migration using the library . . . . . . . . . . . . . . . . . . . . . . . . . . 40
4.1
4.2
4.3
4.4
4.5
Migration steps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
RCC driver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
Flash driver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
CRC driver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
GPIO configuration update . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
4.5.1
4.5.2
Output mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
Input mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
2/71
DocID023072 Rev 3
AN4088
4.5.3
4.5.4
Contents
Analog mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
Alternate function mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
4.6
4.7
4.8
4.9
4.10
4.11
4.12
4.13
4.14
4.15
4.16
EXTI Line0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
NVIC interrupt configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
ADC configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
DAC driver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
PWR driver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
Backup data registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
CEC application code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
I2C driver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
SPI driver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
USART driver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
IWDG driver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
5
Revision history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
DocID023072 Rev 3
3/71
3
List of tables
AN4088
List of tables
Table 1.
Table 2.
Table 3.
Table 4.
Table 5.
Table 6.
Table 7.
Table 8.
Table 9.
Table 10.
Table 11.
Table 12.
Table 13.
Table 14.
Table 15.
Table 16.
Table 17.
Table 18.
Table 19.
Table 20.
Table 21.
Table 22.
Table 23.
Table 24.
Table 25.
Table 26.
Table 27.
Table 28.
Table 29.
Table 30.
Table 31.
Applicable products. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
STM32F1 series and STM32F03x/STM32F05x device pinout differences. . . . . . . . . . . . . . 6
STM32F1 series and STM32F04x device pinout differences . . . . . . . . . . . . . . . . . . . . . . . . 6
STM32F1 series and STM32F07x device pinout differences . . . . . . . . . . . . . . . . . . . . . . . . 7
STM32F1 series and STM32F09x device pinout differences . . . . . . . . . . . . . . . . . . . . . . . . 7
Boot modes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
STM32 peripheral compatibility analysis, STM32F1 versus STM32F0 series . . . . . . . . . . . 9
IP bus mapping differences between STM32F0 and STM32F1 series. . . . . . . . . . . . . . . . 12
RCC differences between STM32F1 and STM32F0 series . . . . . . . . . . . . . . . . . . . . . . . . 14
Example of migrating system clock configuration code from STM32F1 to STM32F0 . . . . 16
RCC registers used for peripheral access configuration. . . . . . . . . . . . . . . . . . . . . . . . . . . 17
DMA request differences between STM32F1 series and STM32F09x family . . . . . . . . . . 18
DMA request differences between STM32F1 series and STM32F07x family . . . . . . . . . . 21
DMA request differences between STM32F1 series and STM32F05x/STM32F03x
families. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
Interrupt vector differences between STM32F1 series and STM32F0
series . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
GPIO differences between STM32F1 series and STM32F0 series . . . . . . . . . . . . . . . . . . 29
Flash differences between STM32F1 series and STM32F0 series . . . . . . . . . . . . . . . . . . 31
ADC differences between STM32F1 series and STM32F0 series . . . . . . . . . . . . . . . . . . . 33
PWR differences between STM32F1 series and STM32F0 series. . . . . . . . . . . . . . . . . . . 34
STM32F10x and STM32F0xx source clock API correspondence . . . . . . . . . . . . . . . . . . . 41
STM32F10x and STM32F0xx Flash driver API correspondence . . . . . . . . . . . . . . . . . . . . 42
STM32F10xx and STM32F0xx CRC driver API correspondence. . . . . . . . . . . . . . . . . . . . 44
STM32F10x and STM32F0xx MISC driver API correspondence . . . . . . . . . . . . . . . . . . . . 50
STM32F10x and STM32F0xx DAC driver API correspondence. . . . . . . . . . . . . . . . . . . . . 52
STM32F10x and STM32F0xx PWR driver API correspondence . . . . . . . . . . . . . . . . . . . . 54
STM32F10xx and STM32F0xx CEC driver API correspondence . . . . . . . . . . . . . . . . . . . . 56
STM32F10xx and STM32F0xx I2C driver API correspondence . . . . . . . . . . . . . . . . . . . . . 58
STM32F10xx and STM32F0xx SPI driver API correspondence. . . . . . . . . . . . . . . . . . . . . 62
STM32F10x and STM32F0xx USART driver API correspondence . . . . . . . . . . . . . . . . . . 65
STM32F10xx and STM32Fxx IWDG driver API correspondence. . . . . . . . . . . . . . . . . . . . 69
Document revision history. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
4/71
DocID023072 Rev 3
AN4088
List of figures
List of figures
Figure 1.
System architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
DocID023072 Rev 3
5/71
5