For designers of STM32 microcontroller applications, it is important to be able to easily
replace 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 memory size, or increasing the number of I/Os. On the other
hand, cost reduction objectives may force you to switch to smaller components and shrink
the PCB area.
This application note is written to help you and analyze the steps you need to migrate from
an existing STM32F1 device to an STM32F0 device. It gathers the most important
information and lists the vital aspects that you need to address.
To migrate your application from STM32F1 series to STM32F0 series, you have to analyze
the hardware migration, the peripheral migration and the firmware migration.
To benefit fully from the information in this application note, the user should be familiar with
the STM32 microcontroller family. You can refer to the following documents that are available
from www.st.com.
●The STM32F1 family reference manuals (RM0008 and RM0041), the STM32F1
datasheets, and the STM32F1 Flash programming manuals (PM0075, PM0063 and
PM0068).
●The STM32F0 family reference manual (RM0091) and the STM32F0 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.
Ta bl e 1 lists the microcontrollers and development tools concerned by this application note.
The entry-level STM32F0 and general-purpose STM32F1xxx families are pin-to-pin
compatible. All peripherals shares the same pins in the two families, but there are some
minor differences between packages. The transition from the STM32F1 series to the
STM32F0 series is simple as only a few pins are impacted (impacted pins are in bold in
Ta bl e 2 ).
Table 2.STM32F1 series and STM32F0 series pinout differences
STM32F1 series STM32F0 series
QFP48 QFP64 PinoutQFP48 QFP64 Pinout
55PD0 - OSC_IN 55PH0 - OSC_IN
66PD1 - OSC_OUT66PH1 - OSC_OUT
-18VSS_4-18PF4
-19VDD_4 -19PF5
3547VSS_23547PF6
3648VDD_23648PF7
2028Boot1/PB22028PB2
The migration from F1 to F0 has no impact on the pinout, except that the user wins 2 or 4
GPIOs for his/her application at VSS/VDD 2 and 4 locations, depending on the package
used.
Doc ID 023072 Rev 15/60
Boot mode compatibilityAN4088
2 Boot mode compatibility
The way to select the boot mode on the F0 family differs from F1 devices. Instead of using
two pins for this setting, F0 gets the nBOOT1 value from an option bit located in the User
option bytes at 0x1FFFF800 memory address. Together with the BOOT0 pin, it selects the
boot mode to the main Flash memory, the SRAM or to the System memory. Tab le 3
summarizes the different configurations available for selecting the Boot mode.
Table 3.Boot modes
F0/F1 Boot mode selection
Boot modeAliasing
BOOT1BOOT0
x0Main Flash memory
01System memory
11Embedded SRAM
Note:The BOOT1 value is the opposite of the nBOOT1 option bit.
Main Flash memory is selected
as boot space
System memory is selected as
boot space
Embedded SRAM is selected as
boot space
6/60Doc ID 023072 Rev 1
AN4088Peripheral migration
3 Peripheral migration
As shown in Ta bl e 3 , there are three categories of peripherals. The common peripherals are
supported with the dedicated firmware library without any modification, except if the
peripheral instance is no longer present. You can change the instance and, of course, all the
related features (clock configuration, pin configuration, interrupt/DMA request).
The modified peripherals such as: ADC, RCC and RTC are different from the F1 series ones
and should be updated to take advantage of the enhancements and the new features in F0
series.
All these modified peripherals in the F0 series are enhanced to obtain smaller silicon print
with features designed to offer advanced high-end capabilities in economical end products
and to fix some limitations present in the F1 series.
3.1 STM32 product cross-compatibility
The STM32 series embeds a set of peripherals which can be classed in three categories:
●The first category is for the peripherals which are, by definition, common to all products.
Those peripherals are identical, so they have the same structure, registers and control
bits. There is no need to perform any firmware change to keep the same functionality,
at the application level, after migration. All the features and behavior remain the same.
●The second category is for the peripherals which are shared by all products but have
only minor differences (in general to support new features). The migration from one
product to another is very easy and does not need any significant new development
effort.
●The third category is for peripherals which have been considerably changed from one
product to another (new architecture, new features...). For this category of peripherals,
the migration will require new development, at the application level.
Ta bl e 4 gives a general overview of this classification.
Doc ID 023072 Rev 17/60
Peripheral migrationAN4088
Table 4.STM32 peripheral compatibility analysis F1 versus F0 series
PeripheralF1 series
SPIYe s
WWDG
IWDG
DBGMCUYe sYesNo JTAG, No Trace
CRC
EXTI
F0
series
Yes++
FeaturePinoutFW driver
Two FIFO available, 4-bit to
16-bit data size selection
Compatibility
IdenticalPartial compatibility
Ye sYesSame featuresNAFull compatibility
Ye sYes+Added a Window modeNAFull compatibility
Identical for the
SWD
Ye sYes++
Ye sYe s +
Added reverse capability and
initial CRC value
Some peripherals are able to
generate event in stop mode
NAPartial compatibility
IdenticalFull compatibility
Kernel clock, arbitration lost
flag and automatic
CEC
Ye sYes++
transmission retry, multi-
IdenticalPartial compatibility
address config, wakeup from
stop mode
DMA
Ye sYe s
1 DMA controller with 5
channels
NAFull compatibility
Partial compatibility
TIM
PWR
Ye sYes+EnhancementIdenticalFull compatibility
Ye sYe s +
No Vref, Vdda can be greater
than Vdd, 1.8 mode for core.
YesYes++New peripheral4 new GPIOsPartial compatibility
8/60Doc ID 023072 Rev 1
AN4088Peripheral migration
Table 4.STM32 peripheral compatibility analysis F1 versus F0 series (continued)
PeripheralF1 series
CANYe sN AN AN AN A
USB FS
Device
EthernetYe sN AN AN AN A
SDIOYe sN AN AN AN A
FSMCYe sN AN AN AN A
Touch
Sensing
COMPNAYesNANANA
SYSCFGNAYesNANANA
Ye sN AN AN AN A
NAYesNANANA
F0
series
FeaturePinoutFW driver
Compatibility
Note:Yes++ = New feature or new architecture
Yes+ = Same feature, but specification change or enhancement
Yes = Feature available
NA = Feature not available
3.2 System architecture
The STM32F0 MCU family has been designed to target an entry-level market, with lowpower capabilities and easy handling. In order to fulfill this aim while keeping the advanced
high-end features proper to the STM32, the core has been changed for a Cortex-M0. Its
small silicon area, coupled to a minimal code footprint, allows for low-cost applications with
32 bits performance. Figure 1 shows the correspondence between the M3 and M0 sets of
instructions. Moving from F1 to F0 requires a recompilation of the code to avoid the use of
unavailable features.
Doc ID 023072 Rev 19/60
Peripheral migrationAN4088
Figure 1.System architecture
Important modifications have been performed on the MCU organization too, starting by
switching from a Harvard to Von Neumann architecture, decreasing the system complexity,
or focusing on SW Debug in order to simplify this precise feature.
3.3 Memory mapping
The peripheral address mapping has been changed in the F0 series versus F1 series. The
main change concerns the GPIOs which have been moved from the APB bus to the AHB
bus to allow them to operate at the maximum speed.
Ta bl e 5 provides the peripheral address mapping correspondence between F0 and F1
series.
Table 5.IP bus mapping differences between STM32F0 and STM32F1 series
Peripheral
TSC
CRC0x40023000
FLITF0x400220000x40022000
RCC0x400210000x40021000
DMA1/DMA0x400200000x40020000
STM32 F0 seriesSTM32 F1 series
BusBase addressBusBase address
0x40024000NANA
0x40023000
AHB1
AHB
10/60Doc ID 023072 Rev 1
AN4088Peripheral migration
Table 5.IP bus mapping differences between STM32F0 and STM32F1 series
STM32 F0 seriesSTM32 F1 series
Peripheral
BusBase addressBusBase address
GPIOF
GPIOD0x48000C000x40011400
GPIOC0x480008000x40011000
GPIOB0x480004000x40010C00
GPIOA0x480000000x40010800
DBGMCU
TIM170x40014800NANA
TIM160x40014400NANA
TIM150x40014000NANA
USART10x40013800
SPI1 / I2S10x400130000x40013000
TIM10x40012C000x40012C00
ADC / ADC10x400124000x40012400
EXTI
AHB2
APB2
APB2
(through
SYSCFG)
0x48001400
APB2
0x40015800NANA
APB2
0x400104000x40010400
0x40011800
0x40013800
SYSCFG + COMPAPB20x40010000NANA
CEC
DAC0x400074000x40007400
PWR0x400070000x40007000
I2C20x400058000x40005800
I2C10x400054000x40005400
USART20x400044000x40004400
SPI20x400038000x40003800
IWWDG / IWDG Own Clock0x400030000x40003000
WWDGAPB10x40002C000x40002C00
RTC
APB1
APB1
(through
PWR)
Doc ID 023072 Rev 111/60
0x40007800
0x40002800 (inc.
BKP registers)
0x40007800
APB1
0x40002800
Peripheral migrationAN4088
Table 5.IP bus mapping differences between STM32F0 and STM32F1 series
STM32 F0 seriesSTM32 F1 series
Peripheral
BusBase addressBusBase address
TIM14
TIM60x40001000
APB1
TIM30x400004000x40000400
TIM20x400000000x40000000
USB device FS SRAMNANA
USB device FSNANA0x40005C00
USART3NANA0x40004800
TIM7NANA0x40001400
TIM4NANA0x40000800
FSMC RegistersNANA
USB OTG FSNANA0x50000000
ETHERNET MAC NANA0x40028000
DMA2NANA0x40020400
GPIOGNANAAPB20x40012000
0x40002000NANA
0x40001000
APB1
0x40006000
APB1
0xA0000000
AHB
SDIONANAAHB0x40018000
TIM11NANA
TIM10NANA0x40015000
TIM9NANA0x40014C00
APB2
ADC2NANA0x40012800
ADC3NANA0x40013C00
TIM8NANA0x40013400
0x40015400
12/60Doc ID 023072 Rev 1
AN4088Peripheral migration
Table 5.IP bus mapping differences between STM32F0 and STM32F1 series
STM32 F0 seriesSTM32 F1 series
Peripheral
BusBase addressBusBase address
CAN2NANA
CAN1NANA0x40006400
UART5NANA0x40005000
UART4NANA0x40004C00
SPI3/I2S3NANA0x40003C00
TIM13NANA0x40001C00
TIM12NANA0x40001800
TIM5NANA0x40000C00
BKP registersNANA0x40006C00
AFIONANAAPB20x40010000
APB1
Note:NA = feature not available.
3.4 Reset and clock controller (RCC) interface
0x40006800
The main differences related to the RCC (Reset and clock controller) in the STM32F0 series
versus STM32F1 series are presented in Tab l e 6.
Table 6.RCC differences between STM32F1 and STM32F0 series
RCCSTM32 F1 seriesSTM32 F0 series
HSI 14NA
HSI8 MHz RC factory-trimmedSimilar
LSI 40 KHz RCSimilar
HSE
LSE32.768 KHzSimilar
PLL
System clock
source
3 - 25 MHz depending on the product
line used
- Connectivity line: main PLL +
2 PLLs for I2S, Ethernet and OTG FS
clock
- Other product lines: main PLL
HSI, HSE or PLLSimilar
High speed internal oscillator dedicated to
ADC
4 - 32 MHz
Main PLL
Doc ID 023072 Rev 113/60
Peripheral migrationAN4088
Table 6.RCC differences between STM32F1 and STM32F0 series (continued)
RCCSTM32 F1 seriesSTM32 F0 series
System clock
frequency
APB1/APB
frequency
RTC clock
source
MCO clock
source
Internal
oscillator
measurement /
calibration
- Up to 72 MHz depending on the
product line used
- 8 MHz after reset using HSI
Up to 36 MHzUp to 48 MHz
LSI, LSE or HSE/128LSI, LSE or HSE clock divided by 32
- LSE & LSI clocks are indirectly measured
through MCO by the timer TIM14 with
respect to HSI/HSE clock
- HSI14/HSE are indirectly measured
through MCO by means of the TIM14
channel 1 input capture with respect to HSI
clock.
In addition to the differences described in the table above, the following additional
adaptation steps may be needed for the migration.
1. S
ystem clock configuration: when moving from F1 series to F0 series, only a few
settings need to be updated in the system clock configuration code; mainly the Flash
settings (configure the right wait states for the system frequency, prefetch
enable/disable) or/and the PLL parameters configuration:
a) In case HSE or HSI is used directly as the system clock source, only the Flash
parameters should be modified.
b) In case PLL (clocked by HSE or HSI) is used as the system clock source, the
Flash parameters and PLL configuration need to be updated.
Ta bl e 7 below provides an example of porting a system clock configuration from F1 to F0
series:
–STM32F100x value line running at maximum performance: system clock at
24 MHz (PLL, clocked by the HSE (8 MHz), used as the system clock source),
Flash with 0 wait states and Flash prefetch queue enabled.
–F0 series running at maximum performance: system clock at 48 MHz (PLL,
clocked by the HSE (8 MHz), used as the system clock source), Flash with 1 wait
state and Flash prefetch enabled.
As shown in Ta bl e 7 , only the Flash settings and PLL parameters (code in Bold Italic) need
to be rewritten to run on F0 series. However, HSE, AHB prescaler and the system clock
source configuration are left unchanged, and APB prescalers are adapted to the maximum
APB frequency in the F0 series.
14/60Doc ID 023072 Rev 1
AN4088Peripheral migration
Note:1The source code presented in Tab le 7 is intentionally simplified (timeout in wait loop
removed) and is based on the assumption that the RCC and Flash registers are at their
reset values.
2For STM32F0xx, you can use the clock configuration tool,
STM32F0xx_Clock_Configuration.xls, to generate a customized system_stm32f0xx.c file
containing a system clock configuration routine, depending on your application
requirements.
Table 7.Example of migrating system clock configuration code from F1 to F0
/* Wait till PLL is ready */
while((RCC->CR & RCC_CR_PLLRDY) == 0)
{
}
/* Select PLL as system clock source ----*/
RCC->CFGR |= (uint32_t)RCC_CFGR_SW_PLL;
/* Wait till PLL is used as system clock source */
while ((RCC->CFGR & (uint32_t)RCC_CFGR_SWS) !=
(uint32_t)RCC_CFGR_SWS_PLL)
{
}
2. Peripheral access configuration: since the address mapping of some peripherals has
been changed in F0 series versus F1 series, you need to use different registers to
[enable/disable] or [enter/exit] the peripheral [clock] or [from reset mode].
Doc ID 023072 Rev 115/60
Peripheral migrationAN4088
Table 8.RCC registers used for peripheral access configuration
BusRegisterComments
AHB
APB1
APB2
RCC_AHBRSTRUsed to [enter/exit] the AHB peripheral from reset
RCC_AHBENRUsed to [enable/disable] the AHB peripheral clock
RCC_APB1RSTRUsed to [enter/exit] the APB1 peripheral from reset
RCC_APB1ENRUsed to [enable/disable] the APB1 peripheral clock
RCC_APB2RSTRUsed to [enter/exit] the APB2 peripheral from reset
RCC_APB2ENRUsed to [enable/disable] the APB2 peripheral clock
To configure the access to a given peripheral, you have first to know to which bus this
peripheral is connected; refer to Ta bl e 5 then, depending on the action needed, program
the right register as described in Ta bl e 8 above. For example, if USART1 is connected to the
APB2 bus, to enable the USART1 clock you have to configure APB2ENR register as follows:
RCC->APB2ENR |= RCC_APB2ENR_USART1EN;
3. Peripheral clock configuration: some peripherals have a dedicated clock source
independent from the system clock, and used to generate the clock required for their
operation:
a) A
DC: in STM32F0 series, the ADC features two possible clock sources:
–The first one is based on the PCLK; a prescaler allows you to reduce the ADC
input frequency by a factor 2 or 4 before getting to the ADC.
–The other one is a completely new feature on stingray; a dedicated 14 MHz
oscillator (HSI14) is integrated on the chip and can be used for the ADC input
frequency.
b) RTC:
in STM32F0 series, the RTC features three possible clock sources:
–The first one is based on the HSE Clock; a prescaler divides its frequency by 32
before going to the RTC.
–The second one is the LSE oscillator.
–The third clock source is the LSI RC with a value of 40 KHz.
3.5 DMA interface
STM32F1 and STM32F0 series use the same fully compatible DMA controller.
The STM32F0 series uses one 5-channel DMA controller when STM32F1 uses two. Each
channel is dedicated to managing memory access requests from one or more peripherals.
The table below presents the correspondence between the DMA requests of the peripherals
in STM32F1 series and STM32F0 series.
16/60Doc ID 023072 Rev 1
AN4088Peripheral migration
Table 9.DMA request differences between STM32F1 series and STM32F0 series
PeripheralDMA requestSTM32F1 series STM32F0 series
Ta bl e 1 0 presents the interrupt vectors in STM32F0 series versus STM32F1 series.
The switch from Cortex-M3 to Cortex-M0 has introduced a reduction of the vector table. This
leads to many differences between the two devices.
Table 10.Interrupt vector differences between STM32F1 series and STM32F0 series
PositionSTM32F1 series STM32F0 series
0WWDGWWDG
1PVDPVD
2TAMPERRTC
3RTCFLASH
4FLASHRCC
5RCCEXTI0_1
6EXTI0EXTI2_3
7EXTI1EXTI4_15
8EXTI2TSC
9EXTI3DMA_CH1
10EXTI4DMA_CH2_CH3
11DMA1_Channel1DMA_CH4_CH5
12DMA1_Channel2ADD_COMP
13DMA1_Channel3TIM1_BRK_UP_TRG_COM
14DMA1_Channel4TIM1_CC
15DMA1_Channel5TIM2
16DMA1_Channel6TIM3
17DMA1_Channel7TIM6_DAC
18ADC1_2Reserved
19
20
21CAN1_RX1TIM16
22CAN1_SCETIM17
23EXTI9_5I2C1
24TIM1_BRK / TIM1_BRK _TIM9 I2C2
25TIM1_UP / TIM1_UP_TIM10 SPI1
26
27TIM1_CCUSART1
CAN1_TX / USB_HP_CAN_TXTIM14
CAN1_RX0 / USB_LP_CAN_RX0 TIM15
TIM1_TRG_COM /
TIM1_TRG_COM_TIM11
SPI2
28TIM2USART2
29TIM3Reserved
Doc ID 023072 Rev 119/60
Peripheral migrationAN4088
Table 10.Interrupt vector differences between STM32F1 series and STM32F0 series
PositionSTM32F1 series STM32F0 series
30TIM4CEC
31I2C1_EVReserved
32I2C1_ERNA
33I2C2_EVNA
34I2C2_ERNA
35SPI1NA
36SPI2NA
37USART1NA
38USART2NA
39USART3NA
40EXTI15_10NA
41RTC_AlarmNA
42OTG_FS_WKUP / USBWakeUpNA
43TIM8_BRK / TIM8_BRK_TIM12
44TIM8_UP / TIM8_UP_TIM13
(1)
(1)
NA
NA
45
TIM8_TRG_COM /
TIM8_TRG_COM_TIM14
(1)
NA
46TIM8_CCNA
47ADC3NA
48FSMCNA
49SDIONA
50TIM5NA
51SPI3NA
52UART4NA
53UART5NA
54TIM6NA
55TIM7NA
56DMA2_Channel1NA
57DMA2_Channel2NA
58DMA2_Channel3NA
59DMA2_Channel4/DMA2_Channel4_5
(1)
NA
60DMA2_Channel5NA
61ETHNA
62ETH_WKUPNA
63CAN2_TXNA
20/60Doc ID 023072 Rev 1
AN4088Peripheral migration
Table 10.Interrupt vector differences between STM32F1 series and STM32F0 series
PositionSTM32F1 series STM32F0 series
64CAN2_RX01NA
65CAN2_RX1NA
66CAN2_SCENA
67OTG_FSNA
1. Depending on the product line used.
The cortex M0 core uses 2 bits to set the interrupt priority without a sub-priority. The user can define 4
levels of priorities in the Nested Vector Interrupt Controller. F1 and Cortex M3 core use 4 bits, thus it can
reach 16 priority levels.
3.7 GPIO interface
The STM32F0 GPIO peripheral embeds new features compared to F1 series, below the
main features:
●GPIO mapped on AHB bus for better performance
●I/O pin multiplexer and mapping: pins are connected to on-chip peripherals/modules
through a multiplexer that allows only one peripheral alternate function (AF) connected
to an I/O pin at a time. In this way, there can be no conflict between peripherals sharing
the same I/O pin.
●More possibilities and features for I/O configuration
The F0 GPIO peripheral is a new design and thus the architecture, features and registers
are different from the GPIO peripheral in the F1 series. Any code written for the F1 series
using the GPIO needs to be rewritten to run on F0 series.
For more information about STM32F0’s GPIO programming and usage, please refer to the
"I/O pin multiplexer and mapping" section in the GPIO chapter of the STM32F0xx Reference
Manual (RM0091).
The table below presents the differences between GPIOs in the STM32F1 series and
STM32F0 series.
Table 11.GPIO differences between STM32F1 series and STM32F0 series
Input mode
General purpose output
GPIOSTM32F1 series STM32F0 series
Floating
PU
PD
PP
OD
Floating
PU
PD
PP
PP + PU
PP + PD
OD
OD + PU
OD + PD
Doc ID 023072 Rev 121/60
Peripheral migrationAN4088
Table 11.GPIO differences between STM32F1 series and STM32F0 series (continued)
GPIOSTM32F1 series STM32F0 series
PP
PP + PU
Alternate function
output
Input / OutputAnalogAnalog
PP
OD
PP + PD
OD
OD + PU
OD + PD
2 MHz
Output speed
Alternate function
selection
Max IO toggle frequency 18 MHz12 MHz
10 MHz
50 MHz
To optimize the number of peripheral I/O
functions for different device packages, it
is possible to remap some alternate
functions to some other pins (software
remap).
2 MHz
10 MHz
48 MHz
Highly flexible pin multiplexing allows no
conflict between peripherals sharing the
same I/O pin.
Alternate function mode
In STM32F1 series
1.The configuration to use an I/O as an alternate function depends on the peripheral
mode used. For example, the USART Tx pin should be configured as an alternate
function push-pull, while the USART Rx pin should be configured as input floating or
input pull-up.
2. To optimize the number of peripheral I/O functions for different device packages
(especially those with a low pin count), it is possible to remap some alternate functions
to other pins by software. For example, the USART2_RX pin can be mapped on PA3
(default remap) or PD6 (by software remap).
In STM32F0 series
1.Whatever the peripheral mode used, the I/O must be configured as an alternate
function, then the system can use the I/O in the proper way (input or output).
2. The I/O pins are connected to on-chip peripherals/modules through a multiplexer that
allows only one peripheral’s alternate function to be connected to an I/O pin at a time.
In this way, there can be no conflict between peripherals sharing the same I/O pin.
Each I/O pin has a multiplexer with eight alternate function inputs (AF0 to AF7) that can
be configured through the GPIOx_AFRL and GPIOx_AFRH registers:
–The peripheral alternate functions are mapped by configuring AF0 to AF7.
3. In addition to this flexible I/O multiplexing architecture, each peripheral has alternate
functions mapped on different I/O pins to optimize the number of peripheral I/O
functions for different device packages. For example, the USART2_RX pin can be
mapped on PA3 or PA15 pin.
22/60Doc ID 023072 Rev 1
AN4088Peripheral migration
Note:Please refer to the “Alternate function mapping” table in the STM32F0x datasheet for the
detailed mapping of the system and the peripheral alternate function I/O pins.
4. Configuration procedure
–Configure the desired I/O as an alternate function in the GPIOx_MODER register
–Select the type, pull-up/pull-down and output speed via the GPIOx_OTYPER,
GPIOx_PUPDR and GPIOx_OSPEEDER registers, respectively
–Connect the I/O to the desired AFx in the GPIOx_AFRL or GPIOx_AFRH register
3.8 EXTI source selection
In STM32F1, the selection of the EXTI line source is performed through EXTIx bits in
AFIO_EXTICRx registers, while in F0 series this selection is done through EXTIx bits in
SYSCFG_EXTICRx registers.
Only the mapping of the EXTICRx registers has been changed, without any changes to the
meaning of the EXTIx bits. However, the maximum range of EXTIx bit values is 0b0101 as
the last PORT is F (in F1 series, the maximum value is 0b0110).
3.9 FLASH interface
The table below presents the difference between the FLASH interface of STM32F1 series
and STM32F0 series, which can be grouped as follows:
Consequently, the F0 Flash programming procedures and registers are different from the F1
series, and any code written for the Flash interface in the F1 series needs to be rewritten to
run on F0 series.
Table 12.FLASH differences between STM32F1 series and STM32F0 series
Main/Program memory
EEPROM memory
FeatureSTM32F1 series STM32F0 series
Start Address0x0800 00000x0800 0000
End Addressup to 0x080F FFFFUp to 0x0805 FFFF
Page size = 2 Kbytes
Granularity
Start Address
End Address
except for Low and Medium
density page size = 1 Kbyte
Available through SW emulation Available through SW emulation
64 pages of 1 Kbyte
System memory
Start Address0x1FFF F0000x1FFF EC00
End Address0x1FFF F7FF0x1FFF F7FF
Doc ID 023072 Rev 123/60
Peripheral migrationAN4088
Table 12.FLASH differences between STM32F1 series and STM32F0 series (continued)
FeatureSTM32F1 series STM32F0 series
Start Address0x1FFF F8000x1FFF F800
Option Bytes
End Address0x1FFF F80F0x1FFF F80B
Start address0x4002 20000x4002 2000
Flash interface
Read Protection
Write protection Protection by 4-Kbyte blockProtection by 4-Kbyte block
User Option bytes
Erase granularityPage (1 or 2 Kbytes)Page (1 Kbyte)
Program modeHalf word (16 bits)Half word (16 bits)
Programming
procedure
Unprotection
Protection
Same for all product lines
Read protection disable
RDP = 0xA55A
Read protection enable
RDP != 0xA55A
STOPSTOP
STANDBYSTANDBY
WDGWDG
NARAM_PARITY_CHECK
NAVDDA_MONITOR
NAnBOOT1
Same as F1 series for Flash
program and erase operations.
Different from F1 series for
Option byte programming
External even
TIM1_TRGO
TIM1_CC4
TIM2_TRGO
TIM3_TRGO
TIM15_TRGO
t
Supply requirement2.4 V to 3.6 V2.4 V to 3.6 V
Input rangeV
<= VIN <= V
REF-
REF+
Vdd and 2.4 <= Vdda <= 3.6
Doc ID 023072 Rev 125/60
Peripheral migrationAN4088
3.11 PWR interface
In STM32F0 series the PWR controller presents some differences vs. F1 series, these
differences are summarized in the table below. However, the programming interface is
unchanged.
Table 14.PWR differences between STM32F1 series and STM32F0 series
PWRSTM32F1 series STM32F0 series
Power supplies
Battery backup
domain
Power supply
supervisor
Low-power
modes
Wake-up
sources
1- VDD = 2.0 to 3.6 V: external power
supply for I/Os and the internal regulator.
Provided externally through VDD pins.
2- VSSA, VDDA = 2.0 to 3.6 V: external
analog power supplies for ADC, Reset
blocks, RCs and PLL. VDDA and VSSA
must be connected to VDD and VSS,
respectively.
3- VBAT = 1.8 to 3.6 V: power supply for
RTC, external clock 32 kHz oscillator and
backup registers (through power switch)
when VDD is not present.
– Backup registers
–RTC
–LSE
– PC13 to PC15 I/Os
Integrated POR / PDR circuitry
Programmable voltage detector (PVD)
Sleep mode
– Any peripheral interrupt/wakeup event
Stop mode
– Any EXTI line event/interrupt
Standby mode
– WKUP pin rising edge
–RTC alarm
– External reset in NRST pin
– IWDG reset
1- VDD = 2.0 to 3.6 V: external power supply for
I/Os and the internal regulator. Provided externally
through VDD pins.
2- VSSA, VDDA = 2.0 to 3.6 V: external analog
power supplies for ADC, DAC, Reset blocks, RCs
and PLL. VDDA and VSSA must be connected to
VDD and VSS, respectively.
3- VBAT = 1.8 to 3.6 V: power supply for RTC,
external clock 32 kHz oscillator and backup
registers (through power switch) when VDD is not
present.
Sleep
– Any peripheral interrupt/wakeup event
Stop mode
– Any EXTI line event/interrupt
Standby mode
– WKUP0 or WKUP1 pin rising edge
– RTC alarm
– External reset in NRST pin
– IWDG reset
26/60Doc ID 023072 Rev 1
AN4088Peripheral migration
3.12 Real-time clock (RTC) interface
The STM32F0 series embeds a new RTC peripheral versus the F1 series. The architecture,
features and programming interface are different.
As a consequence, the F0 RTC programming procedures and registers are different from
those of the F1 series, so any code written for the F1 series using the RTC needs to be
rewritten to run on F0 series.
The F0 RTC provides best-in-class features:
●BCD timer/counter
●Time-of-day clock/calendar featuring subsecond precision with programmable daylight
saving compensation
●A programmable alarm
●Digital calibration circuit
●Time-stamp function for event saving
●Accurate synchronization with an external clock using the subsecond shift feature.
●5 backup registers (20 bytes) which are reset when a tamper detection event occurs
For more information about STM32F0’s RTC features, please refer to RTC chapter of
STM32F0xx Reference Manual (RM0091).
For advanced information about the RTC programming, please refer to Application Note
AN3371 Using the STM32 HW real-time clock (RTC).
3.13 SPI interface
The STM32F0 series embeds a new SPI peripheral versus the F1 series. The architecture,
features and programming interface are modified to introduce new capabilities.
As a consequence, the F0 SPI programming procedures and registers are similar to those
of the F1 series but with new features. The code written for the F1 series using the SPI
needs little rework to run on F0 series, if it did not use new capabilities.
The F0 SPI provides best-in-class added features:
●Enhanced NSS control - NSS pulse mode (NSSP) and TI mode
●Programmable data frame length from 4-bit to 16-bit
●Two 32-bit Tx/Rx FIFO buffers with DMA capability and data packing access for frames
fitted into one byte (up to 8-bit)
●8-bit or 16-bit CRC calculation length for 8-bit and 16-bit data.
Furthermore, the SPI peripheral, available in the F0 family, fixes the CRC limitation present
in the F1 family product. For more information about STM32F0 SPI features, please refer to
SPI chapter of STM32F0xx Reference Manual (RM0091).
Doc ID 023072 Rev 127/60
Peripheral migrationAN4088
3.14 I2C interface
The STM32F0 series embeds a new I2C peripheral versus the F1 series. The architecture,
features and programming interface are different.
As a consequence, the F0 I2C programming procedures and registers are different from
those of the F1 series, so any code written for the F1 series using the I2C needs to be
rewritten to run on F0 series.
The F0 I2C provides best-in-class new features:
●Communication events managed by hardware.
●Programmable analog and digital noise filters.
●Independent clock source: HSI or SYSCLK.
●Wake-up from STOP mode.
●Fast mode + (up to 1MHz) with 20mA I/O output current drive.
●7-bit and 10-bit addressing mode, multiple 7-bit slave address support with
configurable masks.
●Address sequence automatic sending (both 7-bit and 10-bit) in master mode.
●Automatic end of communication management in master mode.
●Programmable Hold and Setup times.
●Command and Data Acknowledge control.
For more information about STM32F0 I2C features, please refer to I2C chapter of
STM32F0xx Reference Manual (RM0091).
28/60Doc ID 023072 Rev 1
AN4088Peripheral migration
3.15 USART interface
The STM32F0 series embeds a new USART peripheral versus the F1 series. The
architecture, features and programming interface are modified to introduce new capabilities.
As a consequence, the F0 USART programming procedures and registers are modified
from those of the F1 series, so any code written for the F1 series using the USART needs to
be updated to run on F0 series.
The F0 USART provides best-in-class added features:
●A choice of independent clock sources allowing
–UART functionality and wake-up from low power modes,
–convenient baud-rate programming independently of the APB clock
reprogramming.
●Smartcard emulation capability: T=0 with auto retry and T=1
●Swappable Tx/Rx pin configuration
●Binary data inversion
●Tx/Rx pin active level inversion
●Transmit/receive enable acknowledge flags
●New Interrupt sources with flags:
–Address/character match
–Block length detection and timeout detection
●Timeout feature
●Modbus communication
●Overrun flag disable
●DMA disable on reception error
●Wake-up from STOP mode
●Auto baud rate detection capability
●Driver Enable signal (DE) for RS485 mode
For more information about STM32F0 USART features, please refer to USART chapter of
STM32F0xx Reference Manual (RM0091).
Doc ID 023072 Rev 129/60
Peripheral migrationAN4088
3.16 CEC interface
The STM32F0 series embeds a new CEC peripheral versus the F1 series. The architecture,
features and programming interface are modified to introduce new capabilities.
As a consequence, the F0 CEC programming procedures and registers are different from
those of the F1 series, so any code written for the F1 series using the CEC needs to be
rewritten to run on F0 series.
The F0 CEC provides best-in-class added features:
●32 KHz CEC kernel with dual clock
–LSE
–HSI/244
●Reception in listen mode
●Rx tolerance margin: standard or extended
●Arbitration (signal free time): standard (by H/W) or aggressive (by S/W)
●Arbitration lost detected flag/interrupt
●Automatic transmission retry supported in case of arbitration lost
●Multi-address configuration
●Wake-up from STOP mode
●Receive error detection
–Bit rising error (with stop reception)
–Short bit period error
–Long bit period error
●Configurable error bit generation
–on bit rising error detection
–on long bit period error detection
●Transmission under run detection
●Reception overrun detection
The following features present in the F1 family are now handled by the new F0 CEC features
and thus are no more available.
●Bit timing error mode & bit period error mode, by the new error handler
●Configurable prescaler frequency divider, by the CEC fixed kernel clock
For more information about STM32F0 CEC features, please refer to CEC chapter of
STM32F0xx Reference Manual (RM0091).
30/60Doc ID 023072 Rev 1
AN4088Firmware migration using the library
4 Firmware migration using the library
This section describes how to migrate an application based on STM32F1xx Standard
Peripherals Library in order to use the STM32F0xx Standard Peripherals Library.
The STM32F1xx and STM32F0xx libraries have the same architecture and are CMSIS
compliant; they use the same driver naming and the same APIs for all compatible
peripherals.
Only a few peripheral drivers need to be updated to migrate the application from an F1
series to an F0 series product.
Note:In the rest of this chapter (unless otherwise specified), the term “STM32F0xx Library” is
used to refer to the STM32F0xx Standard Peripherals Library, and the term “STM32F10x
Library” is used to refer to the STM32F10x Standard Peripherals Library.
4.1 Migration steps
To update your application code to run on STM32F0xx Library, you have to follow the steps
listed below:
1.Update the toolchain startup files
a) Project files: device connections and Flash memory loader. These files are
provided with the latest version of your toolchain that supports STM32F0xxx
devices. For more information, please refer to your toolchain documentation.
b) Linker configuration and vector table location files: these files are developed
following the CMSIS standard and are included in the STM32F0xx Library install
package under the following directory: Libraries\CMSIS\Device\ST\STM32F0xx.
2. Add STM32F0xx Library source files to the application sources
a) Replace the stm32f10x_conf.h file of your application with stm32f0xx_conf.h
provided in STM32F0xx Library.
b) Replace the existing stm32f10x_it.c/stm32f10x_it.h files in your application with
stm32f0xx_it.c/Stm32f0xx_it.h provided in STM32F0xx Library.
3. Update the part of your application code that uses the RCC, PWR, GPIO, FLASH, ADC
and RTC drivers. Further details are provided in the next section.
Note:The STM32F0xx Library comes with a rich set of examples (67 in total) demonstrating how
to use the different peripherals (under Project\STM32F0xx_StdPeriph_Examples\).
4.2 RCC driver
1.System clock configuration: as presented in section 3.4: Reset and clock controller
(RCC) interface, the STM32 F0 and F1 series have the same clock sources and
configuration procedures. However, there are some differences related to the product
voltage range, PLL configuration, maximum frequency and Flash wait state
configuration. Thanks to the CMSIS layer, these differences are hidden from the
application code; you only have to replace the system_stm32f10x.c file by
system_stm32f0xx.c file. This file provides an implementation of SystemInit() function
Doc ID 023072 Rev 131/60
Firmware migration using the libraryAN4088
used to configure the microcontroller system at start-up and before branching to the
main() program.
Note:For STM32F0xx, you can use the clock configuration tool,
STM32F0xx_Clock_Configuration.xls, to generate a customized SystemInit() function
depending on your application requirements. For more information, refer to AN4055 “Clock
configuration tool for STM32F0xx microcontrollers”.
2. Peripheral access configuration
: as presented in section 3.4: Reset and clock controller
(RCC) interface, you need to call different functions to [enable/disable] or [enter/exit]
the peripheral [clock] or [from reset mode]. For example, GPIOA is mapped on AHB
bus on F0 series (APB2 bus on F1 series). To enable its clock, you have to use the
in the F1 series.
Refer to Tab le 5 for the peripheral bus mapping changes between F0 and F1 series.
3.
Peripheral clock configuration
Some STM32F0xx peripherals support dual clock features. The table below summarizes the
clock sources for those IPs in comparison with STM32F10xx peripherals.
Table 15.STM32F10x and STM32F0xx source clock API correspondence
Peripherals
ADCAPB2 clock with prescaler
CECAPB1 clock with prescaler
I2CAPB1 clock
SPI/I2SSystem clockSystem clock
USART
Source clock in STM32F10xx
device
1.USART1 can be clocked with:
- PCLK2 (72 MHz Max)
2. Other USARTs can be clocked
with:
- PCLK1 (36 MHz Max)
Source clock in STM32F0xx device
- HSI14: by default
- APB2 clock/2
- APB2 clock/4
- HSI/244: by default
- LSE
- APB clock: Clock for the digital interface
(used for register read/write access). This
clock is equal to the APB2 clock.
1. I2C1can be clocked with:
- System clock
- HSI
2. I2C2 can be only clocked with:
- HSI
1.USART1 can be clocked with:
- system clock
- LSE clock
- HSI clock
- APB clock (PCLK)
2. USART2 can be only clocked with:
- system clock
32/60Doc ID 023072 Rev 1
AN4088Firmware migration using the library
4.3 FLASH driver
The table below presents the FLASH driver API correspondence between STM32F10x and
STM32F0xx Libraries. You can easily update your application code by replacing
STM32F10x functions by the corresponding function in the STM32F0xx Library.
Table 16.STM32F10x and STM32F0xx FLASH driver API correspondence
STM32F10x Flash driver APISTM32F0xx Flash driver API
1.The configuration to use an I/O as an alternate function depends on the peripheral
mode used; for example, the USART Tx pin should be configured as an alternate
function push-pull while the USART Rx pin should be configured as an input floating or
an input pull-up.
2. To optimize the number of peripheral I/O functions for different device packages, it is
possible, by software, to remap some alternate functions to other pins. For example,
the USART2_RX pin can be mapped on PA3 (default remap) or PD6 (by software
remap).
In STM32 F0 series
1.Whatever the peripheral mode used, the I/O must be configured as an alternate
function, then the system can use the I/O in the proper way (input or output).
2. The I/O pins are connected to onboard peripherals/modules through a multiplexer that
allows only one peripheral’s alternate function to be connected to an I/O pin at a time.
In this way, there can be no conflict between peripherals sharing the same I/O pin.
Each I/O pin has a multiplexer with sixteen alternate function inputs (AF0 to AF15) that
can be configured through the GPIO_PinAFConfig () function:
–After reset, all I/Os are connected to the system’s alternate function 0 (AF0)
–The peripherals’ alternate functions are mapped by configuring AF1 to AF7.
3. In addition to this flexible I/O multiplexing architecture, each peripheral has alternate
functions mapped onto different I/O pins to optimize the number of peripheral I/O
functions for different device packages; for example, the USART2_RX pin can be
mapped on PA3 or PA15 pin.
4. Configuration procedure:
–Connect the pin to the desired peripherals' Alternate Function (AF) using
GPIO_PinAFConfig() function
–Use GPIO_Init() function to configure the I/O pin:
- Configure the desired pin in alternate function mode using
GPIO_InitStructure->GPIO_Mode = GPIO_Mode_AF;
- Select the type, pull-up/pull-down and output speed via
GPIO_PuPd, GPIO_OType and GPIO_Speed members
The example below shows how to remap USART2 Tx/Rx I/Os on PD5/PD6 pins in STM32
F1 series:
/* Enable APB2 interface clock for GPIOD and AFIO (AFIO peripheral is used
to configure the I/Os software remapping) */
In F0 series, the configuration of the EXTI line source pin is performed in the SYSCFG
peripheral (instead of AFIO in F1 series). As a result, the source code should be updated as
follows:
The table below presents the PWR driver API correspondence between STM32F10x and
STM32F0xx Libraries. You can easily update your application code by replacing
STM32F10x functions by the corresponding function in the STM32F0xx Library.
Table 20.STM32F10x and STM32F0xx PWR driver API correspondence
(*) More Wake up pins are available on STM32 F0 series.
4.11 Backup data registers
In STM32 F1 series, the Backup data registers are managed through the BKP peripheral,
while in F0 series they are a part of the RTC peripheral (there is no BKP peripheral).
The example below shows how to write to/read from Backup data registers in STM32 F1
series:
uint16_t BKPdata = 0;
FlagStatus PWR_GetFlagStatus(uint32_t
PWR_FLAG);
...
/* Enable APB2 interface clock for PWR and BKP */
RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR | RCC_APB1Periph_BKP, ENABLE);
/* Enable write access to Backup domain */
PWR_BackupAccessCmd(ENABLE);
/* Write data to Backup data register 1 */
BKP_WriteBackupRegister(BKP_DR1, 0x3210);
/* Read data from Backup data register 1 */
BKPdata = BKP_ReadBackupRegister(BKP_DR1);
In F0 series, you have to update this code as follows:
/* Enable write access to RTC domain */
PWR_RTCAccessCmd(ENABLE);
/* Write data to Backup data register 1 */
RTC_WriteBackupRegister(RTC_BKP_DR1, 0x3220);
/* Read data from Backup data register 1 */
BKPdata = RTC_ReadBackupRegister(RTC_BKP_DR1);
44/60Doc ID 023072 Rev 1
AN4088Firmware migration using the library
The main changes in the source code in F0 series versus F1 are described below:
1.There is no BKP peripheral
2. Write to/read from Backup data registers are done through RTC driver
3. Backup data registers naming changed from BKP_DRx to RTC_BKP_DRx, and
numbering starts from 0 instead of 1.
4.12 CEC application code
You can easily update your CEC application code by replacing STM32F10x functions by the
corresponding function in the STM32F0xx Library.The table below presents the CEC driver
API correspondence between STM32F10x and STM32F0xx Libraries.
Table 21.STM32F10xx and STM32F0xx CEC driver API correspondence
STM32F0xx devices incorporate new I2C features. The table below presents the I2C driver
API correspondence between STM32F10x and STM32F0xx Libraries. You can update your
application code replacing STM32F10x functions by the corresponding function in the
STM32F0xx Library.
Table 22.STM32F10xx and STM32F0xx I2C driver API correspondence
Though some API functions are identical in STM32F1 and STM32F0, in most cases the
application code needs to be rewritten when moving from STM32F1 to STM32F0. However,
STMicroelectronics provides an "I2C Communication peripheral application library (CPAL)",
which allows to move seamlessly from STM32F1 to STM32F0: user needs to modify only
few settings without any changes on the application code. For more details about STM32F1
I2C CPAL, please refer to UM1029. For STM32F0, the I2C CPAL is provided within the
Standard Peripherals Library package."
The STM32F0xx USART includes enhancements in comparison with STM32F10xx USART.
Table9. presents the USART driver API correspondence between STM32F10x and
STM32F0xx Libraries.
Doc ID 023072 Rev 153/60
Firmware migration using the libraryAN4088
Table 24.STM32F10x and STM32F0xx USART driver API correspondence
STM32F10xx USART driver API STM32F0xx USART driver API
Existing IWDG available on STM32F10xx and STM32F0xx devices have the same
specifications, with window capability additional feature in F0 series which detect over
frequency on external oscillators. The table below lists the IWDG driver APIs.
Table 25.STM32F10xx and STM32Fxx IWDG driver API correspondence
STM32F10xx IWDG driver APISTM32F0xx IWDG driver API
Information in this document is provided solely in connection with ST products. STMicroelectronics NV and its subsidiaries (“ST”) reserve the
right to make changes, corrections, modifications or improvements, to this document, and the products and services described herein at any
time, without notice.
All ST products are sold pursuant to ST’s terms and conditions of sale.
Purchasers are solely responsible for the choice, selection and use of the ST products and services described herein, and ST assumes no
liability whatsoever relating to the choice, selection or use of the ST products and services described herein.
No license, express or implied, by estoppel or otherwise, to any intellectual property rights is granted under this document. If any part of this
document refers to any third party products or services it shall not be deemed a license grant by ST for the use of such third party products
or services, or any intellectual property contained therein or considered as a warranty covering the use in any manner whatsoever of such
third party products or services or any intellectual property contained therein.
UNLESS OTHERWISE SET FORTH IN ST’S TERMS AND CONDITIONS OF SALE ST DISCLAIMS ANY EXPRESS OR IMPLIED
WARRANTY WITH RESPECT TO THE USE AND/OR SALE OF ST PRODUCTS INCLUDING WITHOUT LIMITATION IMPLIED
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE (AND THEIR EQUIVALENTS UNDER THE LAWS
OF ANY JURISDICTION), OR INFRINGEMENT OF ANY PATENT, COPYRIGHT OR OTHER INTELLECTUAL PROPERTY RIGHT.
UNLESS EXPRESSLY APPROVED IN WRITING BY TWO AUTHORIZED ST REPRESENTATIVES, ST PRODUCTS ARE NOT
RECOMMENDED, AUTHORIZED OR WARRANTED FOR USE IN MILITARY, AIR CRAFT, SPACE, LIFE SAVING, OR LIFE SUSTAINING
APPLICATIONS, NOR IN PRODUCTS OR SYSTEMS WHERE FAILURE OR MALFUNCTION MAY RESULT IN PERSONAL INJURY,
DEATH, OR SEVERE PROPERTY OR ENVIRONMENTAL DAMAGE. ST PRODUCTS WHICH ARE NOT SPECIFIED AS "AUTOMOTIVE
GRADE" MAY ONLY BE USED IN AUTOMOTIVE APPLICATIONS AT USER’S OWN RISK.
Resale of ST products with provisions different from the statements and/or technical features set forth in this document shall immediately void
any warranty granted by ST for the ST product or service described herein and shall not create or extend in any manner whatsoever, any
liability of ST.
ST and the ST logo are trademarks or registered trademarks of ST in various countries.
Information in this document supersedes and replaces all information previously supplied.
The ST logo is a registered trademark of STMicroelectronics. All other names are the property of their respective owners.