RM0366-STM32F301x6-8-318x8

This reference manual targets application developers. It provides complete information on how to use the STM32F301x6/8 and STM32F318x8 microcontroller memory and peripherals. The STM32F301x6/8 and STM32F318x8 devices will be referred to as “STM32F3xx” throughout the document, unless otherwise specified.

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

For ordering information, mechanical and electrical device characteristics please refer to the applicable datasheets.

For information on the Arm ® Cortex ® -M4 core with FPU, refer to the Cortex ® -M4F technical reference manual.

STM32F3xx microcontrollers include ST state-of-the-art patented technology.

Available from STMicroelectronics web site www.st.com :

Contents

1Documentation conventions . . . . .36
1.1General information . . . . .36
1.2List of abbreviations for registers . . . . .36
1.3Register reset value . . . . .36
1.4Glossary . . . . .37
1.5Availability of peripherals . . . . .37
2System and memory overview . . . . .38
2.1System architecture . . . . .38
2.1.1S0: I-bus . . . . .39
2.1.2S1: D-bus . . . . .39
2.1.3S2: S-bus . . . . .39
2.1.4S3: DMA-bus . . . . .39
2.1.5BusMatrix . . . . .39
2.2Memory organization . . . . .40
2.2.1Introduction . . . . .40
2.2.2Memory map and register boundary addresses . . . . .41
2.3Embedded SRAM . . . . .44
2.4Flash memory overview . . . . .44
2.5Boot configuration . . . . .44
2.5.1Embedded boot loader . . . . .45
3Embedded flash memory . . . . .46
3.1Flash main features . . . . .46
3.2Flash memory functional description . . . . .46
3.2.1Flash memory organization . . . . .46
3.2.2Read operations . . . . .47
3.2.3Flash program and erase operations . . . . .49
3.3Memory protection . . . . .55
3.3.1Read protection (RDP) . . . . .55
3.3.2Write protection . . . . .57
3.3.3Option byte block write protection . . . . .57
3.4Flash interrupts . . . . .57
3.5Flash register description . . . . .58
3.5.1Flash access control register (FLASH_ACR) . . . . .58
3.5.2Flash key register (FLASH_KEYR) . . . . .58
3.5.3Flash option key register (FLASH_OPTKEYR) . . . . .59
3.5.4Flash status register (FLASH_SR) . . . . .59
3.5.5Flash control register (FLASH_CR) . . . . .60
3.5.6Flash address register (FLASH_AR) . . . . .61
3.5.7Option byte register (FLASH_OBR) . . . . .62
3.5.8Write protection register (FLASH_WRPR) . . . . .63
3.6Flash register map . . . . .63
4Option byte description . . . . .65
5Cyclic redundancy check calculation unit (CRC) . . . . .68
5.1Introduction . . . . .68
5.2CRC main features . . . . .68
5.3CRC functional description . . . . .69
5.3.1CRC block diagram . . . . .69
5.3.2CRC internal signals . . . . .69
5.3.3CRC operation . . . . .69
5.4CRC registers . . . . .71
5.4.1CRC data register (CRC_DR) . . . . .71
5.4.2CRC independent data register (CRC_IDR) . . . . .71
5.4.3CRC control register (CRC_CR) . . . . .72
5.4.4CRC initial value (CRC_INIT) . . . . .73
5.4.5CRC polynomial (CRC_POL) . . . . .73
5.4.6CRC register map . . . . .74
6Power control (PWR) . . . . .75
6.1Power supplies . . . . .75
6.1.1Independent A/D and D/A converter supply and reference voltage . . . . .77
6.1.2Battery backup domain . . . . .77
6.1.3Voltage regulator . . . . .78
6.2Power supply supervisor . . . . .78
6.2.1Power on reset (POR)/power down reset (PDR) . . . . .78
6.2.2Programmable voltage detector (PVD) . . . . .79
7.4.2Clock configuration register (RCC_CFGR)104
7.4.3Clock interrupt register (RCC_CIR)106
7.4.4APB2 peripheral reset register (RCC_APB2RSTR)109
7.4.5APB1 peripheral reset register (RCC_APB1RSTR)110
7.4.6AHB peripheral clock enable register (RCC_AHBENR)111
7.4.7APB2 peripheral clock enable register (RCC_APB2ENR)113
7.4.8APB1 peripheral clock enable register (RCC_APB1ENR)114
7.4.9RTC domain control register (RCC_BDCR)117
7.4.10Control/status register (RCC_CSR)118
7.4.11AHB peripheral reset register (RCC_AHBRSTR)120
7.4.12Clock configuration register 2 (RCC_CFGR2)121
7.4.13Clock configuration register 3 (RCC_CFGR3)122
7.4.14RCC register map124
8General-purpose I/Os (GPIO)126
8.1Introduction126
8.2GPIO main features126
8.3GPIO functional description126
8.3.1General-purpose I/O (GPIO)128
8.3.2I/O pin alternate function multiplexer and mapping129
8.3.3I/O port control registers130
8.3.4I/O port data registers130
8.3.5I/O data bitwise handling130
8.3.6GPIO locking mechanism130
8.3.7I/O alternate function input/output131
8.3.8External interrupt/wake-up lines131
8.3.9Input configuration131
8.3.10Output configuration132
8.3.11Alternate function configuration133
8.3.12Analog configuration134
8.3.13Using the HSE or LSE oscillator pins as GPIOs135
8.3.14Using the GPIO pins in the RTC supply domain135
8.4GPIO registers136
8.4.1GPIO port mode register (GPIOx_MODER)
(x = A to D and F)
136
8.4.2GPIO port output type register (GPIOx_OTYPER)
(x = A to D and F)
136
10.4.1DMA block diagram . . . . .156
10.4.2DMA transfers . . . . .157
10.4.3DMA arbitration . . . . .158
10.4.4DMA channels . . . . .158
10.4.5DMA data width, alignment, and endianness . . . . .162
10.4.6DMA error management . . . . .163
10.5DMA interrupts . . . . .164
10.6DMA registers . . . . .164
10.6.1DMA interrupt status register (DMA_ISR) . . . . .164
10.6.2DMA interrupt flag clear register (DMA_IFCR) . . . . .166
10.6.3DMA channel x configuration register (DMA_CCRx) . . . . .168
10.6.4DMA channel x number of data to transfer register (DMA_CNDTRx) . . . . .170
10.6.5DMA channel x peripheral address register (DMA_CPARx) . . . . .171
10.6.6DMA channel x memory address register (DMA_CMARx) . . . . .172
10.6.7DMA register map . . . . .172
11Interrupts and events . . . . .175
11.1Nested vectored interrupt controller (NVIC) . . . . .175
11.1.1NVIC main features . . . . .175
11.1.2SysTick calibration value register . . . . .175
11.1.3Interrupt and exception vectors . . . . .175
11.2Extended interrupts and events controller (EXTI) . . . . .178
11.2.1Main features . . . . .179
11.2.2Block diagram . . . . .179
11.2.3Wake-up event management . . . . .180
11.2.4Asynchronous Internal Interrupts . . . . .180
11.2.5Functional description . . . . .180
11.2.6External and internal interrupt/event line mapping . . . . .182
11.3EXTI registers . . . . .183
11.3.1Interrupt mask register (EXTI_IMR1) . . . . .183
11.3.2Event mask register (EXTI_EMR1) . . . . .184
11.3.3Rising trigger selection register (EXTI_RTSR1) . . . . .185
11.3.4Falling trigger selection register (EXTI_FTSR1) . . . . .186
11.3.5Software interrupt event register (EXTI_SWIER1) . . . . .187
11.3.6Pending register (EXTI_PR1) . . . . .188
11.3.7Interrupt mask register (EXTI_IMR2) . . . . .189
11.3.8Event mask register (EXTI_EMR2) . . . . .189
11.3.9Rising trigger selection register (EXTI_RTSR2) .....189
11.3.10Falling trigger selection register (EXTI_FTSR2) .....190
11.3.11Software interrupt event register (EXTI_SWIER2) .....190
11.3.12Pending register (EXTI_PR2) .....191
11.3.13EXTI register map .....191
12Analog-to-digital converters (ADC) .....193
12.1Introduction .....193
12.2ADC main features .....193
12.3ADC functional description .....195
12.3.1ADC block diagram .....195
12.3.2Pins and internal signals .....196
12.3.3Clocks .....196
12.3.4ADC1 connectivity .....198
12.3.5Slave AHB interface .....198
12.3.6ADC voltage regulator (ADVREGEN) .....199
12.3.7Single-ended and differential input channels .....199
12.3.8Calibration (ADCAL, ADCALDIF, ADCx_CALFACT) .....200
12.3.9ADC on-off control (ADEN, ADDIS, ADRDY) .....202
12.3.10Constraints when writing the ADC control bits .....203
12.3.11Channel selection (SQRx, JSQRx) .....204
12.3.12Channel-wise programmable sampling time (SMPR1, SMPR2) .....205
12.3.13Single conversion mode (CONT=0) .....205
12.3.14Continuous conversion mode (CONT=1) .....206
12.3.15Starting conversions (ADSTART, JADSTART) .....207
12.3.16Timing .....207
12.3.17Stopping an ongoing conversion (ADSTP, JADSTP) .....208
12.3.18Conversion on external trigger and trigger polarity (EXTSEL, EXTEN,
JEXTSEL, JEXTEN) .....
210
12.3.19Injected channel management .....212
12.3.20Discontinuous mode (DISCEN, DISCNUM, JDISCEN) .....214
12.3.21Queue of context for injected conversions .....215
12.3.22Programmable resolution (RES) - fast conversion mode .....223
12.3.23End of conversion, end of sampling phase (EOC, JEOC, EOSMP) ..223
12.3.24End of conversion sequence (EOS, JEOS) .....224
12.3.25Timing diagrams example (single/continuous modes,
hardware/software triggers) .....
224
12.3.26Data management . . . . .226
12.3.27Dynamic low-power features . . . . .231
12.3.28Analog window watchdog (AWD1EN, JAWD1EN, AWD1SGL,
AWD1CH, AWD2CH, AWD3CH, AWD_HTx, AWD_LTx, AWDx) . . . . .
236
12.3.29Temperature sensor . . . . .240
12.3.30VBAT supply monitoring . . . . .241
12.3.31Monitoring the internal voltage reference . . . . .242
12.4ADC interrupts . . . . .243
12.5ADC registers (for each ADC) . . . . .244
12.5.1ADC interrupt and status register (ADCx_ISR, x=1) . . . . .244
12.5.2ADC interrupt enable register (ADCx_IER, x=1) . . . . .246
12.5.3ADC control register (ADCx_CR, x=1) . . . . .248
12.5.4ADC configuration register (ADCx_CFGR, x=1) . . . . .251
12.5.5ADC sample time register 1 (ADCx_SMPR1, x=1) . . . . .254
12.5.6ADC sample time register 2 (ADCx_SMPR2, x=1) . . . . .256
12.5.7ADC watchdog threshold register 1 (ADCx_TR1, x=1) . . . . .256
12.5.8ADC watchdog threshold register 2 (ADCx_TR2, x = 1) . . . . .257
12.5.9ADC watchdog threshold register 3 (ADCx_TR3, x=1) . . . . .258
12.5.10ADC regular sequence register 1 (ADCx_SQR1, x=1) . . . . .259
12.5.11ADC regular sequence register 2 (ADCx_SQR2, x=1) . . . . .260
12.5.12ADC regular sequence register 3 (ADCx_SQR3, x=1) . . . . .262
12.5.13ADC regular sequence register 4 (ADCx_SQR4, x=1) . . . . .263
12.5.14ADC regular Data Register (ADCx_DR, x=1) . . . . .264
12.5.15ADC injected sequence register (ADCx_JSQR, x=1) . . . . .265
12.5.16ADC offset register (ADCx_OFRy, x=1) (y=1..4) . . . . .267
12.5.17ADC injected data register (ADCx_JDRy, x=1, y= 1..4) . . . . .268
12.5.18ADC Analog Watchdog 2 Configuration Register (ADCx_AWD2CR,
x=1) . . . . .
268
12.5.19ADC Analog Watchdog 3 Configuration Register (ADCx_AWD3CR,
x=1) . . . . .
269
12.5.20ADC Differential Mode Selection Register (ADCx_DIFSEL, x=1) . . . . .269
12.5.21ADC Calibration Factors (ADCx_CALFACT, x=1) . . . . .270
12.6ADC common registers . . . . .271
12.6.1ADC Common status register (ADCx_CSR, x=1) . . . . .271
12.6.2ADC common control register (ADCx_CCR, x=1) . . . . .273
12.7ADC register map . . . . .274
13Digital-to-analog converter (DAC1) . . . . .278
13.1Introduction . . . . .278
13.2DAC1 main features . . . . .278
13.3DAC output buffer enable . . . . .279
13.4DAC channel enable . . . . .280
13.5Single mode functional description . . . . .280
13.5.1DAC data format . . . . .280
13.5.2DAC channel conversion . . . . .280
13.5.3DAC output voltage . . . . .281
13.5.4DAC trigger selection . . . . .282
13.6Noise generation . . . . .283
13.7Triangle-wave generation . . . . .284
13.8DMA request . . . . .285
13.9DAC registers . . . . .286
13.9.1DAC control register (DAC_CR) . . . . .286
13.9.2DAC software trigger register (DAC_SWTRIGR) . . . . .288
13.9.3DAC channel1 12-bit right-aligned data holding register
(DAC_DHR12R1) . . . . .
288
13.9.4DAC channel1 12-bit left-aligned data holding register
(DAC_DHR12L1) . . . . .
289
13.9.5DAC channel1 8-bit right-aligned data holding register
(DAC_DHR8R1) . . . . .
289
13.9.6DAC channel1 data output register (DAC_DOR1) . . . . .289
13.9.7DAC status register (DAC_SR) . . . . .290
13.9.8DAC register map . . . . .291
14Comparator (COMP) . . . . .292
14.1Introduction . . . . .292
14.2COMP main features . . . . .292
14.3COMP functional description . . . . .293
14.3.1COMP block diagram . . . . .293
14.3.2COMP pins and internal signals . . . . .294
14.3.3COMP reset and clocks . . . . .294
14.3.4Comparator LOCK mechanism . . . . .295
14.3.5Comparator output blanking function . . . . .295
14.4COMP interrupts . . . . .296
14.5COMP registers . . . . .296
14.5.1COMP2 control and status register (COMP2_CSR) . . . . .296
14.5.2COMP4 control and status register (COMP4_CSR) . . . . .298
14.5.3COMP6 control and status register (COMP6_CSR) . . . . .299
14.5.4COMP register map . . . . .302
15Operational amplifier (OPAMP) . . . . .303
15.1OPAMP introduction . . . . .303
15.2OPAMP main features . . . . .303
15.3OPAMP functional description . . . . .303
15.3.1General description . . . . .303
15.3.2Clock . . . . .303
15.3.3Operational amplifiers and comparators interconnections . . . . .304
15.3.4Using the OPAMP output as an ADC input . . . . .304
15.3.5Calibration . . . . .304
15.3.6Timer controlled Multiplexer mode . . . . .305
15.3.7OPAMP modes . . . . .306
15.4OPAMP registers . . . . .309
15.4.1OPAMP2 control register (OPAMP2_CSR) . . . . .309
15.4.2OPAMP register map . . . . .312
16Touch sensing controller (TSC) . . . . .313
16.1Introduction . . . . .313
16.2TSC main features . . . . .313
16.3TSC functional description . . . . .314
16.3.1TSC block diagram . . . . .314
16.3.2Surface charge transfer acquisition overview . . . . .314
16.3.3Reset and clocks . . . . .317
16.3.4Charge transfer acquisition sequence . . . . .317
16.3.5Spread spectrum feature . . . . .318
16.3.6Max count error . . . . .319
16.3.7Sampling capacitor I/O and channel I/O mode selection . . . . .319
16.3.8Acquisition mode . . . . .320
16.3.9I/O hysteresis and analog switch control . . . . .320
16.4TSC low-power modes . . . . .321
16.5TSC interrupts . . . . .321
16.6TSC registers . . . . .321
16.6.1TSC control register (TSC_CR) . . . . .321
16.6.2TSC interrupt enable register (TSC_IER) . . . . .324
16.6.3TSC interrupt clear register (TSC_ICR) . . . . .325
16.6.4TSC interrupt status register (TSC_ISR) . . . . .325
16.6.5TSC I/O hysteresis control register (TSC_IOHCR) . . . . .326
16.6.6TSC I/O analog switch control register
(TSC_IOASCR) . . . . .
326
16.6.7TSC I/O sampling control register (TSC_IOSCR) . . . . .327
16.6.8TSC I/O channel control register (TSC_IOCCR) . . . . .327
16.6.9TSC I/O group control status register (TSC_IOGCSR) . . . . .328
16.6.10TSC I/O group x counter register (TSC_IOGxCR) . . . . .328
16.6.11TSC register map . . . . .329
17Advanced-control timer (TIM1) . . . . .331
17.1TIM1 introduction . . . . .331
17.2TIM1 main features . . . . .332
17.3TIM1 functional description . . . . .335
17.3.1Time-base unit . . . . .335
17.3.2Counter modes . . . . .337
17.3.3Repetition counter . . . . .348
17.3.4External trigger input . . . . .350
17.3.5Clock selection . . . . .351
17.3.6Capture/compare channels . . . . .355
17.3.7Input capture mode . . . . .358
17.3.8PWM input mode . . . . .359
17.3.9Forced output mode . . . . .359
17.3.10Output compare mode . . . . .360
17.3.11PWM mode . . . . .361
17.3.12Asymmetric PWM mode . . . . .364
17.3.13Combined PWM mode . . . . .365
17.3.14Combined 3-phase PWM mode . . . . .366
17.3.15Complementary outputs and dead-time insertion . . . . .367
17.3.16Using the break function . . . . .369
17.3.17Clearing the OCxREF signal on an external event . . . . .374
17.3.186-step PWM generation . . . . .376
17.3.19One-pulse mode . . . . .377
17.3.20Retriggerable one pulse mode . . . . .378
17.3.21Encoder interface mode . . . . .379
17.3.22UIF bit remapping . . . . .381
17.3.23Timer input XOR function . . . . .382
17.3.24Interfacing with Hall sensors . . . . .382
17.3.25Timer synchronization . . . . .385
17.3.26ADC synchronization . . . . .389
17.3.27DMA burst mode . . . . .389
17.3.28Debug mode . . . . .390
17.4TIM1 registers . . . . .391
17.4.1TIM1 control register 1 (TIM1_CR1) . . . . .391
17.4.2TIM1 control register 2 (TIM1_CR2) . . . . .392
17.4.3TIM1 slave mode control register
(TIM1_SMCR) . . . . .
395
17.4.4TIM1 DMA/interrupt enable register
(TIM1_DIER) . . . . .
397
17.4.5TIM1 status register (TIM1_SR) . . . . .399
17.4.6TIM1 event generation register (TIM1_EGR) . . . . .401
17.4.7TIM1 capture/compare mode register 1 (TIM1_CCMR1) . . . . .402
17.4.8TIM1 capture/compare mode register 1 [alternate]
(TIM1_CCMR1) . . . . .
403
17.4.9TIM1 capture/compare mode register 2 (TIM1_CCMR2) . . . . .406
17.4.10TIM1 capture/compare mode register 2 [alternate]
(TIM1_CCMR2) . . . . .
407
17.4.11TIM1 capture/compare enable register
(TIM1_CCER) . . . . .
408
17.4.12TIM1 counter (TIM1_CNT) . . . . .412
17.4.13TIM1 prescaler (TIM1_PSC) . . . . .412
17.4.14TIM1 auto-reload register (TIM1_ARR) . . . . .412
17.4.15TIM1 repetition counter register (TIM1_RCR) . . . . .413
17.4.16TIM1 capture/compare register 1
(TIM1_CCR1) . . . . .
413
17.4.17TIM1 capture/compare register 2
(TIM1_CCR2) . . . . .
414
17.4.18TIM1 capture/compare register 3
(TIM1_CCR3) . . . . .
414
17.4.19TIM1 capture/compare register 4
(TIM1_CCR4) . . . . .
415
17.4.20TIM1 break and dead-time register
(TIM1_BDTR) . . . . .
415
18.4TIM2 registers .....472
18.4.1TIM2 control register 1 (TIM2_CR1) .....472
18.4.2TIM2 control register 2 (TIM2_CR2) .....473
18.4.3TIM2 slave mode control register (TIM2_SMCR) .....475
18.4.4TIM2 DMA/Interrupt enable register (TIM2_DIER) .....478
18.4.5TIM2 status register (TIM2_SR) .....479
18.4.6TIM2 event generation register (TIM2_EGR) .....480
18.4.7TIM2 capture/compare mode register 1 (TIM2_CCMR1) .....481
18.4.8TIM2 capture/compare mode register 1 [alternate] (TIM2_CCMR1) ..483
18.4.9TIM2 capture/compare mode register 2 (TIM2_CCMR2) .....485
18.4.10TIM2 capture/compare mode register 2 [alternate] (TIM2_CCMR2) ..486
18.4.11TIM2 capture/compare enable register
(TIM2_CCER) .....
487
18.4.12TIM2 counter (TIM2_CNT) .....488
18.4.13TIM2 counter [alternate] (TIM2_CNT) .....489
18.4.14TIM2 prescaler (TIM2_PSC) .....489
18.4.15TIM2 auto-reload register (TIM2_ARR) .....489
18.4.16TIM2 capture/compare register 1 (TIM2_CCR1) .....490
18.4.17TIM2 capture/compare register 2 (TIM2_CCR2) .....490
18.4.18TIM2 capture/compare register 3 (TIM2_CCR3) .....491
18.4.19TIM2 capture/compare register 4 (TIM2_CCR4) .....491
18.4.20TIM2 DMA control register (TIM2_DCR) .....492
18.4.21TIM2 DMA address for full transfer (TIM2_DMAR) .....492
18.4.22TIMx register map .....494
19General-purpose timers (TIM15/TIM16/TIM17) .....496
19.1TIM15/TIM16/TIM17 introduction .....496
19.2TIM15 main features .....496
19.3TIM16/TIM17 main features .....497
19.4TIM15/TIM16/TIM17 functional description .....500
19.4.1Time-base unit .....500
19.4.2Counter modes .....502
19.4.3Repetition counter .....506
19.4.4Clock selection .....507
19.4.5Capture/compare channels .....509
19.4.6Input capture mode .....511
19.4.7PWM input mode (only for TIM15) .....512
19.4.8Forced output mode . . . . .513
19.4.9Output compare mode . . . . .514
19.4.10PWM mode . . . . .515
19.4.11Combined PWM mode (TIM15 only) . . . . .516
19.4.12Complementary outputs and dead-time insertion . . . . .517
19.4.13Using the break function . . . . .519
19.4.146-step PWM generation . . . . .523
19.4.15One-pulse mode . . . . .524
19.4.16Retriggerable one pulse mode (TIM15 only) . . . . .525
19.4.17UIF bit remapping . . . . .526
19.4.18Timer input XOR function (TIM15 only) . . . . .527
19.4.19External trigger synchronization (TIM15 only) . . . . .528
19.4.20Slave mode – combined reset + trigger mode (TIM15 only) . . . . .530
19.4.21DMA burst mode . . . . .530
19.4.22Timer synchronization (TIM15) . . . . .532
19.4.23Using timer output as trigger for other timers (TIM16/TIM17) . . . . .532
19.4.24Debug mode . . . . .532
19.5TIM15 registers . . . . .533
19.5.1TIM15 control register 1 (TIM15_CR1) . . . . .533
19.5.2TIM15 control register 2 (TIM15_CR2) . . . . .534
19.5.3TIM15 slave mode control register (TIM15_SMCR) . . . . .536
19.5.4TIM15 DMA/interrupt enable register (TIM15_DIER) . . . . .537
19.5.5TIM15 status register (TIM15_SR) . . . . .538
19.5.6TIM15 event generation register (TIM15_EGR) . . . . .540
19.5.7TIM15 capture/compare mode register 1 (TIM15_CCMR1) . . . . .541
19.5.8TIM15 capture/compare mode register 1 [alternate]
(TIM15_CCMR1) . . . . .
542
19.5.9TIM15 capture/compare enable register (TIM15_CCER) . . . . .545
19.5.10TIM15 counter (TIM15_CNT) . . . . .548
19.5.11TIM15 prescaler (TIM15_PSC) . . . . .548
19.5.12TIM15 auto-reload register (TIM15_ARR) . . . . .548
19.5.13TIM15 repetition counter register (TIM15_RCR) . . . . .549
19.5.14TIM15 capture/compare register 1 (TIM15_CCR1) . . . . .549
19.5.15TIM15 capture/compare register 2 (TIM15_CCR2) . . . . .550
19.5.16TIM15 break and dead-time register (TIM15_BDTR) . . . . .550
19.5.17TIM15 DMA control register (TIM15_DCR) . . . . .552
19.5.18TIM15 DMA address for full transfer (TIM15_DMAR) . . . . .553
19.5.19TIM15 register map553
19.6TIM16/TIM17 registers556
19.6.1TIMx control register 1 (TIMx_CR1)(x = 16 to 17)556
19.6.2TIMx control register 2 (TIMx_CR2)(x = 16 to 17)557
19.6.3TIMx DMA/interrupt enable register (TIMx_DIER)(x = 16 to 17)558
19.6.4TIMx status register (TIMx_SR)(x = 16 to 17)559
19.6.5TIMx event generation register (TIMx_EGR)(x = 16 to 17)560
19.6.6TIMx capture/compare mode register 1
(TIMx_CCMR1)(x = 16 to 17)
561
19.6.7TIMx capture/compare mode register 1 [alternate]
(TIMx_CCMR1)(x = 16 to 17)
562
19.6.8TIMx capture/compare enable register (TIMx_CCER)(x = 16 to 17)564
19.6.9TIMx counter (TIMx_CNT)(x = 16 to 17)566
19.6.10TIMx prescaler (TIMx_PSC)(x = 16 to 17)567
19.6.11TIMx auto-reload register (TIMx_ARR)(x = 16 to 17)567
19.6.12TIMx repetition counter register (TIMx_RCR)(x = 16 to 17)568
19.6.13TIMx capture/compare register 1 (TIMx_CCR1)(x = 16 to 17)568
19.6.14TIMx break and dead-time register (TIMx_BDTR)(x = 16 to 17)569
19.6.15TIMx DMA control register (TIMx_DCR)(x = 16 to 17)571
19.6.16TIMx DMA address for full transfer (TIMx_DMAR)(x = 16 to 17)571
19.6.17TIM16 option register (TIM16_OR)572
19.6.18TIM16/TIM17 register map573
20Basic timers (TIM6)575
20.1TIM6 introduction575
20.2TIM6 main features575
20.3TIM6 functional description576
20.3.1Time-base unit576
20.3.2Counting mode578
20.3.3UIF bit remapping581
20.3.4Clock source581
20.3.5Debug mode582
20.4TIM6 registers582
20.4.1TIM6 control register 1 (TIM6_CR1)582
20.4.2TIM6 control register 2 (TIM6_CR2)584
20.4.3TIM6 DMA/Interrupt enable register (TIM6_DIER)584
20.4.4TIM6 status register (TIM6_SR)585
23.4.3IWDG reload register (IWDG_RLR) . . . . .600
23.4.4IWDG status register (IWDG_SR) . . . . .601
23.4.5IWDG window register (IWDG_WINR) . . . . .602
23.4.6IWDG register map . . . . .603
24Real-time clock (RTC) . . . . .604
24.1Introduction . . . . .604
24.2RTC main features . . . . .605
24.3RTC functional description . . . . .606
24.3.1RTC block diagram . . . . .606
24.3.2GPIOs controlled by the RTC . . . . .607
24.3.3Clock and prescalers . . . . .609
24.3.4Real-time clock and calendar . . . . .609
24.3.5Programmable alarms . . . . .610
24.3.6Periodic auto-wake-up . . . . .610
24.3.7RTC initialization and configuration . . . . .611
24.3.8Reading the calendar . . . . .612
24.3.9Resetting the RTC . . . . .613
24.3.10RTC synchronization . . . . .614
24.3.11RTC reference clock detection . . . . .614
24.3.12RTC smooth digital calibration . . . . .615
24.3.13Time-stamp function . . . . .617
24.3.14Tamper detection . . . . .618
24.3.15Calibration clock output . . . . .619
24.3.16Alarm output . . . . .620
24.4RTC low-power modes . . . . .620
24.5RTC interrupts . . . . .620
24.6RTC registers . . . . .621
24.6.1RTC time register (RTC_TR) . . . . .621
24.6.2RTC date register (RTC_DR) . . . . .622
24.6.3RTC control register (RTC_CR) . . . . .624
24.6.4RTC initialization and status register (RTC_ISR) . . . . .627
24.6.5RTC prescaler register (RTC_PRER) . . . . .630
24.6.6RTC wake-up timer register (RTC_WUTR) . . . . .631
24.6.7RTC alarm A register (RTC_ALRMAR) . . . . .632
24.6.8RTC alarm B register (RTC_ALRMBR) . . . . .633
24.6.9RTC write protection register (RTC_WPR) . . . . .634
24.6.10RTC sub second register (RTC_SSR) . . . . .634
24.6.11RTC shift control register (RTC_SHIFTR) . . . . .635
24.6.12RTC timestamp time register (RTC_TSTR) . . . . .636
24.6.13RTC timestamp date register (RTC_TSDR) . . . . .637
24.6.14RTC time-stamp sub second register (RTC_TSSSR) . . . . .638
24.6.15RTC calibration register (RTC_CALR) . . . . .639
24.6.16RTC tamper and alternate function configuration register
(RTC_TAFCR) . . . . .
640
24.6.17RTC alarm A sub second register (RTC_ALRMASSR) . . . . .643
24.6.18RTC alarm B sub second register (RTC_ALRMBSSR) . . . . .644
24.6.19RTC backup registers (RTC_BKPxR) . . . . .645
24.6.20RTC register map . . . . .645
25Inter-integrated circuit interface (I2C) . . . . .648
25.1Introduction . . . . .648
25.2I2C main features . . . . .648
25.3I2C implementation . . . . .649
25.4I2C functional description . . . . .649
25.4.1I2C block diagram . . . . .650
25.4.2I2C pins and internal signals . . . . .650
25.4.3I2C clock requirements . . . . .651
25.4.4I2C mode selection . . . . .651
25.4.5I2C initialization . . . . .652
25.4.6I2C reset . . . . .656
25.4.7I2C data transfer . . . . .657
25.4.8I2C target mode . . . . .659
25.4.9I2C controller mode . . . . .668
25.4.10I2C_TIMINGR register configuration examples . . . . .679
25.4.11SMBus specific features . . . . .681
25.4.12SMBus initialization . . . . .684
25.4.13SMBus I2C_TIMEOUTR register configuration examples . . . . .686
25.4.14SMBus target mode . . . . .686
25.4.15SMBus controller mode . . . . .690
25.4.16Wake-up from Stop mode on address match . . . . .693
25.4.17Error conditions . . . . .694
25.5I2C in low-power modes . . . . .696
25.6I2C interrupts . . . . .696
25.7I2C DMA requests . . . . .697
25.7.1Transmission using DMA . . . . .697
25.7.2Reception using DMA . . . . .697
25.8I2C debug modes . . . . .697
25.9I2C registers . . . . .698
25.9.1I2C control register 1 (I2C_CR1) . . . . .698
25.9.2I2C control register 2 (I2C_CR2) . . . . .700
25.9.3I2C own address 1 register (I2C_OAR1) . . . . .702
25.9.4I2C own address 2 register (I2C_OAR2) . . . . .703
25.9.5I2C timing register (I2C_TIMINGR) . . . . .704
25.9.6I2C timeout register (I2C_TIMEOUTR) . . . . .705
25.9.7I2C interrupt and status register (I2C_ISR) . . . . .706
25.9.8I2C interrupt clear register (I2C_ICR) . . . . .708
25.9.9I2C PEC register (I2C_PECR) . . . . .709
25.9.10I2C receive data register (I2C_RXDR) . . . . .709
25.9.11I2C transmit data register (I2C_TXDR) . . . . .710
25.9.12I2C register map . . . . .711
26Universal synchronous/asynchronous receiver transmitter (USART/UART) . . . . .712
26.1Introduction . . . . .712
26.2USART main features . . . . .712
26.3USART extended features . . . . .713
26.4USART implementation . . . . .714
26.5USART functional description . . . . .714
26.5.1USART character description . . . . .717
26.5.2USART transmitter . . . . .719
26.5.3USART receiver . . . . .721
26.5.4USART baud rate generation . . . . .728
26.5.5Tolerance of the USART receiver to clock deviation . . . . .730
26.5.6USART auto baud rate detection . . . . .731
26.5.7Multiprocessor communication using USART . . . . .732
26.5.8Modbus communication using USART . . . . .734
26.5.9USART parity control . . . . .735
26.5.10USART LIN (local interconnection network) mode . . . . .736
26.5.11USART synchronous mode . . . . .738
26.5.12USART single-wire half-duplex communication . . . . .741
26.5.13USART smartcard mode . . . . .741
26.5.14USART IrDA SIR ENDEC block . . . . .746
26.5.15USART continuous communication in DMA mode . . . . .748
26.5.16RS232 hardware flow control and RS485 driver enable
using USART . . . . .
750
26.5.17Wake-up from Stop mode using USART . . . . .752
26.6USART in low-power modes . . . . .754
26.7USART interrupts . . . . .754
26.8USART registers . . . . .756
26.8.1USART control register 1 (USART_CR1) . . . . .756
26.8.2USART control register 2 (USART_CR2) . . . . .759
26.8.3USART control register 3 (USART_CR3) . . . . .763
26.8.4USART baud rate register (USART_BRR) . . . . .767
26.8.5USART guard time and prescaler register (USART_GTPR) . . . . .767
26.8.6USART receiver timeout register (USART_RTOR) . . . . .768
26.8.7USART request register (USART_RQR) . . . . .769
26.8.8USART interrupt and status register (USART_ISR) . . . . .770
26.8.9USART interrupt flag clear register (USART_ICR) . . . . .775
26.8.10USART receive data register (USART_RDR) . . . . .777
26.8.11USART transmit data register (USART_TDR) . . . . .777
26.8.12USART register map . . . . .778
27Serial peripheral interface / integrated interchip sound (SPI/I2S) . . .780
27.1Introduction . . . . .780
27.2SPI main features . . . . .780
27.3I2S main features . . . . .781
27.4SPI/I2S implementation . . . . .781
27.5SPI functional description . . . . .782
27.5.1General description . . . . .782
27.5.2Communications between one master and one slave . . . . .783
27.5.3Standard multislave communication . . . . .785
27.5.4Multimaster communication . . . . .786
27.5.5Slave select (NSS) pin management . . . . .787
27.5.6Communication formats . . . . .788
27.5.7Configuration of SPI . . . . .790
27.5.8Procedure for enabling SPI . . . . .791
27.5.9Data transmission and reception procedures . . . . .791
27.5.10SPI status flags . . . . .801
27.5.11SPI error flags . . . . .802
27.5.12NSS pulse mode . . . . .803
27.5.13TI mode . . . . .803
27.5.14CRC calculation . . . . .804
27.6SPI interrupts . . . . .806
27.7I2S functional description . . . . .807
27.7.1I2S general description . . . . .807
27.7.2I2S full duplex . . . . .808
27.7.3Supported audio protocols . . . . .809
27.7.4Start-up description . . . . .815
27.7.5Clock generator . . . . .817
27.7.6I 2 S master mode . . . . .819
27.7.7I 2 S slave mode . . . . .821
27.7.8I2S status flags . . . . .823
27.7.9I2S error flags . . . . .824
27.7.10DMA features . . . . .825
27.8I2S interrupts . . . . .825
27.9SPI and I2S registers . . . . .826
27.9.1SPI control register 1 (SPIx_CR1) . . . . .826
27.9.2SPI control register 2 (SPIx_CR2) . . . . .828
27.9.3SPI status register (SPIx_SR) . . . . .830
27.9.4SPI data register (SPIx_DR) . . . . .832
27.9.5SPI CRC polynomial register (SPIx_CRCPR) . . . . .832
27.9.6SPI Rx CRC register (SPIx_RXCRCR) . . . . .832
27.9.7SPI Tx CRC register (SPIx_TXCRCR) . . . . .833
27.9.8SPIx_I2S configuration register (SPIx_I2SCFGR) . . . . .833
27.9.9SPIx_I2S prescaler register (SPIx_I2SPR) . . . . .835
27.9.10SPI/I2S register map . . . . .836
28Debug support (DBG) . . . . .837
28.1Overview . . . . .837
28.2Reference Arm documentation . . . . .838
28.3SWJ debug port (serial wire and JTAG) . . . . .838
28.3.1Mechanism to select the JTAG-DP or the SW-DP . . . . .839
28.4Pinout and debug port pins . . . . .839
28.4.1SWJ debug port pins . . . . .840
28.4.2Flexible SWJ-DP pin assignment . . . . .840
28.4.3Internal pull-up and pull-down on JTAG pins . . . . .840
28.4.4Using serial wire and releasing the unused debug pins as GPIOs . . . . .842
28.5STM32F3xx JTAG TAP connection . . . . .842
28.6ID codes and locking mechanism . . . . .843
28.6.1MCU device ID code . . . . .843
28.6.2Boundary scan TAP . . . . .844
28.6.3Cortex ® -M4F TAP . . . . .844
28.6.4Cortex ® -M4F JEDEC-106 ID code . . . . .844
28.7JTAG debug port . . . . .844
28.8SW debug port . . . . .846
28.8.1SW protocol introduction . . . . .846
28.8.2SW protocol sequence . . . . .846
28.8.3SW-DP state machine (reset, idle states, ID code) . . . . .847
28.8.4DP and AP read/write accesses . . . . .848
28.8.5SW-DP registers . . . . .848
28.8.6SW-AP registers . . . . .849
28.9AHB-AP (AHB access port) - valid for both JTAG-DP
and SW-DP . . . . .
849
28.10Core debug . . . . .850
28.11Capability of the debugger host to connect under system reset . . . . .851
28.12FPB (Flash patch breakpoint) . . . . .851
28.13DWT (data watchpoint trigger) . . . . .851
28.14ITM (instrumentation trace macrocell) . . . . .852
28.14.1General description . . . . .852
28.14.2Time stamp packets, synchronization, and overflow packets . . . . .852
28.15Arm ® Arm ® MCU debug component (DBGMCU) . . . . .854
28.15.1Debug support for low-power modes . . . . .854
28.15.2Debug support for timers, watchdog I 2 C . . . . .854
28.15.3Debug MCU configuration register . . . . .854
28.15.4Debug MCU APB1 freeze register (DBGMCU_APB1_FZ) . . . . .856
28.15.5Debug MCU APB2 freeze register (DBGMCU_APB2_FZ) . . . . .857

List of tables

Table 1.STM32F3xx peripheral register boundary addresses . . . . .42
Table 2.Boot modes . . . . .44
Table 3.Flash module organization . . . . .46
Table 4.Flash memory read protection status . . . . .55
Table 5.Access status versus protection level and execution modes . . . . .56
Table 6.Flash interrupt request . . . . .57
Table 7.Flash interface - register map and reset values . . . . .63
Table 8.Option byte format . . . . .65
Table 9.Option byte organization . . . . .65
Table 10.Description of the option bytes . . . . .66
Table 11.CRC internal input/output signals . . . . .69
Table 12.CRC register map and reset values . . . . .74
Table 13.Low-power mode summary . . . . .81
Table 14.Sleep-now . . . . .82
Table 15.Sleep-on-exit . . . . .83
Table 16.Stop mode . . . . .84
Table 17.Standby mode . . . . .85
Table 18.PWR register map and reset values . . . . .89
Table 19.RCC register map and reset values . . . . .124
Table 20.Port bit configuration table . . . . .128
Table 21.GPIO register map and reset values . . . . .142
Table 22.SYSCFG register map and reset values . . . . .151
Table 23.DMA implementation . . . . .153
Table 24.DMA requests for each channel . . . . .155
Table 25.Programmable data width and endian behavior (when PINC = MINC = 1) . . . . .162
Table 26.DMA interrupt requests . . . . .164
Table 27.DMA register map and reset values . . . . .172
Table 28.STM32F3xx vector table . . . . .175
Table 29.External interrupt/event controller register map and reset values . . . . .191
Table 30.ADC internal signals . . . . .196
Table 31.ADC pins . . . . .196
Table 32.Configuring the trigger polarity for regular external triggers . . . . .210
Table 33.Configuring the trigger polarity for injected external triggers . . . . .210
Table 34.ADC1 (master) - External triggers for regular channels . . . . .211
Table 35.ADC1 - External trigger for injected channels . . . . .212
Table 36.TSAR timings depending on resolution . . . . .223
Table 37.Offset computation versus data resolution . . . . .226
Table 38.Analog watchdog channel selection . . . . .236
Table 39.Analog watchdog 1 comparison . . . . .237
Table 40.Analog watchdog 2 and 3 comparison . . . . .237
Table 41.ADC interrupts per each ADC . . . . .243
Table 42.ADC global register map . . . . .274
Table 43.ADC register map and reset values for each ADC (offset=0x000
for master ADC, 0x100 for slave ADC, x=1) . . . . .
274
Table 44.ADC register map and reset values (master and slave ADC
common registers) offset =0x300, x=1) . . . . .
276
Table 45.DACx pins . . . . .279
Table 46.External triggers (DAC1) . . . . .282
Table 47.DAC register map and reset values . . . . .291
Table 48.STM32F3xx comparator input/outputs summary . . . . .294
Table 49.COMP register map and reset values. . . . .302
Table 50.Connections with dedicated I/O . . . . .303
Table 51.OPAMP register map and reset values . . . . .312
Table 52.Acquisition sequence summary . . . . .316
Table 53.Spread spectrum deviation versus AHB clock frequency . . . . .318
Table 54.I/O state depending on its mode and IODEF bit value . . . . .319
Table 55.Effect of low-power modes on TSC . . . . .321
Table 56.Interrupt control bits . . . . .321
Table 57.TSC register map and reset values . . . . .329
Table 58.Behavior of timer outputs versus BRK/BRK2 inputs . . . . .373
Table 59.Counting direction versus encoder signals . . . . .380
Table 60.TIM1 internal trigger connection . . . . .397
Table 61.Output control bits for complementary OCx and OCxN channels with break feature . . . . .411
Table 62.TIM1 register map and reset values . . . . .423
Table 63.Counting direction versus encoder signals . . . . .460
Table 64.TIMx internal trigger connection . . . . .477
Table 65.Output control bit for standard OCx channels . . . . .488
Table 66.TIM2 register map and reset values . . . . .494
Table 67.TIMx Internal trigger connection . . . . .537
Table 68.Output control bits for complementary OCx and OCxN channels with break feature (TIM15) . . . . .547
Table 69.TIM15 register map and reset values . . . . .553
Table 70.Output control bits for complementary OCx and OCxN channels with break feature (TIM16/17) . . . . .566
Table 71.TIM16/TIM17 register map and reset values . . . . .573
Table 72.TIM6 register map and reset values . . . . .587
Table 73.WWDG register map and reset values . . . . .594
Table 74.IWDG register map and reset values . . . . .603
Table 75.RTC pin PC13 configuration . . . . .608
Table 76.LSE pin PC14 configuration . . . . .608
Table 77.LSE pin PC15 configuration . . . . .608
Table 78.Effect of low-power modes on RTC . . . . .620
Table 79.Interrupt control bits . . . . .621
Table 80.RTC register map and reset values . . . . .645
Table 81.I2C implementation . . . . .649
Table 82.I2C input/output pins . . . . .650
Table 83.I2C internal input/output signals . . . . .651
Table 84.Comparison of analog and digital filters . . . . .653
Table 85.I 2 C-bus and SMBus specification data setup and hold times . . . . .655
Table 86.I2C configuration . . . . .659
Table 87.I 2 C-bus and SMBus specification clock timings . . . . .670
Table 88.Timing settings for f I2CCLK of 8 MHz . . . . .680
Table 89.Timing settings for f I2CCLK of 16 MHz . . . . .680
Table 90.Timing settings for f I2CCLK of 48 MHz . . . . .681
Table 91.SMBus timeout specifications . . . . .683
Table 92.SMBus with PEC configuration . . . . .685
Table 93.TIMEOUTA[11:0] for maximum t TIMEOUT of 25 ms . . . . .686
Table 94.TIMEOUTB[11:0] for maximum t LOW:SEXT and t LOW:MEXT of 8 ms . . . . .686
Table 95.TIMEOUTA[11:0] for maximum t IDLE of 50 µs . . . . .686
Table 96.Effect of low-power modes to I2C . . . . .696
Table 97.I2C interrupt requests . . . . .696
Table 98.I2C register map and reset values . . . . .711
Table 99.STM32F3xx USART features . . . . .714
Table 100.Noise detection from sampled data . . . . .726
Table 101.Error calculation for programmed baud rates at \( f_{CK} = 72\text{MHz} \) in both cases of oversampling by 16 or by 8. . . . .729
Table 102.Tolerance of the USART receiver when BRR [3:0] = 0000. . . . .731
Table 103.Tolerance of the USART receiver when BRR [3:0] is different from 0000 . . . . .731
Table 104.Frame formats . . . . .735
Table 105.Effect of low-power modes on the USART . . . . .754
Table 106.USART interrupt requests. . . . .754
Table 107.USART register map and reset values . . . . .778
Table 108.STM32F301x6/8 and STM32F318x8 SPI/I2S implementation . . . . .781
Table 109.SPI interrupt requests . . . . .806
Table 110.Audio-frequency precision using standard 8 MHz HSE . . . . .819
Table 111.I2S interrupt requests . . . . .825
Table 112.SPI/I2S register map and reset values . . . . .836
Table 113.SWJ debug port pins . . . . .840
Table 114.Flexible SWJ-DP pin assignment . . . . .840
Table 115.JTAG debug port data registers . . . . .844
Table 116.32-bit debug port registers addressed through the shifted value A[3:2] . . . . .845
Table 117.Packet request (8-bits) . . . . .846
Table 118.ACK response (3 bits). . . . .847
Table 119.DATA transfer (33 bits). . . . .847
Table 120.SW-DP registers . . . . .848
Table 121.Cortex ® -M4F AHB-AP registers . . . . .850
Table 122.Core debug registers . . . . .850
Table 123.Main ITM registers . . . . .853
Table 124.Asynchronous TRACE pin assignment. . . . .858
Table 125.Flexible TRACE pin assignment. . . . .859
Table 126.Important TPIU registers. . . . .862
Table 127.DBG register map and reset values . . . . .863
Table 128.Document revision history . . . . .867

List of figures

Figure 1.System architecture . . . . .38
Figure 2.Programming procedure . . . . .50
Figure 3.Flash memory Page Erase procedure . . . . .52
Figure 4.Flash memory Mass Erase procedure . . . . .53
Figure 5.CRC calculation unit block diagram . . . . .69
Figure 6.Power supply overview (STM32F301xx devices) . . . . .75
Figure 7.Power supply overview (STM32F318xx devices) . . . . .76
Figure 8.Power on reset/power down reset waveform . . . . .79
Figure 9.PVD thresholds . . . . .80
Figure 10.Simplified diagram of the reset circuit . . . . .91
Figure 11.STM32F3xx clock tree . . . . .93
Figure 12.HSE/ LSE clock sources . . . . .94
Figure 13.Frequency measurement with TIM16 in capture mode . . . . .99
Figure 14.Basic structure of an I/O port bit . . . . .127
Figure 15.Basic structure of a 5-Volt tolerant I/O port bit . . . . .127
Figure 16.Input floating / pull up / pull down configurations . . . . .132
Figure 17.Output configuration . . . . .133
Figure 18.Alternate function configuration . . . . .134
Figure 19.High impedance-analog configuration . . . . .134
Figure 20.DMA request mapping . . . . .154
Figure 21.DMA block diagram . . . . .156
Figure 22.External interrupt/event block diagram . . . . .179
Figure 23.External interrupt/event GPIO mapping . . . . .182
Figure 24.ADC block diagram . . . . .195
Figure 25.ADC clock scheme . . . . .197
Figure 26.ADC1 connectivity . . . . .198
Figure 27.ADC calibration . . . . .201
Figure 28.Updating the ADC calibration factor . . . . .201
Figure 29.Mixing single-ended and differential channels . . . . .202
Figure 30.Enabling / Disabling the ADC . . . . .203
Figure 31.Analog-to-digital conversion time . . . . .208
Figure 32.Stopping ongoing regular conversions . . . . .209
Figure 33.Stopping ongoing regular and injected conversions . . . . .209
Figure 34.Triggers are shared between ADC master & ADC slave . . . . .211
Figure 35.Injected conversion latency . . . . .213
Figure 36.Example of JSQR queue of context (sequence change) . . . . .216
Figure 37.Example of JSQR queue of context (trigger change) . . . . .217
Figure 38.Example of JSQR queue of context with overflow before conversion . . . . .217
Figure 39.Example of JSQR queue of context with overflow during conversion . . . . .218
Figure 40.Example of JSQR queue of context with empty queue (case JQM=0) . . . . .218
Figure 41.Example of JSQR queue of context with empty queue (case JQM=1) . . . . .219
Figure 42.Flushing JSQR queue of context by setting JADSTP=1 (JQM=0).
Case when JADSTP occurs during an ongoing conversion. . . . .
219
Figure 43.Flushing JSQR queue of context by setting JADSTP=1 (JQM=0).
Case when JADSTP occurs during an ongoing conversion and a new
trigger occurs. . . . .
220
Figure 44.Flushing JSQR queue of context by setting JADSTP=1 (JQM=0).
Case when JADSTP occurs outside an ongoing conversion . . . . .
220
Figure 45.Flushing JSQR queue of context by setting JADSTP=1 (JQM=1) . . . . .221
Figure 46.Flushing JSQR queue of context by setting ADDIS=1 (JQM=0). . . . .221
Figure 47.Flushing JSQR queue of context by setting ADDIS=1 (JQM=1). . . . .222
Figure 48.Example of JSQR queue of context when changing SW and HW triggers. . . . .222
Figure 49.Single conversions of a sequence, software trigger . . . . .224
Figure 50.Continuous conversion of a sequence, software trigger. . . . .225
Figure 51.Single conversions of a sequence, hardware trigger . . . . .225
Figure 52.Continuous conversions of a sequence, hardware trigger . . . . .225
Figure 53.Right alignment (offset disabled, unsigned value) . . . . .227
Figure 54.Right alignment (offset enabled, signed value). . . . .228
Figure 55.Left alignment (offset disabled, unsigned value) . . . . .228
Figure 56.Left alignment (offset enabled, signed value). . . . .229
Figure 57.Example of overrun (OVR) . . . . .230
Figure 58.AUTODLY=1, regular conversion in continuous mode, software trigger . . . . .233
Figure 59.AUTODLY=1, regular HW conversions interrupted by injected conversions
(DISCEN=0; JDISCEN=0) . . . . .
233
Figure 60.AUTODLY=1, regular HW conversions interrupted by injected conversions
(DISCEN=1, JDISCEN=1) . . . . .
234
Figure 61.AUTODLY=1, regular continuous conversions interrupted by injected conversions . . . . .235
Figure 62.AUTODLY=1 in auto- injected mode (JAUTO=1). . . . .235
Figure 63.Analog watchdog's guarded area . . . . .236
Figure 64.ADC y _AWD x _OUT signal generation (on all regular channels). . . . .238
Figure 65.ADC y _AWD x _OUT signal generation (AWD x flag not cleared by SW) . . . . .239
Figure 66.ADC y _AWD x _OUT signal generation (on a single regular channel) . . . . .239
Figure 67.ADC y _AWD x _OUT signal generation (on all injected channels) . . . . .239
Figure 68.Temperature sensor channel block diagram . . . . .240
Figure 69.VBAT channel block diagram . . . . .241
Figure 70.DAC1 block diagram. . . . .279
Figure 71.Data registers in single DAC channel mode . . . . .280
Figure 72.Timing diagram for conversion with trigger disabled TEN = 0 . . . . .281
Figure 73.DAC LFSR register calculation algorithm . . . . .283
Figure 74.DAC conversion (SW trigger enabled) with LFSR wave generation. . . . .283
Figure 75.DAC triangle wave generation . . . . .284
Figure 76.DAC conversion (SW trigger enabled) with triangle wave generation . . . . .284
Figure 77.Comparator 2 block diagram . . . . .293
Figure 78.Comparator 4 block diagram . . . . .293
Figure 79.Comparator 6 block diagram . . . . .293
Figure 80.Comparator output blanking . . . . .296
Figure 81.Comparator and operational amplifier
connections . . . . .
304
Figure 82.Timer controlled Multiplexer mode . . . . .305
Figure 83.Standalone mode: external gain setting mode . . . . .306
Figure 84.Follower configuration. . . . .307
Figure 85.PGA mode, internal gain setting (x2/x4/x8/x16), inverting input not used . . . . .308
Figure 86.PGA mode, internal gain setting (x2/x4/x8/x16), inverting input used for
filtering . . . . .
308
Figure 87.TSC block diagram . . . . .314
Figure 88.Surface charge transfer analog I/O group structure . . . . .315
Figure 89.Sampling capacitor voltage variation . . . . .316
Figure 90.Charge transfer acquisition sequence . . . . .317
Figure 91.Spread spectrum variation principle . . . . .318
Figure 92.Advanced-control timer block diagram . . . . .333
Figure 93.Counter timing diagram with prescaler division change from 1 to 2 . . . . .336
Figure 94.Counter timing diagram with prescaler division change from 1 to 4 . . . . .336
Figure 95.Counter timing diagram, internal clock divided by 1 . . . . .338
Figure 96.Counter timing diagram, internal clock divided by 2 . . . . .338
Figure 97.Counter timing diagram, internal clock divided by 4 . . . . .339
Figure 98.Counter timing diagram, internal clock divided by N . . . . .339
Figure 99.Counter timing diagram, update event when ARPE=0 (TIMx_ARR not preloaded) . . . . .340
Figure 100.Counter timing diagram, update event when ARPE=1 (TIMx_ARR preloaded) . . . . .340
Figure 101.Counter timing diagram, internal clock divided by 1 . . . . .342
Figure 102.Counter timing diagram, internal clock divided by 2 . . . . .342
Figure 103.Counter timing diagram, internal clock divided by 4 . . . . .343
Figure 104.Counter timing diagram, internal clock divided by N . . . . .343
Figure 105.Counter timing diagram, update event when repetition counter is not used . . . . .344
Figure 106.Counter timing diagram, internal clock divided by 1, TIMx_ARR = 0x6 . . . . .345
Figure 107.Counter timing diagram, internal clock divided by 2 . . . . .346
Figure 108.Counter timing diagram, internal clock divided by 4, TIMx_ARR=0x36 . . . . .346
Figure 109.Counter timing diagram, internal clock divided by N . . . . .347
Figure 110.Counter timing diagram, update event with ARPE=1 (counter underflow) . . . . .347
Figure 111.Counter timing diagram, Update event with ARPE=1 (counter overflow) . . . . .348
Figure 112.Update rate examples depending on mode and TIMx_RCR register settings . . . . .349
Figure 113.External trigger input block . . . . .350
Figure 114.Control circuit in normal mode, internal clock divided by 1 . . . . .351
Figure 115.TI2 external clock connection example . . . . .352
Figure 116.Control circuit in external clock mode 1 . . . . .353
Figure 117.External trigger input block . . . . .353
Figure 118.Control circuit in external clock mode 2 . . . . .354
Figure 119.Capture/compare channel (example: channel 1 input stage) . . . . .355
Figure 120.Capture/compare channel 1 main circuit . . . . .356
Figure 121.Output stage of capture/compare channel (channel 1, idem ch. 2 and 3) . . . . .356
Figure 122.Output stage of capture/compare channel (channel 4) . . . . .357
Figure 123.Output stage of capture/compare channel (channel 5, idem ch. 6) . . . . .357
Figure 124.PWM input mode timing . . . . .359
Figure 125.Output compare mode, toggle on OC1 . . . . .361
Figure 126.Edge-aligned PWM waveforms (ARR=8) . . . . .362
Figure 127.Center-aligned PWM waveforms (ARR=8) . . . . .363
Figure 128.Generation of 2 phase-shifted PWM signals with 50% duty cycle . . . . .365
Figure 129.Combined PWM mode on channel 1 and 3 . . . . .366
Figure 130.3-phase combined PWM signals with multiple trigger pulses per period . . . . .367
Figure 131.Complementary output with dead-time insertion . . . . .368
Figure 132.Dead-time waveforms with delay greater than the negative pulse . . . . .368
Figure 133.Dead-time waveforms with delay greater than the positive pulse . . . . .369
Figure 134.Various output behavior in response to a break event on BKIN (OSSI = 1) . . . . .372
Figure 135.PWM output state following BKIN and BKIN2 pins assertion (OSSI=1) . . . . .373
Figure 136.PWM output state following BKIN assertion (OSSI=0) . . . . .374
Figure 137.Clearing TIMx_OCxREF . . . . .375
Figure 138.6-step generation, COM example (OSSR=1) . . . . .376
Figure 139.Example of one pulse mode . . . . .377
Figure 140.Retriggerable one pulse mode . . . . .379
Figure 141.Example of counter operation in encoder interface mode . . . . .380
Figure 142.Example of encoder interface mode with TI1FP1 polarity inverted . . . . .381
Figure 143.Measuring time interval between edges on 3 signals . . . . .382
Figure 144.Example of Hall sensor interface . . . . .384
Figure 145. Control circuit in reset mode . . . . .385
Figure 146. Control circuit in Gated mode . . . . .386
Figure 147. Control circuit in trigger mode . . . . .387
Figure 148. Control circuit in external clock mode 2 + trigger mode . . . . .388
Figure 149. General-purpose timer block diagram . . . . .427
Figure 150. Counter timing diagram with prescaler division change from 1 to 2 . . . . .429
Figure 151. Counter timing diagram with prescaler division change from 1 to 4 . . . . .429
Figure 152. Counter timing diagram, internal clock divided by 1 . . . . .430
Figure 153. Counter timing diagram, internal clock divided by 2 . . . . .431
Figure 154. Counter timing diagram, internal clock divided by 4 . . . . .431
Figure 155. Counter timing diagram, internal clock divided by N . . . . .432
Figure 156. Counter timing diagram, Update event when ARPE=0 (TIMx_ARR not preloaded). . . . .432
Figure 157. Counter timing diagram, Update event when ARPE=1 (TIMx_ARR preloaded). . . . .433
Figure 158. Counter timing diagram, internal clock divided by 1 . . . . .434
Figure 159. Counter timing diagram, internal clock divided by 2 . . . . .434
Figure 160. Counter timing diagram, internal clock divided by 4 . . . . .435
Figure 161. Counter timing diagram, internal clock divided by N . . . . .435
Figure 162. Counter timing diagram, Update event . . . . .436
Figure 163. Counter timing diagram, internal clock divided by 1, TIMx_ARR=0x6 . . . . .437
Figure 164. Counter timing diagram, internal clock divided by 2 . . . . .438
Figure 165. Counter timing diagram, internal clock divided by 4, TIMx_ARR=0x36 . . . . .438
Figure 166. Counter timing diagram, internal clock divided by N . . . . .439
Figure 167. Counter timing diagram, Update event with ARPE=1 (counter underflow). . . . .439
Figure 168. Counter timing diagram, Update event with ARPE=1 (counter overflow). . . . .440
Figure 169. Control circuit in normal mode, internal clock divided by 1 . . . . .441
Figure 170. TI2 external clock connection example. . . . .441
Figure 171. Control circuit in external clock mode 1 . . . . .442
Figure 172. External trigger input block . . . . .443
Figure 173. Control circuit in external clock mode 2 . . . . .444
Figure 174. Capture/Compare channel (example: channel 1 input stage) . . . . .445
Figure 175. Capture/Compare channel 1 main circuit . . . . .445
Figure 176. Output stage of Capture/Compare channel (channel 1). . . . .446
Figure 177. PWM input mode timing . . . . .448
Figure 178. Output compare mode, toggle on OC1 . . . . .450
Figure 179. Edge-aligned PWM waveforms (ARR=8). . . . .451
Figure 180. Center-aligned PWM waveforms (ARR=8). . . . .452
Figure 181. Generation of 2 phase-shifted PWM signals with 50% duty cycle . . . . .453
Figure 182. Combined PWM mode on channels 1 and 3 . . . . .455
Figure 183. Clearing TIMx_OCxREF . . . . .456
Figure 184. Example of one-pulse mode. . . . .457
Figure 185. Retriggerable one-pulse mode . . . . .459
Figure 186. Example of counter operation in encoder interface mode . . . . .460
Figure 187. Example of encoder interface mode with TI1FP1 polarity inverted . . . . .461
Figure 188. Control circuit in reset mode . . . . .462
Figure 189. Control circuit in gated mode . . . . .463
Figure 190. Control circuit in trigger mode . . . . .464
Figure 191. Control circuit in external clock mode 2 + trigger mode . . . . .465
Figure 192. Master/Slave timer example . . . . .466
Figure 193. Master/slave connection example with 1 channel only timers . . . . .466
Figure 194. Gating TIM2 with OC1REF of TIM1 . . . . .467
Figure 195. Gating TIM2 with Enable of TIM1 . . . . .468
Figure 196. Triggering TIM2 with update of TIM1 . . . . .469
Figure 197. Triggering TIM2 with Enable of TIM1 . . . . .469
Figure 198. TIM15 block diagram . . . . .498
Figure 199. TIM16/TIM17 block diagram . . . . .499
Figure 200. Counter timing diagram with prescaler division change from 1 to 2 . . . . .501
Figure 201. Counter timing diagram with prescaler division change from 1 to 4 . . . . .501
Figure 202. Counter timing diagram, internal clock divided by 1 . . . . .503
Figure 203. Counter timing diagram, internal clock divided by 2 . . . . .503
Figure 204. Counter timing diagram, internal clock divided by 4 . . . . .504
Figure 205. Counter timing diagram, internal clock divided by N . . . . .504
Figure 206. Counter timing diagram, update event when ARPE=0 (TIMx_ARR not preloaded). . . . .505
Figure 207. Counter timing diagram, update event when ARPE=1 (TIMx_ARR preloaded). . . . .505
Figure 208. Update rate examples depending on mode and TIMx_RCR register settings . . . . .507
Figure 209. Control circuit in normal mode, internal clock divided by 1 . . . . .508
Figure 210. TI2 external clock connection example. . . . .508
Figure 211. Control circuit in external clock mode 1 . . . . .509
Figure 212. Capture/compare channel (example: channel 1 input stage). . . . .510
Figure 213. Capture/compare channel 1 main circuit . . . . .510
Figure 214. Output stage of capture/compare channel (channel 1). . . . .511
Figure 215. Output stage of capture/compare channel (channel 2 for TIM15) . . . . .511
Figure 216. PWM input mode timing . . . . .513
Figure 217. Output compare mode, toggle on OC1 . . . . .515
Figure 218. Edge-aligned PWM waveforms (ARR=8) . . . . .516
Figure 219. Combined PWM mode on channel 1 and 2 . . . . .517
Figure 220. Complementary output with dead-time insertion. . . . .518
Figure 221. Dead-time waveforms with delay greater than the negative pulse. . . . .518
Figure 222. Dead-time waveforms with delay greater than the positive pulse. . . . .519
Figure 223. Output behavior in response to a break . . . . .522
Figure 224. 6-step generation, COM example (OSSR=1) . . . . .523
Figure 225. Example of one pulse mode . . . . .524
Figure 226. Retriggerable one pulse mode . . . . .526
Figure 227. Measuring time interval between edges on 2 signals . . . . .527
Figure 228. Control circuit in reset mode . . . . .528
Figure 229. Control circuit in gated mode . . . . .529
Figure 230. Control circuit in trigger mode . . . . .530
Figure 231. Basic timer block diagram. . . . .575
Figure 232. Counter timing diagram with prescaler division change from 1 to 2 . . . . .577
Figure 233. Counter timing diagram with prescaler division change from 1 to 4 . . . . .577
Figure 234. Counter timing diagram, internal clock divided by 1 . . . . .578
Figure 235. Counter timing diagram, internal clock divided by 2 . . . . .579
Figure 236. Counter timing diagram, internal clock divided by 4 . . . . .579
Figure 237. Counter timing diagram, internal clock divided by N . . . . .580
Figure 238. Counter timing diagram, update event when ARPE = 0 (TIMx_ARR not preloaded). . . . .580
Figure 239. Counter timing diagram, update event when ARPE=1 (TIMx_ARR preloaded). . . . .581
Figure 240. Control circuit in normal mode, internal clock divided by 1 . . . . .582
Figure 241. IRTIM internal hardware connections with TIM16 and TIM17 . . . . .588
Figure 242. Watchdog block diagram . . . . .590
Figure 243. Window watchdog timing diagram . . . . .591
Figure 244. Independent watchdog block diagram . . . . .595
Figure 245.RTC block diagram . . . . .606
Figure 246.Block diagram . . . . .650
Figure 247.I 2 C-bus protocol . . . . .652
Figure 248.Setup and hold timings . . . . .654
Figure 249.I2C initialization flow . . . . .656
Figure 250.Data reception . . . . .657
Figure 251.Data transmission . . . . .658
Figure 252.Target initialization flow . . . . .661
Figure 253.Transfer sequence flow for I2C target transmitter, NOSTRETCH = 0 . . . . .663
Figure 254.Transfer sequence flow for I2C target transmitter, NOSTRETCH = 1 . . . . .664
Figure 255.Transfer bus diagrams for I2C target transmitter (mandatory events only) . . . . .665
Figure 256.Transfer sequence flow for I2C target receiver, NOSTRETCH = 0 . . . . .666
Figure 257.Transfer sequence flow for I2C target receiver, NOSTRETCH = 1 . . . . .667
Figure 258.Transfer bus diagrams for I2C target receiver
(mandatory events only) . . . . .
667
Figure 259.Controller clock generation . . . . .669
Figure 260.Controller initialization flow . . . . .671
Figure 261.10-bit address read access with HEAD10R = 0 . . . . .671
Figure 262.10-bit address read access with HEAD10R = 1 . . . . .672
Figure 263.Transfer sequence flow for I2C controller transmitter, N ≤ 255 bytes. . . . .673
Figure 264.Transfer sequence flow for I2C controller transmitter, N > 255 bytes. . . . .674
Figure 265.Transfer bus diagrams for I2C controller transmitter
(mandatory events only) . . . . .
675
Figure 266.Transfer sequence flow for I2C controller receiver, N ≤ 255 bytes . . . . .677
Figure 267.Transfer sequence flow for I2C controller receiver, N > 255 bytes. . . . .678
Figure 268.Transfer bus diagrams for I2C controller receiver
(mandatory events only) . . . . .
679
Figure 269.Timeout intervals for t LOW:SEXT , t LOW:MEXT . . . . .683
Figure 270.Transfer sequence flow for SMBus target transmitter N bytes + PEC . . . . .687
Figure 271.Transfer bus diagram for SMBus target transmitter (SBC = 1). . . . .687
Figure 272.Transfer sequence flow for SMBus target receiver N bytes + PEC . . . . .689
Figure 273.Bus transfer diagrams for SMBus target receiver (SBC = 1) . . . . .690
Figure 274.Bus transfer diagrams for SMBus controller transmitter . . . . .691
Figure 275.Bus transfer diagrams for SMBus controller receiver . . . . .693
Figure 276.USART block diagram . . . . .716
Figure 277.Word length programming . . . . .718
Figure 278.Configurable stop bits . . . . .720
Figure 279.TC/TXE behavior when transmitting . . . . .721
Figure 280.Start bit detection when oversampling by 16 or 8. . . . .722
Figure 281.Data sampling when oversampling by 16 . . . . .726
Figure 282.Data sampling when oversampling by 8 . . . . .726
Figure 283.Mute mode using Idle line detection . . . . .733
Figure 284.Mute mode using address mark detection . . . . .734
Figure 285.Break detection in LIN mode (11-bit break length - LBDL bit is set). . . . .737
Figure 286.Break detection in LIN mode vs. Framing error detection. . . . .738
Figure 287.USART example of synchronous transmission. . . . .739
Figure 288.USART data clock timing diagram (M bits = 00). . . . .739
Figure 289.USART data clock timing diagram (M bits = 01) . . . . .740
Figure 290.RX data setup/hold time . . . . .740
Figure 291.ISO 7816-3 asynchronous protocol . . . . .742
Figure 292.Parity error detection using the 1.5 stop bits . . . . .743
Figure 293.IrDA SIR ENDEC- block diagram . . . . .747
Figure 294. IrDA data modulation (3/16) - normal mode . . . . .747
Figure 295. Transmission using DMA . . . . .749
Figure 296. Reception using DMA . . . . .750
Figure 297. Hardware flow control between 2 USARTs . . . . .750
Figure 298. RS232 RTS flow control . . . . .751
Figure 299. RS232 CTS flow control . . . . .752
Figure 300. USART interrupt mapping diagram . . . . .755
Figure 301. SPI block diagram. . . . .782
Figure 302. Full-duplex single master/ single slave application. . . . .783
Figure 303. Half-duplex single master/ single slave application . . . . .784
Figure 304. Simplex single master/single slave application (master in transmit-only/
slave in receive-only mode) . . . . .
785
Figure 305. Master and three independent slaves. . . . .786
Figure 306. Multimaster application . . . . .787
Figure 307. Hardware/software slave select management . . . . .788
Figure 308. Data clock timing diagram . . . . .789
Figure 309. Data alignment when data length is not equal to 8-bit or 16-bit . . . . .790
Figure 310. Packing data in FIFO for transmission and reception . . . . .794
Figure 311. Master full-duplex communication . . . . .797
Figure 312. Slave full-duplex communication . . . . .798
Figure 313. Master full-duplex communication with CRC . . . . .799
Figure 314. Master full-duplex communication in packed mode . . . . .800
Figure 315. NSSP pulse generation in Motorola SPI master mode. . . . .803
Figure 316. TI mode transfer . . . . .804
Figure 317. I2S block diagram . . . . .807
Figure 318. I2S full-duplex block diagram . . . . .808
Figure 319. I 2 S Philips protocol waveforms (16/32-bit full accuracy). . . . .810
Figure 320. I 2 S Philips standard waveforms (24-bit frame) . . . . .810
Figure 321. Transmitting 0x8EAA33 . . . . .810
Figure 322. Receiving 0x8EAA33 . . . . .811
Figure 323. I 2 S Philips standard (16-bit extended to 32-bit packet frame) . . . . .811
Figure 324. Example of 16-bit data frame extended to 32-bit channel frame . . . . .811
Figure 325. MSB Justified 16-bit or 32-bit full-accuracy length . . . . .812
Figure 326. MSB justified 24-bit frame length . . . . .812
Figure 327. MSB justified 16-bit extended to 32-bit packet frame . . . . .812
Figure 328. LSB justified 16-bit or 32-bit full-accuracy . . . . .813
Figure 329. LSB justified 24-bit frame length . . . . .813
Figure 330. Operations required to transmit 0x3478AE. . . . .813
Figure 331. Operations required to receive 0x3478AE . . . . .814
Figure 332. LSB justified 16-bit extended to 32-bit packet frame . . . . .814
Figure 333. Example of 16-bit data frame extended to 32-bit channel frame . . . . .814
Figure 334. PCM standard waveforms (16-bit) . . . . .815
Figure 335. PCM standard waveforms (16-bit extended to 32-bit packet frame). . . . .815
Figure 336. Start sequence in master mode . . . . .816
Figure 337. Audio sampling frequency definition . . . . .817
Figure 338. I 2 S clock generator architecture . . . . .817
Figure 339. Block diagram of STM32 MCU and
Cortex ® -M4F-level debug support . . . . .
837
Figure 340. SWJ debug port . . . . .839
Figure 341. JTAG TAP connections . . . . .843
Figure 342. TPIU block diagram . . . . .858

Chapters