RM0360-STM32F030x4-x6-x8-xC-070x6-xB

Introduction

This reference manual targets application developers. It provides complete information on how to use the STM32F030x4/x6/x8/xC and STM32F070x6/xB microcontroller memory and peripherals.

It applies to STM32F030x4/x6/x8/xC and STM32F070x6/xB devices.

For the purpose of this manual, STM32F030x4/x6/x8/xC and STM32F070x6/xB microcontrollers are referred to as STM32F0x0.

The STM32F0x0 is a family of microcontrollers with different memory sizes, packages and peripherals.

For ordering information, mechanical and electrical device characteristics, please refer to the corresponding datasheet.

For information on the Arm ® Cortex ® -M0 core, please refer to the Arm ® Cortex ® -M0 technical reference manual .

STM32F030x4/x6/x8/xC and STM32F070x6/xB microcontrollers include ST state-of-the-art patented technology.

Contents

3.5.8Write protection register (FLASH_WRPR) . . . . .64
3.5.9Flash register map . . . . .65
4Option bytes . . . . .66
4.1Option byte description . . . . .67
4.1.1User and read protection option byte . . . . .67
4.1.2User data option byte . . . . .68
4.1.3Write protection option byte . . . . .68
4.1.4Option byte map . . . . .69
5Cyclic redundancy check calculation unit (CRC) . . . . .70
5.1Introduction . . . . .70
5.2CRC main features . . . . .70
5.3CRC functional description . . . . .71
5.3.1CRC block diagram . . . . .71
5.3.2CRC internal signals . . . . .71
5.3.3CRC operation . . . . .71
5.4CRC registers . . . . .72
5.4.1CRC data register (CRC_DR) . . . . .72
5.4.2CRC independent data register (CRC_IDR) . . . . .73
5.4.3CRC control register (CRC_CR) . . . . .73
5.4.4CRC initial value (CRC_INIT) . . . . .74
5.4.5CRC register map . . . . .75
6Power control (PWR) . . . . .76
6.1Power supplies . . . . .76
6.1.1Independent A/D converter supply and reference voltage . . . . .76
6.1.2Voltage regulator . . . . .77
6.2Power supply supervisor . . . . .77
6.2.1Power on reset (POR) / power down reset (PDR) . . . . .77
6.3Low-power modes . . . . .78
6.3.1Slowing down system clocks . . . . .79
6.3.2Peripheral clock gating . . . . .80
6.3.3Sleep mode . . . . .80
6.3.4Stop mode . . . . .81
6.3.5Standby mode . . . . .83
6.3.6RTC wakeup from low-power mode . . . . .84
6.4Power control registers . . . . .85
6.4.1Power control register (PWR_CR) . . . . .85
6.4.2Power control/status register (PWR_CSR) . . . . .86
6.4.3PWR register map . . . . .87
7Reset and clock control (RCC) . . . . .88
7.1Reset . . . . .88
7.1.1Power reset . . . . .88
7.1.2System reset . . . . .88
7.1.3RTC domain reset . . . . .89
7.2Clocks . . . . .90
7.2.1HSE clock . . . . .93
7.2.2HSI clock . . . . .94
7.2.3PLL . . . . .95
7.2.4LSE clock . . . . .95
7.2.5LSI clock . . . . .96
7.2.6System clock (SYSCLK) selection . . . . .96
7.2.7Clock security system (CSS) . . . . .96
7.2.8ADC clock . . . . .97
7.2.9RTC clock . . . . .97
7.2.10Independent watchdog clock . . . . .97
7.2.11Clock-out capability . . . . .97
7.2.12Internal/external clock measurement with TIM14 . . . . .98
7.3Low-power modes . . . . .99
7.4RCC registers . . . . .100
7.4.1Clock control register (RCC_CR) . . . . .100
7.4.2Clock configuration register (RCC_CFGR) . . . . .101
7.4.3Clock interrupt register (RCC_CIR) . . . . .104
7.4.4APB peripheral reset register 2 (RCC_APB2RSTR) . . . . .107
7.4.5APB peripheral reset register 1 (RCC_APB1RSTR) . . . . .108
7.4.6AHB peripheral clock enable register (RCC_AHBENR) . . . . .110
7.4.7APB peripheral clock enable register 2 (RCC_APB2ENR) . . . . .111
7.4.8APB peripheral clock enable register 1 (RCC_APB1ENR) . . . . .113
7.4.9RTC domain control register (RCC_BDCR) . . . . .115
7.4.10Control/status register (RCC_CSR) . . . . .116
7.4.11AHB peripheral reset register (RCC_AHBRSTR) . . . . .118
7.4.12Clock configuration register 2 (RCC_CFGR2) .....119
7.4.13Clock configuration register 3 (RCC_CFGR3) .....120
7.4.14Clock control register 2 (RCC_CR2) .....121
7.4.15RCC register map .....123
8General-purpose I/Os (GPIO) .....125
8.1Introduction .....125
8.2GPIO main features .....125
8.3GPIO functional description .....125
8.3.1General-purpose I/O (GPIO) .....127
8.3.2I/O pin alternate function multiplexer and mapping .....127
8.3.3I/O port control registers .....128
8.3.4I/O port data registers .....128
8.3.5I/O data bitwise handling .....128
8.3.6GPIO locking mechanism .....129
8.3.7I/O alternate function input/output .....129
8.3.8External interrupt/wake-up lines .....129
8.3.9Input configuration .....130
8.3.10Output configuration .....130
8.3.11Alternate function configuration .....131
8.3.12Analog configuration .....132
8.3.13Using the HSE or LSE oscillator pins as GPIOs .....133
8.3.14Using the GPIO pins in the RTC supply domain .....133
8.4GPIO registers .....134
8.4.1GPIO port mode register (GPIOx_MODER)
(x =A to D, F) .....
134
8.4.2GPIO port output type register (GPIOx_OTYPER)
(x = A to D, F) .....
134
8.4.3GPIO port output speed register (GPIOx_OSPEEDR)
(x = A to D, F) .....
135
8.4.4GPIO port pull-up/pull-down register (GPIOx_PUPDR)
(x = A to ,D, F) .....
135
8.4.5GPIO port input data register (GPIOx_IDR)
(x = A to D, F) .....
136
8.4.6GPIO port output data register (GPIOx_ODR)
(x = A to D, F) .....
136
8.4.7GPIO port bit set/reset register (GPIOx_BSRR)
(x = A to D, F) .....
137
8.4.8GPIO port configuration lock register (GPIOx_LCKR)
(x = A to B) . . . . .
137
8.4.9GPIO alternate function low register (GPIOx_AFRL)
(x = A to D, ) . . . . .
138
8.4.10GPIO alternate function high register (GPIOx_AFRH)
(x = A to D, F) . . . . .
139
8.4.11GPIO port bit reset register (GPIOx_BRR) (x = A to D, F) . . . . .139
8.4.12GPIO register map . . . . .140
9System configuration controller (SYSCFG) . . . . .142
9.1SYSCFG registers . . . . .142
9.1.1SYSCFG configuration register 1 (SYSCFG_CFGR1) . . . . .142
9.1.2SYSCFG external interrupt configuration register 1
(SYSCFG_EXTICR1) . . . . .
144
9.1.3SYSCFG external interrupt configuration register 2
(SYSCFG_EXTICR2) . . . . .
145
9.1.4SYSCFG external interrupt configuration register 3
(SYSCFG_EXTICR3) . . . . .
145
9.1.5SYSCFG external interrupt configuration register 4
(SYSCFG_EXTICR4) . . . . .
146
9.1.6SYSCFG configuration register 2 (SYSCFG_CFGR2) . . . . .147
9.1.7SYSCFG register maps . . . . .148
10Direct memory access controller (DMA) . . . . .149
10.1Introduction . . . . .149
10.2DMA main features . . . . .149
10.3DMA implementation . . . . .150
10.3.1DMA . . . . .150
10.3.2DMA request mapping . . . . .150
10.4DMA functional description . . . . .153
10.4.1DMA block diagram . . . . .153
10.4.2DMA transfers . . . . .154
10.4.3DMA arbitration . . . . .155
10.4.4DMA channels . . . . .155
10.4.5DMA data width, alignment and endianness . . . . .159
10.4.6DMA error management . . . . .160
10.5DMA interrupts . . . . .161
10.6DMA registers . . . . .161
10.6.1DMA interrupt status register (DMA_ISR) . . . . .161
10.6.2DMA interrupt flag clear register (DMA_IFCR) . . . . .163
10.6.3DMA channel x configuration register (DMA_CCRx) . . . . .164
10.6.4DMA channel x number of data to transfer register (DMA_CNDTRx) . . . . .166
10.6.5DMA channel x peripheral address register (DMA_CPARx) . . . . .167
10.6.6DMA channel x memory address register (DMA_CMARx) . . . . .168
10.6.7DMA channel selection register (DMA_CSELR) . . . . .168
10.6.8DMA register map . . . . .169
11Interrupts and events . . . . .171
11.1Nested vectored interrupt controller (NVIC) . . . . .171
11.1.1NVIC main features . . . . .171
11.1.2SysTick calibration value register . . . . .171
11.1.3Interrupt and exception vectors . . . . .171
11.2Extended interrupts and events controller (EXTI) . . . . .173
11.2.1Main features . . . . .173
11.2.2Block diagram . . . . .174
11.2.3Event management . . . . .174
11.2.4Functional description . . . . .174
11.2.5External and internal interrupt/event line mapping . . . . .176
11.3EXTI registers . . . . .177
11.3.1Interrupt mask register (EXTI_IMR) . . . . .177
11.3.2Event mask register (EXTI_EMR) . . . . .177
11.3.3Rising trigger selection register (EXTI_RTSR) . . . . .177
11.3.4Falling trigger selection register (EXTI_FTSR) . . . . .178
11.3.5Software interrupt event register (EXTI_SWIER) . . . . .179
11.3.6Pending register (EXTI_PR) . . . . .179
11.3.7EXTI register map . . . . .181
12Analog-to-digital converter (ADC) . . . . .182
12.1Introduction . . . . .182
12.2ADC main features . . . . .183
12.3ADC functional description . . . . .184
12.3.1ADC pins and internal signals . . . . .184
12.3.2Calibration (ADCAL) . . . . .185
12.3.3ADC on-off control (ADEN, ADDIS, ADRDY) . . . . .186
12.3.4ADC clock (CKMODE) . . . . .188
12.3.5Configuring the ADC . . . . .189
12.3.6Channel selection (CHSEL, SCANDIR) . . . . .189
12.3.7Programmable sampling time (SMP) . . . . .190
12.3.8Single conversion mode (CONT = 0) . . . . .190
12.3.9Continuous conversion mode (CONT = 1) . . . . .191
12.3.10Starting conversions (ADSTART) . . . . .191
12.3.11Timings . . . . .192
12.3.12Stopping an ongoing conversion (ADSTP) . . . . .193
12.4Conversion on external trigger and trigger polarity (EXTSEL, EXTEN) . . . . .193
12.4.1Discontinuous mode (DISCEN) . . . . .194
12.4.2Programmable resolution (RES) - Fast conversion mode . . . . .194
12.4.3End of conversion, end of sampling phase (EOC, EOSMP flags) . . . . .195
12.4.4End of conversion sequence (EOS flag) . . . . .195
12.4.5Example timing diagrams (single/continuous modes
hardware/software triggers) . . . . .
196
12.5Data management . . . . .198
12.5.1Data register and data alignment (ADC_DR, ALIGN) . . . . .198
12.5.2ADC overrun (OVR, OVRMOD) . . . . .198
12.5.3Managing a sequence of data converted without using the DMA . . . . .199
12.5.4Managing converted data without using the DMA without overrun . . . . .199
12.5.5Managing converted data using the DMA . . . . .199
12.6Low-power features . . . . .201
12.6.1Wait mode conversion . . . . .201
12.6.2Auto-off mode (AUTOFF) . . . . .202
12.7Analog window watchdog . . . . .203
12.7.1Description of the analog watchdog . . . . .203
12.7.2ADC_AWD1_OUT output signal generation . . . . .204
12.7.3Analog watchdog threshold control . . . . .206
12.8Temperature sensor and internal reference voltage . . . . .207
12.9ADC interrupts . . . . .210
12.10ADC registers . . . . .211
12.10.1ADC interrupt and status register (ADC_ISR) . . . . .211
12.10.2ADC interrupt enable register (ADC_IER) . . . . .212
12.10.3ADC control register (ADC_CR) . . . . .214
12.10.4ADC configuration register 1 (ADC_CFGR1) . . . . .216
12.10.5ADC configuration register 2 (ADC_CFGR2) . . . . .220
12.10.6ADC sampling time register (ADC_SMPR)220
12.10.7ADC watchdog threshold register (ADC_TR)221
12.10.8ADC channel selection register (ADC_CHSELR)221
12.10.9ADC data register (ADC_DR)222
12.10.10ADC common configuration register (ADC_CCR)223
12.11ADC register map223
13Advanced-control timers (TIM1)225
13.1TIM1 introduction225
13.2TIM1 main features225
13.3TIM1 functional description227
13.3.1Time-base unit227
13.3.2Counter modes229
13.3.3Repetition counter239
13.3.4Clock sources241
13.3.5Capture/compare channels244
13.3.6Input capture mode247
13.3.7PWM input mode248
13.3.8Forced output mode249
13.3.9Output compare mode249
13.3.10PWM mode250
13.3.11Complementary outputs and dead-time insertion254
13.3.12Using the break function256
13.3.13Clearing the OCxREF signal on an external event259
13.3.146-step PWM generation261
13.3.15One-pulse mode262
13.3.16Encoder interface mode263
13.3.17Timer input XOR function266
13.3.18Interfacing with Hall sensors266
13.3.19TIMx and external trigger synchronization268
13.3.20Timer synchronization271
13.3.21Debug mode271
13.4TIM1 registers272
13.4.1TIM1 control register 1 (TIM1_CR1)272
13.4.2TIM1 control register 2 (TIM1_CR2)273
13.4.3TIM1 slave mode control register (TIM1_SMCR)275
13.4.4TIM1 DMA/interrupt enable register (TIM1_DIER)278
13.4.5TIM1 status register (TIM1_SR) .....280
13.4.6TIM1 event generation register (TIM1_EGR) .....281
13.4.7TIM1 capture/compare mode register 1 (TIM1_CCMR1) .....283
13.4.8TIM1 capture/compare mode register 2 (TIM1_CCMR2) .....286
13.4.9TIM1 capture/compare enable register (TIM1_CCER) .....288
13.4.10TIM1 counter (TIM1_CNT) .....291
13.4.11TIM1 prescaler (TIM1_PSC) .....292
13.4.12TIM1 auto-reload register (TIM1_ARR) .....292
13.4.13TIM1 repetition counter register (TIM1_RCR) .....292
13.4.14TIM1 capture/compare register 1 (TIM1_CCR1) .....293
13.4.15TIM1 capture/compare register 2 (TIM1_CCR2) .....293
13.4.16TIM1 capture/compare register 3 (TIM1_CCR3) .....294
13.4.17TIM1 capture/compare register 4 (TIM1_CCR4) .....295
13.4.18TIM1 break and dead-time register (TIM1_BDTR) .....295
13.4.19TIM1 DMA control register (TIM1_DCR) .....297
13.4.20TIM1 DMA address for full transfer (TIM1_DMAR) .....298
13.4.21TIM1 register map .....299
14General-purpose timers (TIM3) .....301
14.1TIM3 introduction .....301
14.2TIM3 main features .....301
14.3TIM3 functional description .....302
14.3.1Time-base unit .....302
14.3.2Counter modes .....304
14.3.3Clock sources .....315
14.3.4Capture/compare channels .....318
14.3.5Input capture mode .....320
14.3.6PWM input mode .....322
14.3.7Forced output mode .....323
14.3.8Output compare mode .....323
14.3.9PWM mode .....324
14.3.10One-pulse mode .....328
14.3.11Clearing the OCxREF signal on an external event .....329
14.3.12Encoder interface mode .....330
14.3.13Timer input XOR function .....332
14.3.14Timers and external trigger synchronization .....333
14.3.15Timer synchronization .....336
14.3.16Debug mode342
14.4TIM3 registers343
14.4.1TIM3 control register 1 (TIM3_CR1)343
14.4.2TIM3 control register 2 (TIM3_CR2)345
14.4.3TIM3 slave mode control register (TIM3_SMCR)346
14.4.4TIM3 DMA/Interrupt enable register (TIM3_DIER)348
14.4.5TIM3 status register (TIM3_SR)349
14.4.6TIM3 event generation register (TIM3_EGR)352
14.4.7TIM3 capture/compare mode register 1 (TIM3_CCMR1)353
14.4.8TIM3 capture/compare mode register 2 (TIM3_CCMR2)356
14.4.9TIM3 capture/compare enable register (TIM3_CCER)357
14.4.10TIM3 counter (TIM3_CNT)359
14.4.11TIM3 prescaler (TIM3_PSC)359
14.4.12TIM3 auto-reload register (TIM3_ARR)359
14.4.13TIM3 capture/compare register 1 (TIM3_CCR1)360
14.4.14TIM3 capture/compare register 2 (TIM3_CCR2)360
14.4.15TIM3 capture/compare register 3 (TIM3_CCR3)360
14.4.16TIM3 capture/compare register 4 (TIM3_CCR4)362
14.4.17TIM3 DMA control register (TIM3_DCR)362
14.4.18TIM3 DMA address for full transfer (TIM3_DMAR)363
14.4.19TIM3 register map365
15Basic timer (TIM6/TIM7)367
15.1TIM6/TIM7 introduction367
15.2TIM6/TIM7 main features367
15.3TIM6/TIM7 functional description368
15.3.1Time-base unit368
15.3.2Counter modes370
15.3.3Clock source374
15.3.4Debug mode374
15.4TIM6/TIM7 registers375
15.4.1TIM6/TIM7 control register 1 (TIMx_CR1)375
15.4.2TIM6/TIM7 DMA/Interrupt enable register (TIMx_DIER)376
15.4.3TIM6/TIM7 status register (TIMx_SR)377
15.4.4TIM6/TIM7 event generation register (TIMx_EGR)377
15.4.5TIM6/TIM7 counter (TIMx_CNT)377
15.4.6TIM6/TIM7 prescaler (TIMx_PSC)378
15.4.7TIM6/TIM7 auto-reload register (TIMx_ARR) .....378
15.4.8TIM6/TIM7 register map .....379
16General-purpose timer (TIM14) .....380
16.1TIM14 introduction .....380
16.2TIM14 main features .....380
16.3TIM14 functional description .....381
16.3.1Time-base unit .....381
16.3.2Counter operation .....382
16.3.3Clock source .....385
16.3.4Capture/compare channels .....385
16.3.5Input capture mode .....387
16.3.6Forced output mode .....388
16.3.7Output compare mode .....388
16.3.8PWM mode .....390
16.3.9Debug mode .....391
16.4TIM14 registers .....391
16.4.1TIM14 control register 1 (TIM14_CR1) .....391
16.4.2TIM14 interrupt enable register (TIM14_DIER) .....392
16.4.3TIM14 status register (TIM14_SR) .....393
16.4.4TIM14 event generation register (TIM14_EGR) .....393
16.4.5TIM14 capture/compare mode register 1 [alternate] (TIM14_CCMR1) .....394
16.4.6TIM14 capture/compare mode register 1 [alternate] (TIM14_CCMR1) .....395
16.4.7TIM14 capture/compare enable register (TIM14_CCER) .....396
16.4.8TIM14 counter (TIM14_CNT) .....397
16.4.9TIM14 prescaler (TIM14_PSC) .....398
16.4.10TIM14 auto-reload register (TIM14_ARR) .....398
16.4.11TIM14 capture/compare register 1 (TIM14_CCR1) .....398
16.4.12TIM14 option register (TIM14_OR) .....399
16.4.13TIM14 register map .....399
17General-purpose timers (TIM15/16/17) .....401
17.1TIM15/16/17 introduction .....401
17.2TIM15 main features .....401
17.3TIM16 and TIM17 main features .....403
17.4TIM15/16/17 functional description .....404
17.4.1Time-base unit . . . . .404
17.4.2Counter operation . . . . .406
17.4.3Repetition counter . . . . .410
17.4.4Clock sources . . . . .411
17.4.5Capture/compare channels . . . . .413
17.4.6Input capture mode . . . . .416
17.4.7PWM input mode (only for TIM15) . . . . .417
17.4.8Forced output mode . . . . .417
17.4.9Output compare mode . . . . .418
17.4.10PWM mode . . . . .419
17.4.11Complementary outputs and dead-time insertion . . . . .420
17.4.12Using the break function . . . . .422
17.4.13One-pulse mode . . . . .425
17.4.14TIM15 external trigger synchronization . . . . .426
17.4.15Timer synchronization (TIM15) . . . . .429
17.4.16Debug mode . . . . .429
17.5TIM15 registers . . . . .430
17.5.1TIM15 control register 1 (TIM15_CR1) . . . . .430
17.5.2TIM15 control register 2 (TIM15_CR2) . . . . .431
17.5.3TIM15 slave mode control register (TIM15_SMCR) . . . . .432
17.5.4TIM15 DMA/interrupt enable register (TIM15_DIER) . . . . .434
17.5.5TIM15 status register (TIM15_SR) . . . . .435
17.5.6TIM15 event generation register (TIM15_EGR) . . . . .437
17.5.7TIM15 capture/compare mode register 1 [alternate] (TIM15_CCMR1) . . . . .438
17.5.8TIM15 capture/compare mode register 1 [alternate] (TIM15_CCMR1) . . . . .439
17.5.9TIM15 capture/compare enable register (TIM15_CCER) . . . . .441
17.5.10TIM15 counter (TIM15_CNT) . . . . .444
17.5.11TIM15 prescaler (TIM15_PSC) . . . . .444
17.5.12TIM15 auto-reload register (TIM15_ARR) . . . . .444
17.5.13TIM15 repetition counter register (TIM15_RCR) . . . . .445
17.5.14TIM15 capture/compare register 1 (TIM15_CCR1) . . . . .445
17.5.15TIM15 capture/compare register 2 (TIM15_CCR2) . . . . .445
17.5.16TIM15 break and dead-time register (TIM15_BDTR) . . . . .446
17.5.17TIM15 DMA control register (TIM15_DCR) . . . . .448
17.5.18TIM15 DMA address for full transfer (TIM15_DMAR) . . . . .449
17.5.19TIM15 register map . . . . .449
17.6TIM16/TIM17 registers . . . . .450
19.4.6IWDG register map .....477
20System window watchdog (WWDG) .....478
20.1Introduction .....478
20.2WWDG main features .....478
20.3WWDG functional description .....478
20.3.1WWDG block diagram .....479
20.3.2Enabling the watchdog .....479
20.3.3Controlling the down-counter .....479
20.3.4How to program the watchdog timeout .....479
20.3.5Debug mode .....480
20.4WWDG interrupts .....481
20.5WWDG registers .....481
20.5.1WWDG control register (WWDG_CR) .....481
20.5.2WWDG configuration register (WWDG_CFR) .....482
20.5.3WWDG status register (WWDG_SR) .....482
20.5.4WWDG register map .....483
21Real-time clock (RTC) .....484
21.1Introduction .....484
21.2RTC main features .....485
21.3RTC implementation .....485
21.4RTC functional description .....486
21.4.1RTC block diagram .....486
21.4.2GPIOs controlled by the RTC .....488
21.4.3Clock and prescalers .....489
21.4.4Real-time clock and calendar .....490
21.4.5Programmable alarm .....490
21.4.6Periodic auto-wake-up .....491
21.4.7RTC initialization and configuration .....491
21.4.8Reading the calendar .....493
21.4.9Resetting the RTC .....494
21.4.10RTC synchronization .....494
21.4.11RTC reference clock detection .....495
21.4.12RTC smooth digital calibration .....496
21.4.13Time-stamp function .....498
22.4.8Data transfer . . . . .534
22.4.9I2C slave mode . . . . .536
22.4.10I2C master mode . . . . .545
22.4.11I2C_TIMINGR register configuration examples . . . . .556
22.4.12SMBus specific features . . . . .558
22.4.13SMBus initialization . . . . .561
22.4.14SMBus: I2C_TIMEOUTR register configuration examples . . . . .563
22.4.15SMBus slave mode . . . . .563
22.4.16Error conditions . . . . .570
22.4.17DMA requests . . . . .572
22.4.18Debug mode . . . . .573
22.5I2C low-power modes . . . . .573
22.6I2C interrupts . . . . .574
22.7I2C registers . . . . .575
22.7.1I2C control register 1 (I2C_CR1) . . . . .575
22.7.2I2C control register 2 (I2C_CR2) . . . . .577
22.7.3I2C own address 1 register (I2C_OAR1) . . . . .579
22.7.4I2C own address 2 register (I2C_OAR2) . . . . .580
22.7.5I2C timing register (I2C_TIMINGR) . . . . .581
22.7.6I2C timeout register (I2C_TIMEOUTR) . . . . .582
22.7.7I2C interrupt and status register (I2C_ISR) . . . . .583
22.7.8I2C interrupt clear register (I2C_ICR) . . . . .585
22.7.9I2C PEC register (I2C_PECR) . . . . .586
22.7.10I2C receive data register (I2C_RXDR) . . . . .587
22.7.11I2C transmit data register (I2C_TXDR) . . . . .587
22.7.12I2C register map . . . . .588
23Universal synchronous/asynchronous receiver transmitter (USART/UART) . . . . .590
23.1Introduction . . . . .590
23.2USART main features . . . . .590
23.3USART implementation . . . . .592
23.4USART functional description . . . . .593
23.4.1USART character description . . . . .594
23.4.2USART transmitter . . . . .595
23.4.3USART receiver . . . . .598
23.4.4USART baud rate generation . . . . .604
23.4.5Tolerance of the USART receiver to clock deviation . . . . .606
23.4.6USART auto baud rate detection . . . . .607
23.4.7Multiprocessor communication using USART . . . . .607
23.4.8USART parity control . . . . .610
23.4.9USART synchronous mode . . . . .610
23.4.10USART Single-wire Half-duplex communication . . . . .613
23.4.11USART continuous communication in DMA mode . . . . .613
23.4.12RS232 hardware flow control and RS485 driver enable
using USART . . . . .
616
23.5USART in low-power modes . . . . .618
23.6USART interrupts . . . . .619
23.7USART registers . . . . .620
23.7.1USART control register 1 (USART_CR1) . . . . .620
23.7.2USART control register 2 (USART_CR2) . . . . .623
23.7.3USART control register 3 (USART_CR3) . . . . .626
23.7.4USART baud rate register (USART_BRR) . . . . .628
23.7.5USART receiver timeout register (USART_RTOR) . . . . .628
23.7.6USART request register (USART_RQR) . . . . .629
23.7.7USART interrupt and status register (USART_ISR) . . . . .630
23.7.8USART interrupt flag clear register (USART_ICR) . . . . .633
23.7.9USART receive data register (USART_RDR) . . . . .634
23.7.10USART transmit data register (USART_TDR) . . . . .635
23.7.11USART register map . . . . .635
24Serial peripheral interface (SPI) . . . . .637
24.1Introduction . . . . .637
24.2SPI main features . . . . .637
24.3SPI implementation . . . . .638
24.4SPI functional description . . . . .638
24.4.1General description . . . . .638
24.4.2Communications between one master and one slave . . . . .639
24.4.3Standard multislave communication . . . . .642
24.4.4Multimaster communication . . . . .642
24.4.5Slave select (NSS) pin management . . . . .643
24.4.6Communication formats . . . . .644
24.4.7Configuration of SPI . . . . .646
24.4.8Procedure for enabling SPI .....647
24.4.9Data transmission and reception procedures .....647
24.4.10SPI status flags .....657
24.4.11SPI error flags .....658
24.4.12NSS pulse mode .....659
24.4.13TI mode .....659
24.4.14CRC calculation .....660
24.5SPI interrupts .....662
24.6SPI registers .....663
24.6.1SPI control register 1 (SPIx_CR1) .....663
24.6.2SPI control register 2 (SPIx_CR2) .....665
24.6.3SPI status register (SPIx_SR) .....667
24.6.4SPI data register (SPIx_DR) .....668
24.6.5SPI CRC polynomial register (SPIx_CRCPR) .....669
24.6.6SPI Rx CRC register (SPIx_RXCRCR) .....669
24.6.7SPI Tx CRC register (SPIx_TXCRCR) .....669
24.6.8SPI register map .....671
25Universal serial bus full-speed device interface (USB) .....672
25.1Introduction .....672
25.2USB main features .....672
25.3USB implementation .....672
25.4USB functional description .....673
25.4.1Description of USB blocks .....674
25.5Programming considerations .....675
25.5.1Generic USB device programming .....675
25.5.2System and power-on reset .....676
25.5.3Double-buffered endpoints .....681
25.5.4Isochronous transfers .....683
25.5.5Suspend/Resume events .....684
25.6USB and USB SRAM registers .....687
25.6.1Common registers .....687
25.6.2Buffer descriptor table .....700
25.6.3USB register map .....703
26Debug support (DBG) .....705

27 Device electronic signature . . . . . 720

Appendix A Code examples. . . . . 721

A.2.2Main flash memory programming sequence . . . . .721
A.2.3Page erase sequence . . . . .722
A.2.4Mass erase sequence . . . . .723
A.2.5Option byte unlocking sequence . . . . .723
A.2.6Option byte programming sequence . . . . .724
A.2.7Option byte erasing sequence . . . . .724
A.3Clock controller code examples . . . . .725
A.3.1HSE start sequence . . . . .725
A.3.2PLL configuration modification . . . . .726
A.3.3MCO selection . . . . .726
A.3.4Clock measurement configuration with TIM14 . . . . .727
A.4GPIO code examples . . . . .728
A.4.1Lock sequence . . . . .728
A.4.2Alternate function selection sequence . . . . .728
A.4.3Analog GPIO configuration . . . . .729
A.5DMA code examples . . . . .729
A.5.1DMA channel configuration sequence . . . . .729
A.6Interrupts and event code examples . . . . .730
A.6.1NVIC initialization . . . . .730
A.6.2External interrupt selection . . . . .730
A.7ADC code examples . . . . .731
A.7.1ADC calibration . . . . .731
A.7.2ADC enable sequence . . . . .731
A.7.3ADC disable sequence . . . . .732
A.7.4ADC clock selection . . . . .732
A.7.5Single conversion sequence - software trigger . . . . .733
A.7.6Continuous conversion sequence - software trigger . . . . .733
A.7.7Single conversion sequence - hardware trigger . . . . .734
A.7.8Continuous conversion sequence - hardware trigger . . . . .734
A.7.9DMA one shot mode sequence . . . . .735
A.7.10DMA circular mode sequence . . . . .735
A.7.11Wait mode sequence . . . . .735
A.7.12Auto Off and no wait mode sequence . . . . .736
A.7.13Auto Off and wait mode sequence . . . . .736
A.7.14Analog watchdog . . . . .736
A.7.15Temperature configuration . . . . .737
A.7.16Temperature computation . . . . .737
A.8Timers . . . . .738
A.8.1Upcounter on TI2 rising edge . . . . .738
A.8.2Up counter on each 2 ETR rising edges . . . . .739
A.8.3Input capture configuration . . . . .739
A.8.4Input capture data management . . . . .740
A.8.5PWM input configuration . . . . .741
A.8.6PWM input with DMA configuration . . . . .741
A.8.7Output compare configuration . . . . .742
A.8.8Edge-aligned PWM configuration example . . . . .742
A.8.9Center-aligned PWM configuration example . . . . .743
A.8.10ETR configuration to clear OCxREF . . . . .744
A.8.11Encoder interface . . . . .744
A.8.12Reset mode . . . . .745
A.8.13Gated mode . . . . .745
A.8.14Trigger mode . . . . .746
A.8.15External clock mode 2 + trigger mode . . . . .746
A.8.16One-Pulse mode . . . . .747
A.8.17Timer prescaling another timer . . . . .747
A.8.18Timer enabling another timer . . . . .748
A.8.19Master and slave synchronization . . . . .749
A.8.20Two timers synchronized by an external trigger . . . . .750
A.8.21DMA burst feature . . . . .751
A.9IRTIM code examples . . . . .752
A.9.1TIM16 and TIM17 configuration . . . . .752
A.9.2IRQHandler for IRTIM . . . . .753
A.10DBG code examples . . . . .754
A.10.1DBG read device ID . . . . .754
A.10.2DBG debug in Low-power mode . . . . .754
A.11I2C code examples . . . . .754
A.11.1I2C configured in master mode to receive . . . . .754
A.11.2I2C configured in master mode to transmit . . . . .754
A.11.3I2C configured in slave mode . . . . .755
A.11.4I2C master transmitter . . . . .755
A.11.5I2C master receiver . . . . .755
A.11.6I2C slave transmitter . . . . .756
A.11.7I2C slave receiver . . . . .756

Important security notice . . . . . 766

Revision history . . . . . 767

List of tables

Table 1.STM32F0x0 memory boundary addresses . . . . .39
Table 2.STM32F0x0 peripheral register boundary addresses. . . . .40
Table 3.Boot modes. . . . .44
Table 4.Flash memory organization (STM32F030x4, STM32F030x6, STM32F070x6 and STM32F030x8 devices). . . . .47
Table 5.Flash memory organization (STM32F070xB, STM32F030xC devices) . . . . .48
Table 6.Flash memory read protection status . . . . .56
Table 7.Access status versus protection level and execution modes . . . . .57
Table 8.Flash interrupt request . . . . .58
Table 9.Flash interface - Register map and reset values . . . . .65
Table 10.Option byte format . . . . .66
Table 11.Option byte organization. . . . .66
Table 12.Option byte map and ST production values . . . . .69
Table 13.CRC internal input/output signals . . . . .71
Table 14.CRC register map and reset values . . . . .75
Table 15.Low-power mode summary . . . . .79
Table 16.Sleep-now. . . . .81
Table 17.Sleep-on-exit. . . . .81
Table 18.Stop mode . . . . .82
Table 19.Standby mode. . . . .83
Table 20.PWR register map and reset values. . . . .87
Table 21.RCC register map and reset values . . . . .123
Table 22.Port bit configuration table . . . . .126
Table 23.GPIO register map and reset values . . . . .140
Table 24.SYSCFG register map and reset values. . . . .148
Table 25.DMA implementation . . . . .150
Table 26.DMA requests for each channel on STM32F030x4/x6/x8 and STM32F070x6/x8 devices . . . . .151
Table 27.DMA requests for each channel on STM32F030xC devices . . . . .152
Table 28.Programmable data width and endian behavior (when PINC = MINC = 1) . . . . .159
Table 29.DMA interrupt requests. . . . .161
Table 30.DMA register map and reset values . . . . .169
Table 31.Vector table. . . . .171
Table 32.External interrupt/event controller register map and reset values. . . . .181
Table 33.ADC input/output pins. . . . .184
Table 34.ADC internal input/output signals . . . . .185
Table 35.External triggers . . . . .185
Table 36.Latency between trigger and start of conversion . . . . .189
Table 37.Configuring the trigger polarity . . . . .193
Table 38.tSAR timings depending on resolution . . . . .195
Table 39.Analog watchdog comparison. . . . .204
Table 40.Analog watchdog channel selection . . . . .204
Table 41.ADC interrupts . . . . .210
Table 42.ADC register map and reset values . . . . .223
Table 43.Counting direction versus encoder signals. . . . .264
Table 44.TIMx Internal trigger connection . . . . .277
Table 45.Output control bits for complementary OCx and OCxN channels with break feature. . . . .290
Table 46.TIM1 register map and reset values . . . . .299
Table 47.Counting direction versus encoder signals . . . . .331
Table 48.TIM3 internal trigger connection . . . . .348
Table 49.Output control bit for standard OCx channels . . . . .358
Table 50.TIM3 register map and reset values . . . . .365
Table 51.TIM6/TIM7 register map and reset values . . . . .379
Table 52.Output control bit for standard OCx channels . . . . .397
Table 53.TIM14 register map and reset values . . . . .399
Table 54.TIMx Internal trigger connection . . . . .433
Table 55.Output control bits for complementary OCx and OCxN channels with break feature . . . . .443
Table 56.TIM15 register map and reset values . . . . .449
Table 57.Output control bits for complementary OCx and OCxN channels with break feature . . . . .460
Table 58.TIM16/TIM17 register map and reset values . . . . .466
Table 59.IWDG register map and reset values . . . . .477
Table 60.WWDG register map and reset values . . . . .483
Table 61.STM32F0x0 RTC implementation . . . . .485
Table 62.RTC pin PC13 configuration . . . . .488
Table 63.LSE pin PC14 configuration . . . . .489
Table 64.LSE pin PC15 configuration . . . . .489
Table 65.Effect of low-power modes on RTC . . . . .501
Table 66.Interrupt control bits . . . . .501
Table 67.RTC register map and reset values . . . . .521
Table 68.STM32F0x0 I2C implementation . . . . .525
Table 69.I2C input/output pins . . . . .527
Table 70.I2C internal input/output signals . . . . .527
Table 71.Comparison of analog vs. digital filters . . . . .529
Table 72.I2C-SMBus specification data setup and hold times . . . . .532
Table 73.I2C configuration . . . . .536
Table 74.I2C-SMBus specification clock timings . . . . .547
Table 75.Examples of timing settings for f I2CCLK = 8 MHz . . . . .557
Table 76.Examples of timing settings for f I2CCLK = 16 MHz . . . . .557
Table 77.Examples of timing settings for f I2CCLK = 48 MHz . . . . .558
Table 78.SMBus timeout specifications . . . . .560
Table 79.SMBus with PEC configuration . . . . .561
Table 80.Examples of TIMEOUTA settings (max t TIMEOUT = 25 ms) . . . . .563
Table 81.Examples of TIMEOUTB settings . . . . .563
Table 82.Examples of TIMEOUTA settings (max t IDLE = 50 µs) . . . . .563
Table 83.Effect of low-power modes on the I2C . . . . .573
Table 84.I2C interrupt requests . . . . .574
Table 85.I2C register map and reset values . . . . .588
Table 86.STM32F0x0 USART features . . . . .592
Table 87.Noise detection from sampled data . . . . .603
Table 88.Error calculation for programmed baud rates at f CK = 48 MHz in both cases of oversampling by 16 or by 8 . . . . .605
Table 89.Tolerance of the USART receiver when BRR [3:0] = 0000 . . . . .606
Table 90.Tolerance of the USART receiver when BRR [3:0] is different from 0000 . . . . .606
Table 91.Frame formats . . . . .610
Table 92.Effect of low-power modes on the USART . . . . .618
Table 93.USART interrupt requests . . . . .619
Table 94.USART register map and reset values . . . . .635
Table 95.STM32F0x0 SPI implementation . . . . .638
Table 96.SPI interrupt requests . . . . .662

Table 97. SPI register map and reset values . . . . . 671
Table 98. STM32F0x0 USB implementation . . . . . 672
Table 99. Double-buffering buffer flag definition . . . . . 682
Table 100. Bulk double-buffering memory buffers usage . . . . . 682
Table 101. Isochronous memory buffers usage . . . . . 684
Table 102. Resume event detection . . . . . 685
Table 103. Reception status encoding . . . . . 698
Table 104. Endpoint type encoding . . . . . 698
Table 105. Endpoint kind meaning . . . . . 698
Table 106. Transmission status encoding . . . . . 699
Table 107. Definition of allocated buffer memory . . . . . 702
Table 108. USB register map and reset values . . . . . 703
Table 109. SW debug port pins . . . . . 707
Table 110. DEV_ID and REV_ID field values . . . . . 708
Table 111. Packet request (8-bits) . . . . . 709
Table 112. ACK response (3 bits) . . . . . 709
Table 113. DATA transfer (33 bits) . . . . . 710
Table 114. SW-DP registers . . . . . 711
Table 115. 32-bit debug port registers addressed through the shifted value A[3:2] . . . . . 712
Table 116. Core debug registers . . . . . 712
Table 117. DBG register map and reset values . . . . . 719
Table 118. Document revision history . . . . . 767

List of figures

Figure 1.System architecture . . . . .35
Figure 2.Memory map . . . . .38
Figure 3.Programming procedure . . . . .51
Figure 4.Flash memory Page erase procedure . . . . .53
Figure 5.Flash memory mass erase procedure . . . . .54
Figure 6.CRC calculation unit block diagram . . . . .71
Figure 7.Power supply overview . . . . .76
Figure 8.Power on reset/power down reset waveform . . . . .77
Figure 9.Simplified diagram of the reset circuit . . . . .89
Figure 10.Clock tree (STM32F030x4, STM32F030x6 and STM32F030x8 devices) . . . . .91
Figure 11.Clock tree (STM32F070x6, STM32F070xB and STM32F030xC). . . . .92
Figure 12.HSE/ LSE clock sources . . . . .93
Figure 13.Frequency measurement with TIM14 in capture mode. . . . .98
Figure 14.Basic structure of an I/O port bit . . . . .126
Figure 15.Input floating / pull up / pull down configurations . . . . .130
Figure 16.Output configuration . . . . .131
Figure 17.Alternate function configuration . . . . .132
Figure 18.High impedance-analog configuration . . . . .133
Figure 19.DMA request mapping . . . . .151
Figure 20.DMA block diagram . . . . .153
Figure 21.Extended interrupts and events controller (EXTI) block diagram . . . . .174
Figure 22.External interrupt/event GPIO mapping . . . . .176
Figure 23.ADC block diagram . . . . .184
Figure 24.ADC calibration . . . . .186
Figure 25.Enabling/disabling the ADC . . . . .187
Figure 26.ADC clock scheme . . . . .188
Figure 27.Analog to digital conversion time . . . . .192
Figure 28.ADC conversion timings . . . . .192
Figure 29.Stopping an ongoing conversion . . . . .193
Figure 30.Single conversions of a sequence, software trigger . . . . .196
Figure 31.Continuous conversion of a sequence, software trigger. . . . .196
Figure 32.Single conversions of a sequence, hardware trigger . . . . .197
Figure 33.Continuous conversions of a sequence, hardware trigger . . . . .197
Figure 34.Data alignment and resolution . . . . .198
Figure 35.Example of overrun (OVR) . . . . .199
Figure 36.Wait mode conversion (continuous mode, software trigger). . . . .201
Figure 37.Behavior with WAIT = 0, AUTOFF = 1 . . . . .202
Figure 38.Behavior with WAIT = 1, AUTOFF = 1 . . . . .203
Figure 39.Analog watchdog guarded area . . . . .204
Figure 40.ADC_AWD1_OUT signal generation . . . . .205
Figure 41.ADC_AWD1_OUT signal generation (AWD flag not cleared by software) . . . . .206
Figure 42.ADC1_AWD_OUT signal generation (on a single channel) . . . . .206
Figure 43.Analog watchdog threshold update . . . . .207
Figure 44.Temperature sensor and VREFINT channel block diagram . . . . .208
Figure 45.Advanced-control timer block diagram . . . . .226
Figure 46.Counter timing diagram with prescaler division change from 1 to 2 . . . . .228
Figure 47.Counter timing diagram with prescaler division change from 1 to 4 . . . . .228
Figure 48.Counter timing diagram, internal clock divided by 1 . . . . .230
Figure 49.Counter timing diagram, internal clock divided by 2 . . . . .230
Figure 50.Counter timing diagram, internal clock divided by 4 . . . . .231
Figure 51.Counter timing diagram, internal clock divided by N . . . . .231
Figure 52.Counter timing diagram, update event when ARPE=0
(TIMx_ARR not preloaded). . . . .
232
Figure 53.Counter timing diagram, update event when ARPE=1
(TIMx_ARR preloaded). . . . .
232
Figure 54.Counter timing diagram, internal clock divided by 1 . . . . .233
Figure 55.Counter timing diagram, internal clock divided by 2 . . . . .234
Figure 56.Counter timing diagram, internal clock divided by 4 . . . . .234
Figure 57.Counter timing diagram, internal clock divided by N . . . . .234
Figure 58.Counter timing diagram, update event when repetition counter is not used. . . . .235
Figure 59.Counter timing diagram, internal clock divided by 1, TIMx_ARR = 0x6 . . . . .236
Figure 60.Counter timing diagram, internal clock divided by 2 . . . . .237
Figure 61.Counter timing diagram, internal clock divided by 4, TIMx_ARR=0x36 . . . . .237
Figure 62.Counter timing diagram, internal clock divided by N . . . . .238
Figure 63.Counter timing diagram, update event with ARPE=1 (counter underflow) . . . . .238
Figure 64.Counter timing diagram, Update event with ARPE=1 (counter overflow) . . . . .239
Figure 65.Update rate examples depending on mode and TIMx_RCR register settings . . . . .240
Figure 66.Control circuit in normal mode, internal clock divided by 1 . . . . .241
Figure 67.TI2 external clock connection example. . . . .242
Figure 68.Control circuit in external clock mode 1 . . . . .243
Figure 69.External trigger input block . . . . .243
Figure 70.Control circuit in external clock mode 2 . . . . .244
Figure 71.Capture/compare channel (example: channel 1 input stage) . . . . .245
Figure 72.Capture/compare channel 1 main circuit . . . . .245
Figure 73.Output stage of capture/compare channel (channel 1 to 3) . . . . .246
Figure 74.Output stage of capture/compare channel (channel 4). . . . .246
Figure 75.PWM input mode timing . . . . .248
Figure 76.Output compare mode, toggle on OC1 . . . . .250
Figure 77.Edge-aligned PWM waveforms (ARR=8) . . . . .252
Figure 78.Center-aligned PWM waveforms (ARR=8). . . . .253
Figure 79.Complementary output with dead-time insertion. . . . .255
Figure 80.Dead-time waveforms with delay greater than the negative pulse. . . . .255
Figure 81.Dead-time waveforms with delay greater than the positive pulse. . . . .255
Figure 82.Output behavior in response to a break . . . . .258
Figure 83.Clearing TIMx_OCxREF . . . . .260
Figure 84.6-step generation, COM example (OSSR=1) . . . . .261
Figure 85.Example of one pulse mode . . . . .262
Figure 86.Example of counter operation in encoder interface mode. . . . .265
Figure 87.Example of encoder interface mode with TI1FP1 polarity inverted. . . . .265
Figure 88.Example of hall sensor interface . . . . .267
Figure 89.Control circuit in reset mode . . . . .268
Figure 90.Control circuit in gated mode . . . . .269
Figure 91.Control circuit in trigger mode . . . . .270
Figure 92.Control circuit in external clock mode 2 + trigger mode . . . . .271
Figure 93.General-purpose timer block diagram (TIM3) . . . . .302
Figure 94.Counter timing diagram with prescaler division change from 1 to 2 . . . . .303
Figure 95.Counter timing diagram with prescaler division change from 1 to 4 . . . . .304
Figure 96.Counter timing diagram, internal clock divided by 1 . . . . .305
Figure 97.Counter timing diagram, internal clock divided by 2 . . . . .305
Figure 98.Counter timing diagram, internal clock divided by 4 . . . . .306
Figure 99.Counter timing diagram, internal clock divided by N . . . . .306
Figure 100.Counter timing diagram, Update event when ARPE=0
(TIMx_ARR not preloaded). . . . .
307
Figure 101.Counter timing diagram, Update event when ARPE=1
(TIMx_ARR preloaded). . . . .
307
Figure 102.Counter timing diagram, internal clock divided by 1 . . . . .308
Figure 103.Counter timing diagram, internal clock divided by 2 . . . . .309
Figure 104.Counter timing diagram, internal clock divided by 4 . . . . .309
Figure 105.Counter timing diagram, internal clock divided by N . . . . .310
Figure 106.Counter timing diagram, Update event when repetition counter is not used . . . . .310
Figure 107.Counter timing diagram, internal clock divided by 1, TIMx_ARR=0x6 . . . . .312
Figure 108.Counter timing diagram, internal clock divided by 2 . . . . .312
Figure 109.Counter timing diagram, internal clock divided by 4, TIMx_ARR=0x36 . . . . .313
Figure 110.Counter timing diagram, internal clock divided by N . . . . .313
Figure 111.Counter timing diagram, Update event with ARPE=1 (counter underflow). . . . .314
Figure 112.Counter timing diagram, Update event with ARPE=1 (counter overflow). . . . .314
Figure 113.Control circuit in normal mode, internal clock divided by 1 . . . . .315
Figure 114.TI2 external clock connection example. . . . .316
Figure 115.Control circuit in external clock mode 1 . . . . .317
Figure 116.External trigger input block . . . . .317
Figure 117.Control circuit in external clock mode 2 . . . . .318
Figure 118.Capture/compare channel (example: channel 1 input stage). . . . .319
Figure 119.Capture/compare channel 1 main circuit . . . . .319
Figure 120.Output stage of capture/compare channel (channel 1). . . . .320
Figure 121.PWM input mode timing . . . . .322
Figure 122.Output compare mode, toggle on OC1 . . . . .324
Figure 123.Edge-aligned PWM waveforms (ARR=8). . . . .325
Figure 124.Center-aligned PWM waveforms (ARR=8). . . . .327
Figure 125.Example of one-pulse mode . . . . .328
Figure 126.Clearing TIMx_OCxREF . . . . .330
Figure 127.Example of counter operation in encoder interface mode . . . . .332
Figure 128.Example of encoder interface mode with TI1FP1 polarity inverted . . . . .332
Figure 129.Control circuit in reset mode . . . . .333
Figure 130.Control circuit in gated mode . . . . .334
Figure 131.Control circuit in trigger mode . . . . .335
Figure 132.Control circuit in external clock mode 2 + trigger mode . . . . .336
Figure 133.Master/Slave timer example . . . . .337
Figure 134.Gating timer 3 with OC1REF of timer 1 . . . . .338
Figure 135.Gating timer 3 with Enable of timer 1 . . . . .339
Figure 136.Triggering timer 3 with update of timer 1 . . . . .340
Figure 137.Triggering timer 3 with Enable of timer 1 . . . . .341
Figure 138.Triggering timer 1 and 3 with timer 1 TI1 input . . . . .342
Figure 139.Basic timer block diagram. . . . .367
Figure 140.Counter timing diagram with prescaler division change from 1 to 2 . . . . .369
Figure 141.Counter timing diagram with prescaler division change from 1 to 4 . . . . .369
Figure 142.Counter timing diagram, internal clock divided by 1 . . . . .370
Figure 143.Counter timing diagram, internal clock divided by 2 . . . . .371
Figure 144.Counter timing diagram, internal clock divided by 4 . . . . .371
Figure 145.Counter timing diagram, internal clock divided by N . . . . .372
Figure 146.Counter timing diagram, update event when ARPE = 0
(TIMx_ARR not preloaded). . . . .
372
Figure 147.Counter timing diagram, update event when ARPE=1
(TIMx_ARR preloaded) . . . . .373
Figure 148. Control circuit in normal mode, internal clock divided by 1 . . . . .374
Figure 149. General-purpose timer block diagram (TIM14) . . . . .381
Figure 150. Counter timing diagram with prescaler division change from 1 to 2 . . . . .382
Figure 151. Counter timing diagram with prescaler division change from 1 to 4 . . . . .382
Figure 152. Counter timing diagram, internal clock divided by 1 . . . . .383
Figure 153. Counter timing diagram, internal clock divided by 2 . . . . .383
Figure 154. Counter timing diagram, internal clock divided by 4 . . . . .384
Figure 155. Counter timing diagram, internal clock divided by N . . . . .384
Figure 156. Counter timing diagram, update event when ARPE=0
(TIMx_ARR not preloaded) . . . . .
384
Figure 157. Counter timing diagram, update event when ARPE=1
(TIMx_ARR preloaded) . . . . .
385
Figure 158. Control circuit in normal mode, internal clock divided by 1 . . . . .385
Figure 159. Capture/compare channel (example: channel 1 input stage) . . . . .386
Figure 160. Capture/compare channel 1 main circuit . . . . .386
Figure 161. Output stage of capture/compare channel (channel 1) . . . . .387
Figure 162. Output compare mode, toggle on OC1 . . . . .390
Figure 163. Edge-aligned PWM waveforms (ARR=8) . . . . .391
Figure 164. TIM15 block diagram . . . . .402
Figure 165. TIM16 and TIM17 block diagram . . . . .404
Figure 166. Counter timing diagram with prescaler division change from 1 to 2 . . . . .405
Figure 167. Counter timing diagram with prescaler division change from 1 to 4 . . . . .406
Figure 168. Counter timing diagram, internal clock divided by 1 . . . . .407
Figure 169. Counter timing diagram, internal clock divided by 2 . . . . .408
Figure 170. Counter timing diagram, internal clock divided by 4 . . . . .408
Figure 171. Counter timing diagram, internal clock divided by N . . . . .409
Figure 172. Counter timing diagram, update event when ARPE=0
(TIMx_ARR not preloaded) . . . . .
409
Figure 173. Counter timing diagram, update event when ARPE=1
(TIMx_ARR preloaded) . . . . .
410
Figure 174. Update rate examples depending on mode and TIMx_RCR register settings . . . . .411
Figure 175. Control circuit in normal mode, internal clock divided by 1 . . . . .412
Figure 176. TI2 external clock connection example . . . . .412
Figure 177. Control circuit in external clock mode 1 . . . . .413
Figure 178. Capture/compare channel (example: channel 1 input stage) . . . . .414
Figure 179. Capture/compare channel 1 main circuit . . . . .414
Figure 180. Output stage of capture/compare channel (channel 1) . . . . .415
Figure 181. Output stage of capture/compare channel (channel 2 for TIM15) . . . . .415
Figure 182. PWM input mode timing . . . . .417
Figure 183. Output compare mode, toggle on OC1 . . . . .419
Figure 184. Edge-aligned PWM waveforms (ARR=8) . . . . .420
Figure 185. Complementary output with dead-time insertion . . . . .421
Figure 186. Dead-time waveforms with delay greater than the negative pulse . . . . .421
Figure 187. Dead-time waveforms with delay greater than the positive pulse . . . . .421
Figure 188. Output behavior in response to a break . . . . .424
Figure 189. Example of One-pulse mode . . . . .425
Figure 190. Control circuit in reset mode . . . . .427
Figure 191. Control circuit in gated mode . . . . .428
Figure 192. Control circuit in trigger mode . . . . .429
Figure 193. IRTIM internal hardware connections . . . . .468
Figure 194. Independent watchdog block diagram . . . . .469
Figure 195. Watchdog block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Figure 242. RX data setup/hold time . . . . .613
Figure 243. Transmission using DMA . . . . .615
Figure 244. Reception using DMA . . . . .616
Figure 245. Hardware flow control between 2 USARTs . . . . .616
Figure 246. RS232 RTS flow control . . . . .617
Figure 247. RS232 CTS flow control . . . . .618
Figure 248. USART interrupt mapping diagram . . . . .619
Figure 249. SPI block diagram. . . . .639
Figure 250. Full-duplex single master/ single slave application. . . . .640
Figure 251. Half-duplex single master/ single slave application . . . . .640
Figure 252. Simplex single master/single slave application (master in transmit-only/
slave in receive-only mode) . . . . .
641
Figure 253. Master and three independent slaves. . . . .642
Figure 254. Multimaster application. . . . .643
Figure 255. Hardware/software slave select management . . . . .644
Figure 256. Data clock timing diagram . . . . .645
Figure 257. Data alignment when data length is not equal to 8-bit or 16-bit . . . . .646
Figure 258. Packing data in FIFO for transmission and reception. . . . .650
Figure 259. Master full-duplex communication . . . . .653
Figure 260. Slave full-duplex communication . . . . .654
Figure 261. Master full-duplex communication with CRC . . . . .655
Figure 262. Master full-duplex communication in packed mode . . . . .656
Figure 263. NSSP pulse generation in Motorola SPI master mode. . . . .659
Figure 264. TI mode transfer . . . . .660
Figure 265. USB peripheral block diagram . . . . .673
Figure 266. Packet buffer areas with examples of buffer description table locations . . . . .677
Figure 267. Block diagram of STM32F0x0 MCU and Arm ® Cortex ® -M0-level debug support . . . . .705

Chapters