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