Page 1
This reference manual targets application developers. It provides complete information on how to use the STM32G4 Series microcontroller memory and peripherals. The STM32G4 Series is a family of microcontrollers with different memory sizes, packages and peripherals. For ordering information, mechanical and electrical device characteristics refer to the corresponding datasheets.
Page 7
RM0440 Contents 6.4.5 Power status register 1 (PWR_SR1) ......259 6.4.6 Power status register 2 (PWR_SR2) ......260 6.4.7 Power status clear register (PWR_SCR) .
Page 42
Contents RM0440 40.5.15 SAI data register (SAI_ADR) ....... 1852 40.5.16 SAI data register (SAI_BDR) ....... 1853 40.5.17 SAI PDM control register (SAI_PDMCR) .
Page 46
Contents RM0440 45.5.5 Suspend/Resume events ........2021 45.6 USB and USB SRAM registers .
Page 47
Using serial wire and releasing the unused debug pins as GPIOs . . 2085 47.5 STM32G4 Series JTAG TAP connection ..... . . 2085 47.6 ID codes and locking mechanism .
Page 51
RM0440 List of tables Table 100. CRC internal input/output signals ......... . . 462 Table 101.
Page 52
List of tables RM0440 Table 151. 16-bit NAND Flash ............559 Table 152.
Page 53
RM0440 List of tables Table 201. Operating modes and calibration ......... . . 795 Table 202.
Page 54
Table 267. STM32G4 Series general purpose timers ........
Page 55
Table 309. STM32G4 Series LPTIM features........
Page 56
Table 356. LPUART register map and reset values ........1732 Table 357. STM32G4 Series SPI and SPI/I2S implementation ......1735 Table 358.
Page 57
Table 407. STM32G4 Series USB implementation ........
Page 58
STM32G4 Series power supply overview ........
Page 59
RM0440 List of figures Figure 49. X1 buffer initialization ........... . 502 Figure 50.
Page 60
List of figures RM0440 Figure 101. Example of JSQR queue of context with overflow before conversion ....637 Figure 102. Example of JSQR queue of context with overflow during conversion ....637 Figure 103.
Page 61
RM0440 List of figures Figure 147. Interleaved single channel CH0 with injected sequence CH11, CH12 ....678 Figure 148. Two Interleaved channels (CH1, CH2) with injected sequence CH11, CH12 - case 1: Master interrupted first .
Page 62
List of figures RM0440 Figure 193. Auto-delayed compare ........... 868 Figure 194.
Page 63
RM0440 List of figures Figure 245. Fault signal filtering (FLTxF[3:0]= 0010: f = fHRTIM, N = 4) ....928 SAMPLING Figure 246. Fault counter cumulative mode (FLTxRSTM = 1, FLTxCNT[3:0] = 2) ....930 Figure 247.
Page 64
List of figures RM0440 Figure 295. Control circuit in external clock mode 2 ........1111 Figure 296.
Page 65
RM0440 List of figures Figure 347. Index behavior in directional clock mode, IPOS[0] = 1 ......1160 Figure 348.
Page 66
List of figures RM0440 Figure 399. Clearing TIMx tim_ocxref ..........1269 Figure 400.
Page 67
RM0440 List of figures Figure 449. Update rate examples depending on mode and TIMx_RCR register settings ..1358 Figure 450. Control circuit in normal mode, internal clock divided by 1 ..... . . 1359 Figure 451.
Page 68
List of figures RM0440 Figure 498. Waveform generation ........... 1472 Figure 499.
Page 69
RM0440 List of figures Figure 547. Parity error detection using the 1.5 stop bits ....... . . 1629 Figure 548.
Page 70
List of figures RM0440 Figure 595. MSB justified 24-bit frame length ......... . 1765 Figure 596.
Page 71
RM0440 List of figures Figure 645. 10-bit address read access with HEAD10R=1 ....... . 1884 Figure 646.
Documentation conventions RM0440 Documentation conventions General information ®(a) ® The STM32G4 Series devices have an Arm Cortex -M4 with FPU core. List of abbreviations for registers The following abbreviations are used in register descriptions: read/write (rw) Software can read and write to this bit.
The present reference manual describes the superset of features for each product category. Refer to Table 2 for the list of features per category. Table 1. STM32G4 Series memory density Memory density Category 2 Category 3 Category 4...
Documentation conventions RM0440 Table 2. Product specific features STM32G474/ STM32G473/ STM32G431/ STM32G491/ Feature STM32G471 STM32G484 STM32G483 STM32G441 STM32G4A1 512/256/128K, 512/256/128K, 512/256/128K, 128/64/32K, 512/256K, Flash Dual bank Dual bank Dual bank single bank single bank 16K, parity check 80K, parity check 80K, parity check 80K, parity check 80K, parity check...
Page 75
RM0440 Documentation conventions Table 2. Product specific features (continued) STM32G474/ STM32G473/ STM32G431/ STM32G491/ Feature STM32G471 STM32G484 STM32G483 STM32G441 STM32G4A1 HRTIM1 Advanced control timers TIM1/8/20 TIM1/8/20 TIM1/8/20 TIM1/8 TIM1/8/20 (TIM1/TIM8 TIM20) General purpose timers TIM2/3/4/5 TIM2/3/4/5 TIM2/3/4 TIM2/3/4 TIM2/3/4 (TIM2/TIM3 TIM4/TIM5) General purpose timers...
Page 76
Documentation conventions RM0440 Table 2. Product specific features (continued) STM32G474/ STM32G473/ STM32G431/ STM32G491/ Feature STM32G471 STM32G484 STM32G483 STM32G441 STM32G4A1 3 x FDCAN 3 x FDCAN 2 x FDCAN 1 x FDCAN 2 x FDCAN FDCAN (FDCAN1..3) (FDCAN1..3) (FDCAN1,2) (FDCAN1) (FDCAN1,2) USB device 1 x USB device 1 x USB device...
RM0440 System and memory overview System and memory overview System architecture The main system consists of 32-bit multilayer AHB bus matrix that interconnects: • Up to five masters: ® – Cortex -M4 with FPU core I-bus ® – Cortex -M4 with FPU core D-bus ®...
System and memory overview RM0440 Figure 1. System architecture ® Cortex DMA1 DMA2 with FPU ICode FLASH 512 KB DCode SRAM1 CCM SRAM SRAM2 AHB1 peripherals AHB2 peripherals FSMC QUADSPI BusMatrix-S MSv45850V1 2.1.1 I-bus ® This bus connects the instruction bus of the Cortex -M4 with FPU core to the BusMatrix.
RM0440 System and memory overview 2.1.3 S-bus ® This bus connects the system bus of the Cortex -M4 with FPU core to the BusMatrix. This bus is used by the core to access data located in a peripheral or SRAM area. The targets of this bus are the internal SRAM, the AHB1 peripherals including the APB1 and APB2 peripherals, the AHB2 peripherals and the external memories through the QUADSPI or the FSMC.
RM0440 Memory organization 2.2.1 Introduction Program memory, data memory, registers and I/O ports are organized within the same linear 4-Gbyte address space. The bytes are coded in memory in Little Endian format. The lowest numbered byte in a word is considered the word’s least significant byte and the highest numbered byte the most significant.
“Reserved”. For the detailed mapping of available memory and register areas, refer to the following table. The following table gives the boundary addresses of the peripherals available in the devices. Table 3. STM32G4 Series memory map and peripheral register boundary addresses Size Boundary address...
In the STM32G4 Series devices both the peripheral registers and the SRAM are mapped to a bit-band region, so that single bit-band write and read operations are allowed. The ®...
0x20000300 (0x01: bit set; 0x00: bit reset). Embedded SRAM The STM32G4 Series category 3 devices feature up to 128 Kbytes SRAM: • 80 Kbytes SRAM1 (mapped at address 0x2000 0000) • 16 Kbytes SRAM2 (mapped at address 0x2001 4000) •...
RM0440 Execution can be performed from CCM SRAM with maximum performance without any remap thanks to access through ICode bus. The CCM SRAM is aliased at address following the end of SRAM2 (0x2000 5800 for category 2 devices, 0x2001 8000 for category 3 devices, 0x2001 8000 for category 4 devices), offering a continuous address space with the SRAM1 and SRAM2.
The information block. It is composed of three parts: – Option bytes for hardware and memory protection user configuration. – System memory that contains the ST proprietary code. – OTP (one-time programmable) area The Flash interface implements instruction access and data access based on the AHB protocol.
Page 90
RM0440 The BOOT0 pin or user option bit (depending on the nSWBOOT0 bit value in the FLASH_OPTR register), and nBOOT1 bit are also re-sampled when exiting from Standby mode. Consequently, they must be kept in the required Boot mode configuration in Standby mode.
3. Even when aliased in the boot memory space, the related memory is still accessible at its original memory space. Embedded boot loader The embedded boot loader is located in the system memory, programmed by ST during production. Refer to AN2606 STM32 microcontroller system memory boot mode.
Embedded Flash memory (FLASH) for category 3 devices RM0440 Embedded Flash memory (FLASH) for category 3 devices Introduction The Flash memory interface manages CPU AHB ICode and DCode accesses to the Flash memory. It implements the erase and program Flash memory operations and the read and write protection mechanisms.
USART, SPI, I2C, FDCAN, USB. It is programmed by STMicroelectronics when the device is manufactured, and protected against spurious write/erase operations. For further details, please refer to the AN2606 available from www.st.com. – 1 Kbyte (128 double word) OTP (one-time programmable) bytes for user data. The OTP area is available in Bank 1 only.
Embedded Flash memory (FLASH) for category 3 devices RM0440 Single bank mode (DBANK=0, 128-bits data width) Data in Flash memory are 144-bits words: 8 bits are added per each double word. The ECC mechanism supports: • One error detection and correction •...
RM0440 Embedded Flash memory (FLASH) for category 3 devices Table 9. Number of wait states according to CPU clock (HCLK) frequency HCLK (MHz) Wait states (WS) Range 1 Range 1 (LATENCY) CORE CORE Range 2 CORE boost mode normal mode 0 WS (1 CPU cycles) ≤...
Embedded Flash memory (FLASH) for category 3 devices RM0440 RCC_CFGR register and then (if needed) modify the CPU clock prescaler by writing the HPRE bits in RCC_CFGR. Check that the new CPU clock source or/and the new CPU clock prescaler value is/are taken into account by reading the clock source status (SWS bits) or/and the AHB prescaler value (HPRE bits), respectively, in the RCC_CFGR register.
RM0440 Embedded Flash memory (FLASH) for category 3 devices Figure 3. Sequential 16-bit instructions execution (64-bit read data width) WAIT WITHOUT PREFETCH WAIT ins 1 ins 2 ins 3 ins 4 ins 5 ins 6 ins 7 ins 8 fetch fetch fetch fetch...
Data in option bytes block are not cacheable. 3.3.5 Flash program and erase operations The STM32G4 Series embedded Flash memory can be programmed using in-circuit programming or in-application programming. The in-circuit programming (ICP) method is used to update the entire contents of the Flash memory, using the JTAG, SWD protocol or the boot loader to load the user application into the microcontroller.
RM0440 Embedded Flash memory (FLASH) for category 3 devices a write/erase operation is performed to the other bank (refer to Section 3.3.8: Read-while- write (RWW) available only in dual bank mode (DBANK=1)). The Flash erase and programming is only possible in the voltage scaling range 1. The VOS[1:0] bits in the PWR_CR1 must be programmed to 01b.
Embedded Flash memory (FLASH) for category 3 devices RM0440 Note: The internal oscillator HSI16 (16 MHz) is enabled automatically when STRT bit is set, and disabled automatically when STRT bit is cleared, except if the HSI16 is previously enabled with HSION in RCC_CR register. If the page erase is part of write-protected area (by WRP or PCROP), WRPERR is set and the page erase request is aborted.
Page 103
RM0440 Embedded Flash memory (FLASH) for category 3 devices Standard programming The Flash memory programming sequence in standard mode is as follows: Check that no Flash main memory operation is ongoing by checking the BSY bit in the Flash status register (FLASH_SR).
Page 104
Embedded Flash memory (FLASH) for category 3 devices RM0440 bootloader. In dual bank mode (DBANK=1), perform a mass erase of the bank to program. If not, PGSERR is set. Check that no Flash main memory operation is ongoing by checking the BSY bit in the Flash status register (FLASH_SR).
Page 105
RM0440 Embedded Flash memory (FLASH) for category 3 devices Programming errors Several kind of errors are detected. In case of error, the Flash operation (programming or erasing) is aborted. • PROGERR: Programming Error In standard programming: PROGERR is set if the word to write is not previously erased (except if the value to program is full zero).
Embedded Flash memory (FLASH) for category 3 devices RM0440 In fast programming: all the data must be written successively. MISSERR is set if the previous data programmation is finished and the next data to program is not written yet. • FASTERR: Fast Programming Error In fast programming: FASTERR is set if one of the following conditions occurs: –...
Page 107
RM0440 Embedded Flash memory (FLASH) for category 3 devices Read from bank 1 while mass erasing bank 2 (or vice versa) While executing a program code from bank 1, it is possible to perform a mass erase operation on bank 2 (and vice versa). Follow the procedure below: Check that no Flash memory operation is ongoing by checking the BSY bit in the Flash status register (FLASH_SR)
Embedded Flash memory (FLASH) for category 3 devices RM0440 FLASH option bytes 3.4.1 Option bytes description The option bytes are configured by the end user depending on the application requirements. As a configuration example, the watchdog may be selected in hardware or software mode (refer to Section 5.4.2: Option bytes programming).
Page 110
Embedded Flash memory (FLASH) for category 3 devices RM0440 Bit 25 CCMSRAM_RST: CCM SRAM erase when system reset 0: CCM SRAM erased when a system reset occurs 1: CCM SRAM is not erased when a system reset occurs Bit 24 SRAM_PE: SRAM1 and CCM SRAM parity check enable 0: SRAM1 and CCM SRAM parity check enable 1: SRAM1 and CCM SRAM parity check disable Bit 23 nBOOT1: Boot configuration...
Page 111
0xAA: Level 0, read protection not active 0xCC: Level 2, chip read protection active Others: Level 1, memories read protection active PCROP1 Start address option bytes Flash memory address: 0x1FFF 7808 ST production value: 0xFFFF FFFF Res. Res. Res. Res.
Page 112
PCROP1_END contains the last double-word of the bank 1 PCROP area. DBANK=0 PCROP1_END contains the last 2x double-word PCROP area for all memory. WRP1 Area A address option bytes Flash memory address: 0x1FFF 7818 ST production value: 0xFF00 FFFF Res. Res. Res. Res.
Page 113
RM0440 Embedded Flash memory (FLASH) for category 3 devices WRP2 Area A address option bytes Flash memory address: 0x1FFF 7820 ST production value: 0xFF00 FFFF Res. Res. Res. Res. Res. Res. Res. Res. Res. WRP2A_END[6:0] Res. Res. Res. Res. Res.
Page 114
Embedded Flash memory (FLASH) for category 3 devices RM0440 Bits 7:0 SEC_SIZE1 Securable memory area size Contains the number of Securable Flash memory pages PCROP2 Start address option bytes Flash memory address: 0x1FFFF808 ST production value: 0xFFFF FFFF Res. Res. Res. Res. Res.
Page 115
RM0440 Embedded Flash memory (FLASH) for category 3 devices WRP1 Area B address option bytes Flash memory address: 0x1FFF F818 ST production value: 0xFF00 FFFF Res. Res. Res. Res. Res. Res. Res. Res. Res. WRP1B_END[6:0] Res. Res. Res. Res. Res.
WRP2B_STRT contains the first page of the WRP second area for bank2. DBANK=0 WRP2B_STRT contains the first page of the WRP second area for all memory. Securable memory area Bank 2 option bytes Flash memory address: 0x1FFF F828 ST production value: 0xFF00 FF00 Res. Res. Res. Res.
Page 117
RM0440 Embedded Flash memory (FLASH) for category 3 devices Modifying user options The option bytes are programmed differently from a main memory user address. It is not possible to modify independently user options of bank 1 or bank 2. The users Options of the bank 1 are modified first.
Page 118
Embedded Flash memory (FLASH) for category 3 devices RM0440 FLASH_PCROP1/2ER, FLASH_WRP1/2AR, FLASH_WRP1/2BR). These registers are also used to modify options. If these registers are not modified by user, they reflects the options states of the system. See Section : Modifying user options for more details.
RM0440 Embedded Flash memory (FLASH) for category 3 devices FLASH memory protection The Flash main memory can be protected against external accesses with the Read protection (RDP). The pages of the Flash memory can also be protected against unwanted write due to loss of program counter contexts. The write-protection (WRP) granularity is one page (2 KByte).
Page 120
Embedded Flash memory (FLASH) for category 3 devices RM0440 Level 1: Read protection This is the default protection level when RDP option byte is erased. It is defined as well when RDP value is at any value different from 0xAA and 0xCC, or even if the complement is not correct.
RM0440 Embedded Flash memory (FLASH) for category 3 devices Only when both banks are erased, options are re-programmed with their previous values. This is also true for FLASH_PCROPxSR and FLASH_PCROPxER registers (x=1,2). Note: Full mass erase or partial mass erase is performed only when Level 1 is active and Level 0 requested.
Embedded Flash memory (FLASH) for category 3 devices RM0440 Table 13. Access status versus protection level and execution modes (continued) Debug/ BootFromRam/ User execution (BootFromFlash) Protection BootFromLoader Area level Read Write Erase Read Write Erase Backup registers CCM SRAM 1. When the protection level 2 is active, the Debug port, the boot from RAM and the boot from system memory are disabled. 2.
RM0440 Embedded Flash memory (FLASH) for category 3 devices For example, to protect by PCROP from the address 0x0806 2F80 (included) to the address 0x0807 0004 (included): • if boot in flash is done in Bank 1, FLASH_PCROP1SR and FLASH_PCROP1ER registers must be programmed with: –...
Embedded Flash memory (FLASH) for category 3 devices RM0440 1. When DBANK=1, the minimum PCROP area size is 2xdouble words: PCROPx_offset_strt and PCROPx_offset_end. When DBANK=0, the minimum PCROP area size is 2x(2xdouble words): PCROPx_offset_strt and PCROPx_offset_end. When DBANK=1, it is the user’s responsibility to make sure no overlapping occurs on the PCROP zones. 3.5.3 Write protection (WRP) The user area in Flash memory can be protected against unwanted write operations.
RM0440 Embedded Flash memory (FLASH) for category 3 devices If an erase/program operation to a write-protected part of the Flash memory is attempted, the write protection error flag (WRPERR) is set in the FLASH_SR register. This flag is also set for any write access to: –...
Embedded Flash memory (FLASH) for category 3 devices RM0440 In RDP level 2, the debugger is disabled by hardware, but in other RDP levels, the debugger can be disabled by software using the bit DBG_SWEN in the FLASH_ACR register. Figure 11 gives an example of managing DBG_SWEN and SEC_PROT bits.
Embedded Flash memory (FLASH) for category 3 devices RM0440 Bit 11 ICRST: Instruction cache reset 0: Instruction cache is not reset 1: Instruction cache is reset This bit can be written only when the instruction cache is disabled. Bit 10 DCEN: Data cache enable 0: Data cache is disabled 1: Data cache is enabled Bit 9 ICEN: Instruction cache enable...
Embedded Flash memory (FLASH) for category 3 devices RM0440 3.7.5 Flash status register (FLASH_SR) Address offset: 0x10 Reset value: 0x0000 0000 Access: no wait state, word, half-word and byte access Res. Res. Res. Res. Res. Res. Res. Res. Res. Res. Res.
Page 131
RM0440 Embedded Flash memory (FLASH) for category 3 devices Bit 7 PGSERR: Programming sequence error Set by hardware when a write access to the Flash memory is performed by the code while PG or FSTPG have not been set previously. Set also by hardware when PROGERR, SIZERR, PGAERR, WRPERR, MISSERR or FASTERR is set due to a previous programming error.
Embedded Flash memory (FLASH) for category 3 devices RM0440 3.7.6 Flash control register (FLASH_CR) Address offset: 0x14 Reset value: 0xC000 0000 Access: no wait state when no Flash memory operation is on going, word, half-word and byte access SEC_ SEC_ OBL_ LOCK Res.
Page 133
RM0440 Embedded Flash memory (FLASH) for category 3 devices Bit 25 ERRIE: Error interrupt enable This bit enables the interrupt generation when the OPERR bit in the FLASH_SR is set to 1. 0: OPERR error interrupt disabled 1: OPERR error interrupt enabled Bit 24 EOPIE: End of operation interrupt enable This bit enables the interrupt generation when the EOP bit in the FLASH_SR is set to 1.
Embedded Flash memory (FLASH) for category 3 devices RM0440 Bits 9:3 PNB[6:0]: Page number selection These bits select the page to erase: 00000000: page 0 00000001: page 1 11111111: page 255 Bit 2 MER1: Bank 1 Mass erase This bit triggers the bank 1 mass erase (all bank 1 user pages) when set. Bit 1 PER: Page erase 0: page erase disabled 1: page erase enabled...
Page 135
RM0440 Embedded Flash memory (FLASH) for category 3 devices Bit 31 ECCD: ECC detection DBANK=1 Set by hardware when two ECC errors have been detected (only if ECCC/ECCC2/ECCD/ ECCD2 are previously cleared). When this bit is set, a NMI is generated. Cleared by writing 1.
Embedded Flash memory (FLASH) for category 3 devices RM0440 Bit 22 SYSF_ECC: System Flash ECC fail This bit indicates that the ECC error correction or double ECC error detection is located in the System Flash. Bit 21 BK_ECC: ECC fail bank DBANK=1 This bit indicates which bank is concerned by the ECC error correction or by the double ECC error detection.
Page 137
RM0440 Embedded Flash memory (FLASH) for category 3 devices Bit 31 Reserved, must be kept at reset value. Bit 30 IRHEN: Internal reset holder enable bit 0: Internal resets are propagated as simple pulse on NRST pin 1: Internal resets drives NRST pin low until it is seen as low level Bits 29:28 NRST_MODE[1:0] 00: Reserved 01: Reset Input only: a low level on the NRST pin generates system reset,...
Embedded Flash memory (FLASH) for category 3 devices RM0440 Bit 16 IDWG_SW: Independent watchdog selection 0: Hardware independent watchdog 1: Software independent watchdog Bit 15 Reserved, must be kept cleared Bit 14 nRST_SHDW 0: Reset generated when entering the Shutdown mode 1: No reset generated when entering the Shutdown mode Bit 13 nRST_STDBY 0: Reset generated when entering the Standby mode...
RM0440 Embedded Flash memory (FLASH) for category 3 devices Bits 31:15 Reserved, must be kept cleared Bits 14:0 PCROP1_STRT: PCROP area start offset DBANK=1 PCROP1_STRT contains the first double-word of the PCROP area for bank1. DBANK=0 PCROP1_STRT contains the first 2xdouble-word of the PCROP area for all memory.
Embedded Flash memory (FLASH) for category 3 devices RM0440 3.7.11 Flash Bank 1 WRP area A address register (FLASH_WRP1AR) Address offset: 0x2C Reset value: 0x00XX 00XX. Register bits are loaded with values from Flash memory at OBL. Access: no wait state when no Flash memory operation is on going, word, half-word and byte access Res.
RM0440 Embedded Flash memory (FLASH) for category 3 devices Bits 31:23 Reserved, must be kept cleared Bits 22:16 WRP1B_END: WRP second area “B” end offset DBANK=1 WRP1B_END contains the last page of the WRP second area for bank1. DBANK=0 WRP1B_END contains the last page of the WPR second area for all memory. Bits 15:7 Reserved, must be kept cleared Bits 6:0 WRP1B_STRT: WRP second area “B”...
Embedded Flash memory (FLASH) for category 3 devices RM0440 Bits 31:15 Reserved, must be kept cleared Bits 14:0 PCROP2_END: PCROP area end offset DBANK=1 PCROP2_END contains the last double-word of the PCROP area for bank2. DBANK=0 PCROP2_END contains the last 2xdouble-word of the PCROP area for all the memory.
RM0440 Embedded Flash memory (FLASH) for category 3 devices 3.7.16 Flash Bank 2 WRP area B address register (FLASH_WRP2BR) Address offset: 0x50 Reset value: 0x00XX 00XX Access: no wait state when no Flash memory operation is on going, word, half-word and byte access Res.
Embedded Flash memory (FLASH) for category 3 devices RM0440 Bits 31:17 Reserved, must be kept cleared Bit 16 BOOT_LOCK used to force boot from user Flash area 0: Boot based on the pad/option bit configuration 1: Boot forced from Main Flash memory Caution: If BOOT_LOCK is set in association with RDP Level 1, the debug capabilities of the device are stopped and the reset value of the DBG_SWEN bit of the FLASH_ACR register becomes zero.
RM0440 Embedded Flash memory (FLASH) for category 3 devices 3.7.19 FLASH register map Table 17. Flash interface - register map and reset values Offset Register LATENCY FLASH_ACR [3:0] 0x00 Reset value FLASH_ PDKEYR[31:0] PDKEYR 0x04 Reset value FLASH_KEYR KEYR[31:0] 0x08 Reset value FLASH_OPT OPTKEYR[31:0]...
Page 146
Embedded Flash memory (FLASH) for category 3 devices RM0440 Table 17. Flash interface - register map and reset values (continued) Offset Register FLASH_ WRP1B_END[6:0] WRP1B_STRT[6:0] WRP1BR 0x30 Reset value X X X X X X X X X X X X X X FLASH_ PCROP2_STRT[14:0] PCROP2SR...
RM0440 Embedded Flash memory (FLASH) for category 4 devices Embedded Flash memory (FLASH) for category 4 devices Introduction The Flash memory interface manages CPU AHB ICode and DCode accesses to the Flash memory. It implements the erase and program Flash memory operations and the read and write protection mechanisms.
USART, SPI, I2C, USB. It is programmed by STMicroelectronics when the device is manufactured, and protected against spurious write/erase operations. For further details, please refer to the AN2606 available from www.st.com. – 1 Kbyte (128 double word) OTP (one-time programmable) bytes for user data. The OTP data cannot be erased and can be written only once.
RM0440 Embedded Flash memory (FLASH) for category 4 devices 4.3.2 Error code correction (ECC) Data in Flash memory are 72-bits words: 8 bits are added per double word (64 bits). The ECC mechanism supports: • One error detection and correction •...
Embedded Flash memory (FLASH) for category 4 devices RM0440 Increasing the CPU frequency: Program the new number of wait states to the LATENCY bits in the Flash access control register (FLASH_ACR). Check that the new number of wait states is taken into account to access the Flash memory by reading the FLASH_ACR register.
Page 151
RM0440 Embedded Flash memory (FLASH) for category 4 devices Instruction prefetch ® The Cortex -M4 fetches the instruction over the ICode bus and the literal pool (constant/data) over the DCode bus. The prefetch block aims at increasing the efficiency of ICode bus accesses.
Embedded Flash memory (FLASH) for category 4 devices RM0440 Figure 6. Sequential 16-bit instructions execution (64-bit read data width) WAIT WITHOUT PREFETCH WAIT ins 1 ins 2 ins 3 ins 4 ins 5 ins 6 ins 7 ins 8 fetch fetch fetch fetch...
Data in option bytes block are not cacheable. 4.3.5 Flash program and erase operations The STM32G4 Series embedded Flash memory can be programmed using in-circuit programming or in-application programming. The in-circuit programming (ICP) method is used to update the entire contents of the Flash memory, using the JTAG, SWD protocol or the boot loader to load the user application into the microcontroller.
Embedded Flash memory (FLASH) for category 4 devices RM0440 During a program/erase operation to the Flash memory, any attempt to read the Flash memory stalls the bus. The read operation proceeds correctly once the program/erase operation has completed. Unlocking the Flash memory After reset, write is not allowed in the Flash control register (FLASH_CR) to protect the...
RM0440 Embedded Flash memory (FLASH) for category 4 devices Check that no Flash memory operation is ongoing by checking the BSY bit in the FLASH_SR register. Check and clear all error programming flags due to a previous programming. If not, PGSERR is set.
Page 156
Embedded Flash memory (FLASH) for category 4 devices RM0440 automatically when PG bit is set, and disabled automatically when PG bit is cleared, except if the HSI16 is previously enabled with HSION in RCC_CR register. If the user needs to program only one word, double word must be completed with the erase value 0xFFFF FFFF to launch automatically the programming.
Page 157
RM0440 Embedded Flash memory (FLASH) for category 4 devices Programming errors Several kind of errors can be detected. In case of error, the Flash operation (programming or erasing) is aborted. • PROGERR: Programming Error In standard programming: PROGERR is set if the word to write is not previously erased (except if the value to program is full zero).
Page 158
Embedded Flash memory (FLASH) for category 4 devices RM0440 In fast programming: FASTERR is set if one of the following conditions occurs: – When FSTPG bit is set for more than 7ms which generates a time-out detection. – When the fast programming has been interrupted by a MISSERR, PGAERR, WRPERR or SIZERR.
Embedded Flash memory (FLASH) for category 4 devices RM0440 4.4.2 Option bytes programming After reset, the options related bits in the Flash control register (FLASH_CR) are write- protected. To run any operation on the option bytes page, the option lock bit OPTLOCK in Flash control register (FLASH_CR) must be cleared.
RM0440 Embedded Flash memory (FLASH) for category 4 devices If the comparison between the word and its complement fails, a status bit OPTVERR is set. Mismatch values are forced into the option registers: – For USR OPT option, the value of mismatch is all options at ‘1’, except for BOR_LEV which is “000”...
Page 166
Embedded Flash memory (FLASH) for category 4 devices RM0440 Level 0: no protection Read, program and erase operations into the Flash main memory area are possible. The option bytes, the CCM SRAM and the backup registers are also accessible by all operations.
RM0440 Embedded Flash memory (FLASH) for category 4 devices If the bit PCROP_RDP is cleared in the FLASH_PCROP1ER, the full mass erase is replaced by a partial mass erase that is successive page erases, except for the pages protected by PCROP. This is done in order to keep the PCROP code. Only when the Flash memory is erased, options are re-programmed with their previous values.
RM0440 Embedded Flash memory (FLASH) for category 4 devices Any read access performed through the D-bus to a PCROP protected area triggers RDERR flag error. Any PCROP protected address is also write protected and any write access to one of these addresses triggers WRPERR.
Embedded Flash memory (FLASH) for category 4 devices RM0440 For example, to protect by WRP from the address 0x0801 2800 (included) to the address 0x0801 87FF (included): • if boot in flash is selected, FLASH_WRP1AR register must be programmed with: –...
RM0440 Embedded Flash memory (FLASH) for category 4 devices The size of the Securable memory area is defined by the SEC_SIZE1[8:0] bitfield of the FLASH_SEC register. It can be modified only in RDP Level 0. Its content is erased upon changing from RDP Level 1 to Level 0, even if it overlaps with PCROP pages.
Embedded Flash memory (FLASH) for category 4 devices RM0440 Bit 11 ICRST: Instruction cache reset 0: Instruction cache is not reset 1: Instruction cache is reset This bit can be written only when the instruction cache is disabled. Bit 10 DCEN: Data cache enable 0: Data cache is disabled 1: Data cache is enabled Bit 9 ICEN: Instruction cache enable...
RM0440 Embedded Flash memory (FLASH) for category 4 devices Bit 6 SIZERR: Size error Set by hardware when the size of the access is a byte or half-word during a program or a fast program sequence. Only double word programming is allowed (consequently: word access).
Page 178
Embedded Flash memory (FLASH) for category 4 devices RM0440 Bit 31 LOCK: FLASH_CR Lock This bit is set only. When set, the FLASH_CR register is locked. It is cleared by hardware after detecting the unlock sequence. In case of an unsuccessful unlock operation, this bit remains set until the next system reset.
RM0440 Embedded Flash memory (FLASH) for category 4 devices Bit 16 START: Start This bit triggers an erase operation when set. If MER1, MER2 and PER bits are reset and the STRT bit is set, an unpredictable behavior may occur without generating any error flag.
Embedded Flash memory (FLASH) for category 4 devices RM0440 Bit 24 ECCCIE: ECC correction interrupt enable 0: ECCC interrupt disabled 1: ECCC interrupt enabled. This bit enables the interrupt generation when the ECCC bit in the FLASH_ECCR register is set. Bit 23 Reserved, must be kept at reset value.
Page 181
RM0440 Embedded Flash memory (FLASH) for category 4 devices Bit 26 nSWBOOT0: Software BOOT0 0: BOOT0 taken from the option bit nBOOT0 1: BOOT0 taken from PB8/BOOT0 pin Bit 25 CCMSRAM_RST: CCM SRAM Erase when system reset 0: CCM SRAM erased when a system reset occurs 1: CCM SRAM is not erased when a system reset occurs Bit 24 SRAM_PE: SRAM1 and CCM SRAM parity check enable 0: SRAM1 and CCM SRAM parity check enable...
Embedded Flash memory (FLASH) for category 4 devices RM0440 Bit 11 Reserved, must be kept cleared Bits10:8 BOR_LEV: BOR reset Level These bits contain the VDD supply level threshold that activates/releases the reset. 000: BOR Level 0. Reset level threshold is around 1.7 V 001: BOR Level 1.
RM0440 Embedded Flash memory (FLASH) for category 4 devices 4.7.10 Flash PCROP1 End address register (FLASH_PCROP1ER) Address offset: 0x28 Reset value: 0xX000 XXXX. Register bits are loaded with values from Flash memory at OBL. Access: no wait state when no Flash memory operation is on going, word, half-word access. PCROP_RDP bit can be accessed with byte access.
Embedded Flash memory (FLASH) for category 4 devices RM0440 Bits 23:16 WRP1A_END: WRP first area “A” end offset WRP1A_END contains the last page of WRP first area. Bits 15:8 Reserved, must be kept cleared Bits 7:0 WRP1A_STRT: WRP first area “A” start offset WRP1A_STRT contains the first page of WRP first area.
Page 185
RM0440 Embedded Flash memory (FLASH) for category 4 devices Bits 31:17 Reserved, must be kept cleared Bit 16 BOOT_LOCK used to force boot from user Flash area 0: Boot based on the pad/option bit configuration 1: Boot forced from Main Flash memory Caution: If BOOT_LOCK is set in association with RDP Level 1, the debug capabilities of the device are stopped and the reset value of the DBG_SWEN bit of the FLASH_ACR register becomes zero.
Embedded Flash memory (FLASH) for category 4 devices RM0440 4.7.14 FLASH register map Table 27. Flash interface - register map and reset values Offset Register LATENCY FLASH_ACR [3:0] 0x00 Reset value FLASH_ PDKEYR[31:0] PDKEYR 0x04 Reset value FLASH_KEYR KEYR[31:0] 0x08 Reset value FLASH_OPT OPTKEYR[31:0]...
Page 187
RM0440 Embedded Flash memory (FLASH) for category 4 devices Table 27. Flash interface - register map and reset values (continued) Offset Register FLASH_ WRP1B_END[7:0] WRP1B_STRT[7:0] WRP1BR 0x30 Reset value X X X X X X X X X X X X X X X X FLASH_ SEC_SIZE1[8:0] SEC1R...
Embedded Flash memory (FLASH) for category 2 devices RM0440 Embedded Flash memory (FLASH) for category 2 devices Introduction The Flash memory interface manages CPU AHB ICode and DCode accesses to the Flash memory. It implements the erase and program Flash memory operations and the read and write protection mechanisms.
USART, SPI, I2C, USB. It is programmed by STMicroelectronics when the device is manufactured, and protected against spurious write/erase operations. For further details, please refer to the AN2606 available from www.st.com. – 1 Kbyte (128 double word) OTP (one-time programmable) bytes for user data. The OTP data cannot be erased and can be written only once.
Embedded Flash memory (FLASH) for category 2 devices RM0440 5.3.2 Error code correction (ECC) Data in Flash memory are 72-bits words: 8 bits are added per double word (64 bits). The ECC mechanism supports: • One error detection and correction •...
RM0440 Embedded Flash memory (FLASH) for category 2 devices Increasing the CPU frequency: Program the new number of wait states to the LATENCY bits in the Flash access control register (FLASH_ACR). Check that the new number of wait states is taken into account to access the Flash memory by reading the FLASH_ACR register.
Page 192
Embedded Flash memory (FLASH) for category 2 devices RM0440 Instruction prefetch ® The Cortex -M4 fetches the instruction over the ICode bus and the literal pool (constant/data) over the DCode bus. The prefetch block aims at increasing the efficiency of ICode bus accesses.
RM0440 Embedded Flash memory (FLASH) for category 2 devices Figure 9. Sequential 16-bit instructions execution (64-bit read data width) WAIT WITHOUT PREFETCH WAIT ins 1 ins 2 ins 3 ins 4 ins 5 ins 6 ins 7 ins 8 fetch fetch fetch fetch...
Data in option bytes block are not cacheable. 5.3.5 Flash program and erase operations The STM32G4 Series embedded Flash memory can be programmed using in-circuit programming or in-application programming. The in-circuit programming (ICP) method is used to update the entire contents of the Flash memory, using the JTAG, SWD protocol or the boot loader to load the user application into the microcontroller.
RM0440 Embedded Flash memory (FLASH) for category 2 devices During a program/erase operation to the Flash memory, any attempt to read the Flash memory stalls the bus. The read operation proceeds correctly once the program/erase operation has completed. Unlocking the Flash memory After reset, write is not allowed in the Flash control register (FLASH_CR) to protect the...
Embedded Flash memory (FLASH) for category 2 devices RM0440 Check that no Flash memory operation is ongoing by checking the BSY bit in the FLASH_SR register. Check and clear all error programming flags due to a previous programming. If not, PGSERR is set.
Page 197
RM0440 Embedded Flash memory (FLASH) for category 2 devices automatically when PG bit is set, and disabled automatically when PG bit is cleared, except if the HSI16 is previously enabled with HSION in RCC_CR register. If the user needs to program only one word, double word must be completed with the erase value 0xFFFF FFFF to launch automatically the programming.
Page 198
Embedded Flash memory (FLASH) for category 2 devices RM0440 Programming errors Several kind of errors can be detected. In case of error, the Flash operation (programming or erasing) is aborted. • PROGERR: Programming Error In standard programming: PROGERR is set if the word to write is not previously erased (except if the value to program is full zero).
Page 199
RM0440 Embedded Flash memory (FLASH) for category 2 devices In fast programming: FASTERR is set if one of the following conditions occurs: – When FSTPG bit is set for more than 7ms which generates a time-out detection. – When the fast programming has been interrupted by a MISSERR, PGAERR, WRPERR or SIZERR.
Unused END [5:0] _STRT [5:0] [5:0] [5:0] BOOT_ SEC_ BOOT_ SEC_ 1FFF7828 Unused Unused Unused Unused LOCK SIZE1 LOCK SIZE1 User and read protection option bytes Flash memory address: 0x1FFF 7800 ST production value: 0xFFEF F8AA 200/2126 RM0440 Rev 4...
Page 201
RM0440 Embedded Flash memory (FLASH) for category 2 devices IRH_ PG10_ CCMSRAM SRAM WWDG IWGD_ IWDG_ IWDG_ Res. Res. Res. Res. Mode BOOT0 BOOT0 _RST BOOT1 STDBY STOP nRST_ nRST_ nRST_ Res. Res. BOR_LEV[2:0] RDP[7:0] SHDW STDBY STOP Bit 31 Reserved, must be kept at reset value. Bit 30 IRH_IN: Internal reset holder for PG10 0: IRH disabled 1: IRH enabled...
Page 202
0xAA: Level 0, read protection not active 0xCC: Level 2, chip read protection active Others: Level 1, memories read protection active PCROP1 Start address option bytes Flash memory address: 0x1FFF 7808 ST production value: 0xFFFF FFFF Res. Res. Res. Res.
Page 203
Bits 30:14 Reserved, must be kept at reset value. Bits 13:0 PCROP1_END: Bank 1 PCROP area end offset PCROP1_END contains the last double-word of the PCROP area. WRP1 Area A address option bytes Flash memory address: 0x1FFF 7818 ST production value: 0xFF00 FFFF Res. Res. Res. Res.
Page 204
Embedded Flash memory (FLASH) for category 2 devices RM0440 WRP2 Area A address option bytes Flash memory address: 0x1FFF 7820 ST production value: 0xFF00 FFFF Res. Res. Res. Res. Res. Res. Res. Res. Res. Res. WRP2A_END[5:0] Res. Res. Res. Res.
RM0440 Embedded Flash memory (FLASH) for category 2 devices 5.4.2 Option bytes programming After reset, the options related bits in the Flash control register (FLASH_CR) are write- protected. To run any operation on the option bytes page, the option lock bit OPTLOCK in Flash control register (FLASH_CR) must be cleared.
Embedded Flash memory (FLASH) for category 2 devices RM0440 If the comparison between the word and its complement fails, a status bit OPTVERR is set. Mismatch values are forced into the option registers: – For USR OPT option, the value of mismatch is all options at ‘1’, except for BOR_LEV which is “000”...
Page 207
RM0440 Embedded Flash memory (FLASH) for category 2 devices Level 0: no protection Read, program and erase operations into the Flash main memory area are possible. The option bytes, the CCM SRAM and the backup registers are also accessible by all operations.
Embedded Flash memory (FLASH) for category 2 devices RM0440 If the bit PCROP_RDP is cleared in the FLASH_PCROP1ER, the full mass erase is replaced by a partial mass erase that is successive page erases, except for the pages protected by PCROP. This is done in order to keep the PCROP code. Only when the Flash memory is erased, options are re-programmed with their previous values.
Embedded Flash memory (FLASH) for category 2 devices RM0440 Any read access performed through the D-bus to a PCROP protected area triggers RDERR flag error. Any PCROP protected address is also write protected and any write access to one of these addresses triggers WRPERR.
RM0440 Embedded Flash memory (FLASH) for category 2 devices For example, to protect by WRP from the address 0x0801 2800 (included) to the address 0x0801 87FF (included): • if boot in flash is selected, FLASH_WRP1AR register must be programmed with: –...
Embedded Flash memory (FLASH) for category 2 devices RM0440 The size of the Securable memory area is defined by the SEC_SIZE1[7:0] bitfield of the FLASH_SEC register. It can be modified only in RDP Level 0. Its content is erased upon changing from RDP Level 1 to Level 0, even if it overlaps with PCROP pages.
RM0440 Embedded Flash memory (FLASH) for category 2 devices Bit 11 ICRST: Instruction cache reset 0: Instruction cache is not reset 1: Instruction cache is reset This bit can be written only when the instruction cache is disabled. Bit 10 DCEN: Data cache enable 0: Data cache is disabled 1: Data cache is enabled Bit 9 ICEN: Instruction cache enable...
Embedded Flash memory (FLASH) for category 2 devices RM0440 Bit 6 SIZERR: Size error Set by hardware when the size of the access is a byte or half-word during a program or a fast program sequence. Only double word programming is allowed (consequently: word access).
Page 219
RM0440 Embedded Flash memory (FLASH) for category 2 devices Bit 31 LOCK: FLASH_CR Lock This bit is set only. When set, the FLASH_CR register is locked. It is cleared by hardware after detecting the unlock sequence. In case of an unsuccessful unlock operation, this bit remains set until the next system reset.
Page 220
Embedded Flash memory (FLASH) for category 2 devices RM0440 Bit 16 START: Start This bit triggers an erase operation when set. If MER1, MER2 and PER bits are reset and the STRT bit is set, an unpredictable behavior may occur without generating any error flag.
Page 221
RM0440 Embedded Flash memory (FLASH) for category 2 devices Bit 31 ECCD: ECC detection Set by hardware when two ECC errors have been detected (only if ECCC/ECCD are previously cleared). When this bit is set, a NMI is generated. Cleared by writing 1. Bit 30 ECCC: ECC correction Set by hardware when one ECC error has been detected and corrected (only if ECCC/ECCC2/ECCD/ECCD2 are previously cleared).
Page 222
Embedded Flash memory (FLASH) for category 2 devices RM0440 Bit 31 Reserved, must be kept at reset value. Bit 30 IRHEN: Internal reset holder enable bit 0: Internal resets are propagated as simple pulse on NRST pin 1: Internal resets drives NRST pin low until it is seen as low level Bits 29:28 NRST_MODE[1:0] 00: Reserved 01: Reset Input only: a low level on the NRST pin generates system reset,...
Page 223
RM0440 Embedded Flash memory (FLASH) for category 2 devices Bit 13 nRST_STDBY 0: Reset generated when entering the Standby mode 1: No reset generate when entering the Standby mode Bit 12 nRST_STOP 0: Reset generated when entering the Stop mode 1: No reset generated when entering the Stop mode Bit 11 Reserved, must be kept cleared Bits10:8 BOR_LEV: BOR reset Level...
Page 224
Embedded Flash memory (FLASH) for category 2 devices RM0440 5.7.10 Flash PCROP1 End address register (FLASH_PCROP1ER) Address offset: 0x28 Reset value: 0xX000 XXXX. Register bits are loaded with values from Flash memory at OBL. Access: no wait state when no Flash memory operation is on going, word, half-word access. PCROP_RDP bit can be accessed with byte access.
Page 225
RM0440 Embedded Flash memory (FLASH) for category 2 devices Bits 21:16 WRP1A_END: WRP first area “A” end offset WRP1A_END contains the last page of WRP first area. Bits 15:6 Reserved, must be kept cleared Bits 5:0 WRP1A_STRT: WRP first area “A” start offset WRP1A_STRT contains the first page of WRP first area.
Page 226
Embedded Flash memory (FLASH) for category 2 devices RM0440 Bits 31:17 Reserved, must be kept cleared Bit 16 BOOT_LOCK used to force boot from user Flash area 0: Boot based on the pad/option bit configuration 1: Boot forced from Main Flash memory Caution: If BOOT_LOCK is set in association with RDP Level 1, the debug capabilities of the device are stopped and the reset value of the DBG_SWEN bit of the FLASH_ACR register becomes zero.
RM0440 Embedded Flash memory (FLASH) for category 2 devices 5.7.14 FLASH register map Table 37. Flash interface - register map and reset values Offset Register LATENCY FLASH_ACR [3:0] 0x00 Reset value FLASH_ PDKEYR[31:0] PDKEYR 0x04 Reset value FLASH_KEYR KEYR[31:0] 0x08 Reset value FLASH_OPT OPTKEYR[31:0]...
Page 228
Embedded Flash memory (FLASH) for category 2 devices RM0440 Table 37. Flash interface - register map and reset values (continued) Offset Register FLASH_ WRP1B_END[6:0] WRP1B_STRT[6:0] WRP1BR 0x30 Reset value X X X X X X X X X X X X X X FLASH_ SEC_SIZE1[7:0] SEC1R...
Page 229
RM0440 Power control (PWR) Power control (PWR) Power supplies The STM32G4 Series devices require a 1.71 V to 3.6 V operating supply voltage (V Analog peripherals are supplied through independent power domain V • = 1.71 V to 3.6 V is the external power supply for the I/Os, the internal regulator and the system analog such as reset, power management and internal clocks.
An embedded linear voltage regulator is used to supply the internal digital power V CORE is the power supply for digital peripherals SRAM1, SRAM2 and CCM SRAM. The CORE Flash is supplied by V and V CORE Figure 12. STM32G4 Series power supply overview domain A/D converter D/A converters REF+ Comparators Operational amplifiers...
Page 231
RM0440 Power control (PWR) ADC and DAC reference voltage To ensure a better accuracy on low-voltage inputs and outputs, the user can connect to a separate reference voltage lower than V is the highest voltage, REF+ REF+ represented by the full scale value, for an analog input (ADC) or output (DAC) signal. can be provided either by an external reference of by an internal buffered voltage REF+ reference (VREFBUF).
Page 232
Power control (PWR) RM0440 RTC functional description on page 1540) • PA0/RTC_TAMP2 and PE6/RTC_TAMP3 when they are configured by the RTC as tamper pins Note: Due to the fact that the analog switch can transfer only a limited amount of current (3 mA), the use of GPIO PC13 to PC15 in output mode is restricted: the speed has to be limited to 2 MHz with a maximum load of 30 pF and these I/Os must not be used as a current source (e.g.
RM0440 Power control (PWR) (MR) supplies full power to the V domain (core, memories and digital peripherals). CORE • In low-power run and low-power sleep modes, the main regulator is off and the low- power regulator (LPR) supplies low power to the V domain, preserving the CORE contents of the registers, SRAM1, SRAM2 and CCM SRAM.
Page 234
Power control (PWR) RM0440 The main regulator provides a typical output voltage at 1.0 V. The system clock frequency can be up to 26 MHz.The Flash access time for a read access is increased as compared to Range 1; write and erase operations are not possible. Voltage scaling is selected through the VOS bit in the Section 6.4.1: Power control register 1 (PWR_CR1)
Page 235
RM0440 Power control (PWR) Set the R1MODE bit is in the PWR_CR5 register. Adjust the number of wait states according new frequency target in Range1 default mode. Configure and switch to new system frequency. Power supply supervisor 6.2.1 Power-on reset (POR) / power-down reset (PDR) / brown-out reset (BOR) The device has an integrated power-on reset (POR) / power-down reset (PDR), coupled with a brown-out reset (BOR) circuitry.
Power control (PWR) RM0440 Figure 13. Brown-out reset waveform BORR4 BORF4 BORR3 BORF3 BORR2 BORF2 BORR1 BORF1 RSTTEMPO Reset with BOR off RSTTEMPO Reset with BOR on BORR4 BORF1 POR/BOR rising thresholds PDR/BOR falling thresholds MSv45389V4 1. The reset temporization t is present only for the BOR lowest threshold (V RSTTEMPO BOR0...
RM0440 Power control (PWR) Figure 14. PVD thresholds V DD 100 mV threshold hysteresis PVD output MS31445V2 6.2.3 Peripheral Voltage Monitoring (PVM) Only V is monitored by default, as it is the only supply required for all system-related functions. The V can be independent from V and can be monitored with two peripheral voltage monitoring (PVM).
Page 238
Power control (PWR) RM0440 Low-power modes By default, the microcontroller is in Run mode after a system or a power Reset. Several low-power modes are available to save power when the CPU does not need to be kept running, for example when waiting for an external event. It is up to the user to select the mode that gives the best compromise between low-power consumption, short startup time and available wakeup sources.
RM0440 Power control (PWR) In addition, the power consumption in Run mode can be reduced by one of the following means: • Slowing down the system clocks • Gating the clocks to the APB and AHB peripherals when they are unused. Figure 15.
Power control (PWR) RM0440 Table 40. Low-power mode summary Voltage Wakeup Wakeup regulators Mode name Entry Effect on clocks source system clock WFI or Return Sleep CPU clock OFF Same as before Any interrupt from ISR entering Sleep (Sleep-now or no effect on other clocks mode Sleep-on-exit)
RM0440 Power control (PWR) Table 41. Functionalities depending on the working mode Stop 0/1 Standby Shutdown Peripheral Sleep VBAT Flash memory SRAM1 SRAM2 CCM SRAM FSMC QUADSPI Backup Registers Brown-out reset (BOR) Programmable Voltage Detector (PVD) Peripheral Voltage Monitor (PVM) Oscillator HSI16 Oscillator HSI48 High Speed External (HSE)
Page 242
Power control (PWR) RM0440 Table 41. Functionalities depending on the working mode (continued) Stop 0/1 Standby Shutdown Peripheral Sleep VBAT SPIx (1,2,3,4) FDCANx (1,2,3) SAI1 ADCx (x=1,2,3,4,5) DACx (x=1,2,3,4) VREFBUF OPAMPx (x=1,2,3,4,5,6) COMPx (x=1,2,3,4,5,6,7) Temperature sensor Timers (TIMx) High resolution timer 1 (HRTIM1) Low-power timer 1 (LPTIM1) Independent watchdog (IWDG) Window watchdog (WWDG)
Page 243
RM0440 Power control (PWR) 5. Some peripherals with wakeup from Stop capability can request HSI16 to be enabled. In this case, HSI16 is woken up by the peripheral, and only feeds the peripheral which requested it. HSI16 is automatically put off when the peripheral does not need it anymore.
Power control (PWR) RM0440 I/O states in Low-power run mode In Low-power run mode, all I/O pins keep the same state as in Run mode. Entering the Low-power run mode To enter the Low-power run mode, proceed as follows: Optional: Jump into the SRAM and power-down the Flash by setting the RUN_PD bit in Flash access control register (FLASH_ACR).
Page 245
RM0440 Power control (PWR) – NVIC IRQ interrupt. ® - When SEVONPEND = 0 in the Cortex -M4 with FPU System Control register. By enabling an interrupt in the peripheral control register and in the NVIC. When the MCU resumes from WFE, the peripheral interrupt pending bit and the NVIC peripheral IRQ channel pending bit (in the NVIC interrupt clear pending register) have to be cleared.
-M4 with FPU System Control register. If WFI or return from ISR was used for entry Interrupt: refer to Table 97: STM32G4 Series vector table If WFE was used for entry and SEVONPEND = 0: Wakeup event: refer to Section 15.3.2: Wakeup event management...
-M4 with FPU System Control register. If WFI or Return from ISR was used for entry Interrupt: refer to Table 97: STM32G4 Series vector table If WFE was used for entry and SEVONPEND = 0: Wakeup event: refer to Section 15.3.2: Wakeup event management...
Page 248
Power control (PWR) RM0440 Refer to Table 45: Stop 0 mode for details on how to enter the Stop 0 mode. If Flash memory programming is ongoing, the Stop 0 mode entry is delayed until the memory access is finished. If an access to the APB domain is ongoing, The Stop 0 mode entry is delayed until the APB access is finished.
Any EXTI Line configured in Interrupt mode (the corresponding EXTI Interrupt vector must be enabled in the NVIC). The interrupt source can be external interrupts or peripherals with wakeup capability. Refer to Table 97: STM32G4 Series vector table. If WFE was used for entry and SEVONPEND = 0: Any EXTI Line configured in event mode.
Any EXTI Line configured in Interrupt mode (the corresponding EXTI Interrupt vector must be enabled in the NVIC). The interrupt source can be external interrupts or peripherals with wakeup capability. Refer to Table 97: STM32G4 Series vector table. If WFE was used for entry and SEVONPEND = 0: Any EXTI Line configured in event mode.
Page 251
RM0440 Power control (PWR) I/O states in Standby mode In the Standby mode, the I/Os can be configured either with a pull-up (refer to PWR_PUCRx registers (x=A,B,C,D,E,F,G)), or with a pull-down (refer to PWR_PDCRx registers (x=A,B,C,D,E,F,G)), or can be kept in analog state. The RTC outputs on PC13 are functional in Standby mode.
Power control (PWR) RM0440 Table 47. Standby mode Standby mode Description WFI (Wait for Interrupt) or WFE (Wait for Event) while: ® – SLEEPDEEP bit is set in Cortex -M4 with FPU System Control register – No interrupt (for WFI) or event (for WFE) is pending –...
Page 253
RM0440 Power control (PWR) 6.3.9 Shutdown mode The Shutdown mode allows to achieve the lowest power consumption. It is based on the deepsleep mode, with the voltage regulator disabled. The V domain is consequently CORE powered off. The PLL, the HSI16, the LSI and the HSE oscillators are also switched off. SRAM1, SRAM2, CCM SRAM and register contents are lost except for registers in the Backup domain.
Power control (PWR) RM0440 Table 48. Shutdown mode Shutdown mode Description WFI (Wait for Interrupt) or WFE (Wait for Event) while: ® – SLEEPDEEP bit is set in Cortex -M4 with FPU System Control register – No interrupt (for WFI) or event (for WFE) is pending –...
Page 255
RM0440 Power control (PWR) PWR registers The peripheral registers can be accessed by half-words (16-bit) or words (32-bit). 6.4.1 Power control register 1 (PWR_CR1) Address offset: 0x00 Reset value: 0x0000 0200. This register is reset after wakeup from Standby mode. Res.
Page 256
Power control (PWR) RM0440 6.4.2 Power control register 2 (PWR_CR2) Address offset: 0x04 Reset value: 0x0000 0000. This register is reset when exiting Standby mode. Res. Res. Res. Res. Res. Res. Res. Res. Res. Res. Res. Res. Res. Res. Res. Res.
Page 257
RM0440 Power control (PWR) Res. Res. Res. Res. Res. Res. Res. Res. Res. Res. Res. Res. Res. Res. Res. Res. UCPD1 UCPD1_ EWUP EWUP EWUP EWUP EWUP EIWUL Res. Res. Res. Res. Res. Res. _DBDIS STDBY Bits 31:16 Reserved, must be kept at reset value. Bit 15 EIWUL: Enable internal wakeup line 0: Internal wakeup line disable.
Page 258
Power control (PWR) RM0440 Bit 2 EWUP3: Enable Wakeup pin WKUP3 When this bit is set, the external wakeup pin WKUP3 is enabled and triggers a wakeup from Standby or Shutdown event when a rising or a falling edge occurs. The active edge is configured via the WP3 bit in the PWR_CR4 register.
RM0440 Power control (PWR) Bit 2 WP3: Wakeup pin WKUP3 polarity This bit defines the polarity used for an event detection on external wake-up pin, WKUP3 0: Detection on high level (rising edge) 1: Detection on low level (falling edge) Bit 1 WP2: Wakeup pin WKUP2 polarity This bit defines the polarity used for an event detection on external wake-up pin, WKUP2 0: Detection on high level (rising edge)
Power control (PWR) RM0440 Bit 2 WUF3: Wakeup flag 3 This bit is set when a wakeup event is detected on wakeup pin, WKUP3. It is cleared by writing ‘1’ in the CWUF3 bit of the PWR_SCR register. Bit 1 WUF2: Wakeup flag 2 This bit is set when a wakeup event is detected on wakeup pin, WKUP2.
RM0440 Power control (PWR) Bit 9 REGLPF: Low-power regulator flag This bit is set by hardware when the MCU is in Low-power run mode. When the MCU exits the Low-power run mode, this bit remains at 1 until the regulator is ready in main mode. A polling on this bit must be done before increasing the product frequency.
Power control (PWR) RM0440 Bit 2 CWUF3: Clear wakeup flag 3 Setting this bit clears the WUF3 flag in the PWR_SR1 register. Bit 1 CWUF2: Clear wakeup flag 2 Setting this bit clears the WUF2 flag in the PWR_SR1 register. Bit 0 CWUF1: Clear wakeup flag 1 Setting this bit clears the WUF1 flag in the PWR_SR1 register.
RM0440 Power control (PWR) Res. Res. Res. Res. Res. Res. Res. Res. Res. Res. Res. Res. Res. Res. Res. Res. Res. PD14 Res. PD12 PD11 PD10 Bits 31:15 Reserved, must be kept at reset value. Bit 14 PD14: Port A pull-down bit 14 When set, this bit activates the pull-down on PA[14] when APC bit is set in PWR_CR3 register.
Power control (PWR) RM0440 Res. Res. Res. Res. Res. Res. Res. Res. Res. Res. Res. Res. Res. Res. Res. Res. PD15 PD14 PD13 PD12 PD11 PD10 Res. Bits 31:16 Reserved, must be kept at reset value. Bits 15:5 PDy: Port B pull-down bit y (y=5..15) When set, this bit activates the pull-down on PB[y] when APC bit is set in PWR_CR3 register.
RM0440 Power control (PWR) Res. Res. Res. Res. Res. Res. Res. Res. Res. Res. Res. Res. Res. Res. Res. Res. PD15 PD14 PD13 PD12 PD11 PD10 Bits 31:16 Reserved, must be kept at reset value. Bits 15:0 PDy: Port C pull-down bit y (y=0..15) When set, this bit activates the pull-down on PC[y] when APC bit is set in PWR_CR3 register.
Power control (PWR) RM0440 Res. Res. Res. Res. Res. Res. Res. Res. Res. Res. Res. Res. Res. Res. Res. Res. PD15 PD14 PD13 PD12 PD11 PD10 Bits 31:16 Reserved, must be kept at reset value. Bits 15:0 PDy: Port D pull-down bit y (y=0..15) When set, this bit activates the pull-down on PD[y] when APC bit is set in PWR_CR3 register.
RM0440 Power control (PWR) Res. Res. Res. Res. Res. Res. Res. Res. Res. Res. Res. Res. Res. Res. Res. Res. PD15 PD14 PD13 PD12 PD11 PD10 Bits 31:16 Reserved, must be kept at reset value. Bits 15:0 PDy: Port E pull-down bit y (y=0..15) When set, this bit activates the pull-down on PE[y] when APC bit is set in PWR_CR3 register.
Power control (PWR) RM0440 Res. Res. Res. Res. Res. Res. Res. Res. Res. Res. Res. Res. Res. Res. Res. Res. PD15 PD14 PD13 PD12 PD11 PD10 Bits 31:16 Reserved, must be kept at reset value. Bits 15:0 PDy: Port F pull-down bit y (y=0..15) When set, this bit activates the pull-down on PF[y] when APC bit is set in PWR_CR3 register.
RM0440 Power control (PWR) Res. Res. Res. Res. Res. Res. Res. Res. Res. Res. Res. Res. Res. Res. Res. Res. Res. Res. Res. Res. Res. PD10 Bits 31:16 Reserved, must be kept at reset value. Bits 15:0 PDy: Port G pull-down bit y (y=0..10) When set, this bit activates the pull-down on PG[y] when APC bit is set in PWR_CR3 register.
Power control (PWR) RM0440 6.4.23 PWR register map and reset value table Table 49. PWR register map and reset values Offset Register LPMS PWR_CR1 [1:0] [2:0] 0x00 Reset value PWR_CR2 PLS[2:0] 0x04 Reset value PWR_CR3 0x08 Reset value PWR_CR4 0x0C Reset value PWR_SR1 0x10...
Page 271
RM0440 Power control (PWR) Table 49. PWR register map and reset values (continued) Offset Register PWR_PDCRD 0x3C Reset value PWR_PUCRE 0x40 Reset value PWR_PDCRE 0x44 Reset value PWR_PUCRF 0x48 Reset value PWR_PDCRF 0x4C Reset value PWR_PUCRG 0x50 Reset value PWR_PDCRG 0x54 Reset value PWR_CR5...
Reset and clock control (RCC) RM0440 Reset and clock control (RCC) Reset There are three types of reset, defined as system reset, power reset and RTC domain reset. 7.1.1 Power reset A power reset is generated when one of the following events occurs: Power-on reset (POR) or Brown-out reset (BOR).
RM0440 Reset and clock control (RCC) significant capacitive load. In case on an internal reset, the internal pull-up RPU is deactivated in order to save the power consumption through the pull-up resistor. This mode is always active (independently of the option bytes setting) during each device power-on-reset (until option bytes are loaded): power on the device or wakeup from Shutdown mode.
Reset and clock control (RCC) RM0440 Entering Standby mode: this type of reset is enabled by resetting nRST_STDBY bit in User option Bytes. In this case, whenever a Standby mode entry sequence is successfully executed, the device is reset instead of entering Standby mode. Entering Stop mode: this type of reset is enabled by resetting nRST_STOP bit in User option bytes.
Page 275
RM0440 Reset and clock control (RCC) All the peripheral clocks are derived from their bus clock (HCLK, PCLK1 or PCLK2) except: • The 48 MHz clock, used for USB device FS, and RNG. This clock is derived (selected by software) from one of the four following sources: –...
Page 276
Reset and clock control (RCC) RM0440 LSI or LSE, or in external clock mode. • The RTC clock which is derived (selected by software) from one of the three following sources: – LSE clock – LSI clock – HSE clock divided by 32 The functionality in Stop mode (including wakeup) is supported only when the clock is LSI or LSE.
Reset and clock control (RCC) RM0440 characteristics” section in your device datasheet. 2. The ADC clock can be derived from the AHB clock of the ADC bus interface, divided by a programmable factor (1, 2 or 4). When the programmable factor is ‘1’, the AHB prescaler must be equal to ‘1’. 7.2.1 HSE clock The high speed external clock signal (HSE) can be generated from two possible clock...
Calibration RC oscillator frequencies can vary from one chip to another due to manufacturing process variations, this is why each device is factory calibrated by ST for 1 % accuracy at T =25°C. After reset, the factory calibration value is loaded in the HSICAL[7:0] bits in the...
Reset and clock control (RCC) RM0440 The HSI16 signal can also be used as a backup source (Auxiliary clock) if the HSE crystal oscillator fails. Refer to Section 7.2.9: Clock security system (CSS) on page 282. 7.2.3 HSI48 clock The HSI48 clock signal is generated from an internal 48 MHz RC oscillator and can be used directly for USB and for random number generator (RNG).
RM0440 Reset and clock control (RCC) The LSE crystal is switched on and off using the LSEON bit in RTC domain control register (RCC_BDCR). The crystal oscillator driving strength can be changed at runtime using the LSEDRV[1:0] bits in the RTC domain control register (RCC_BDCR) to obtain the best compromise between robustness and short start-up time on one side and low-power-...
Reset and clock control (RCC) RM0440 Clock source switching conditions: • Switching from HSE or HSI16 to PLL with AHB frequency (HCLK) higher than 80 MHz • Switching from PLL with HCLK higher than 80 MHz to HSE or HSI16 Transition state: •...
RM0440 Reset and clock control (RCC) LSE and LSI are enabled (LSEON and LSION enabled) and ready (LSERDY and LSIRDY set by hardware), and after the RTC clock has been selected by RTCSEL. The CSS on LSE is working in all modes except VBAT. It is working also under system reset (excluding power on reset).
Page 284
Reset and clock control (RCC) RM0440 7.2.13 Timer clock The timer clock frequencies are automatically defined by hardware. There are two cases: If the APB prescaler equals 1, the timer clock frequencies are set to the same frequency as that of the APB domain. Otherwise, they are set to twice (×2) the frequency of the APB domain.
RM0440 Reset and clock control (RCC) Figure 19. Frequency measurement with TIM15 in capture mode TIM 15 TI1SEL in TIM15_TISEL GPIO MS48963V1 The input capture channel of the Timer 15 can be a GPIO line or an internal clock of the MCU.
Reset and clock control (RCC) RM0440 Figure 21. Frequency measurement with TIM17 in capture mode TIM 17 TI1SEL in TIM17_TISEL GPIO RTC wakeup interrupt HSE/32 MSv45849V1 The input capture channel of the Timer 17 can be a GPIO line or an internal clock of the MCU.
Page 287
RM0440 Reset and clock control (RCC) Calibration of the HSI16 For TIM15 and TIM16, the primary purpose of connecting the LSE to the channel 1 input capture is to be able to precisely measure the HSI16 system clocks (for this, the HSI16 should be used as the system clock source).
Page 288
Reset and clock control (RCC) RM0440 during sleep mode. The AHB to APB bridge clocks are disabled by hardware during Sleep mode when all the clocks of the peripherals connected to them are disabled. • Stop modes (Stop 0 and Stop 1) stops all the clocks in the V domain and disables CORE the PLL, the HSI16, and the HSE oscillators.
Page 289
RM0440 Reset and clock control (RCC) RCC registers 7.4.1 Clock control register (RCC_CR) Address offset: 0x00 Reset value: 0x0000 0063 HSEBYP is not affected by reset. Access: no wait state, word, half-word and byte access Res. Res. Res. Res. Res. Res.
Page 290
Reset and clock control (RCC) RM0440 Bit 16 HSEON: HSE clock enable Set and cleared by software. Cleared by hardware to stop the HSE oscillator when entering Stop, Standby or Shutdown mode. This bit cannot be reset if the HSE oscillator is used directly or indirectly as the system clock.
Page 291
RM0440 Reset and clock control (RCC) Bit 31 Reserved, must be kept at reset value. Bits 30:24 HSITRIM[6:0]: HSI16 clock trimming These bits provide an additional user-programmable trimming value that is added to the HSICAL[7:0] bits. It can be programmed to adjust to variations in voltage and temperature that influence the frequency of the HSI16.
Page 292
Reset and clock control (RCC) RM0440 Bits 27:24 MCOSEL[3:0]: Microcontroller clock output Set and cleared by software. 0000: MCO output disabled, no clock on MCO 0001: SYSCLK system clock selected 0010: Reserved, must be kept at reset value 0011: HSI16 clock selected 0100: HSE clock selected 0101: Main PLL clock selected 0110: LSI clock selected...
Page 293
RM0440 Reset and clock control (RCC) Bits 3:2 SWS[1:0]: System clock switch status Set and cleared by hardware to indicate which clock source is used as system clock. 00: Reserved, must be kept at reset value 01: HSI16 oscillator used as system clock 10: HSE used as system clock 11: PLL used as system clock Bits 1:0 SW[1:0]: System clock switch...
Page 294
Reset and clock control (RCC) RM0440 Bits 26:25 PLLR[1:0]: Main PLL division factor for PLL “R” clock (system clock) Set and cleared by software to control the frequency of the main PLL output clock PLLCLK. This output can be selected as system clock. These bits can be written only if PLL is disabled.
Page 295
RM0440 Reset and clock control (RCC) Bit 16 PLLPEN: Main PLL PLL “P” clock output enable Set and reset by software to enable the PLL “P” clock output of the PLL. In order to save power, when the PLL “P” clock output of the PLL is not used, the value of PLLPEN should be 0.
Page 296
Reset and clock control (RCC) RM0440 7.4.5 Clock interrupt enable register (RCC_CIER) Address offset: 0x18 Reset value: 0x0000 0000 Access: no wait state, word, half-word and byte access Res. Res. Res. Res. Res. Res. Res. Res. Res. Res. Res. Res. Res.
Page 297
RM0440 Reset and clock control (RCC) Bit 2 Reserved, must be kept at reset value. Bit 1 LSERDYIE: LSE ready interrupt enable Set and cleared by software to enable/disable interrupt caused by the LSE oscillator stabilization. 0: LSE ready interrupt disabled 1: LSE ready interrupt enabled Bit 0 LSIRDYIE: LSI ready interrupt enable Set and cleared by software to enable/disable interrupt caused by the LSI oscillator...
Page 298
Reset and clock control (RCC) RM0440 Bit 5 PLLRDYF: PLL ready interrupt flag Set by hardware when the PLL locks and PLLRDYDIE is set. Cleared by software setting the PLLRDYC bit. 0: No clock ready interrupt caused by PLL lock 1: Clock ready interrupt caused by PLL lock Bit 4 HSERDYF: HSE ready interrupt flag Set by hardware when the HSE clock becomes stable and HSERDYDIE is set.
Page 299
RM0440 Reset and clock control (RCC) Bits 31:11 Reserved, must be kept at reset value. Bit 10 HSI48RDYC: HSI48 oscillator ready interrupt clear This bit is set by software to clear the HSI48RDYF flag. 0: No effect 1: Clear the HSI48RDYC flag Bit 9 LSECSSC: LSE Clock security system interrupt clear This bit is set by software to clear the LSECSSF flag.
Page 300
Reset and clock control (RCC) RM0440 Res. Res. Res. Res. Res. Res. Res. Res. Res. Res. Res. Res. Res. Res. Res. Res. FLASH FMAC CORDIC DMAMUX1 DMA2 DMA1 Res. Res. Res. Res. Res. Res. Res. Res. Res. Bits 31:13 Reserved, must be kept at reset value. Bit 12 CRCRST: CRC reset Set and cleared by software.
Page 301
RM0440 Reset and clock control (RCC) 7.4.9 AHB2 peripheral reset register (RCC_AHB2RSTR) Address offset: 0x2C Reset value: 0x0000 0000 Access: no wait state, word, half-word and byte access DAC4 DAC3 DAC2 DAC1 Res. Res. Res. Res. Res. Res. Res. Res. Res.
Page 302
Reset and clock control (RCC) RM0440 Bit 14 ADC345RST: ADC345 reset Set and cleared by software. 0: No effect 1: Reset ADC345 Bit 13 ADC12RST: ADC12 reset Set and cleared by software. 0: No effect 1: Reset ADC12 interface Bits 12:7 Reserved, must be kept at reset value. Bit 6 GPIOGRST: IO port G reset Set and cleared by software.
Page 303
RM0440 Reset and clock control (RCC) 7.4.10 AHB3 peripheral reset register (RCC_AHB3RSTR) Address offset: 0x30 Reset value: 0x0000 0000 Access: no wait state, word, half-word and byte access Res. Res. Res. Res. Res. Res. Res. Res. Res. Res. Res. Res. Res.
Page 304
Reset and clock control (RCC) RM0440 Bit 31 LPTIM1RST: Low Power Timer 1 reset Set and cleared by software. 0: No effect 1: Reset LPTIM1 Bit 30 I2C3RST: I2C3 reset Set and cleared by software. 0: No effect 1: Reset I2C3 interface Bit 29 Reserved, must be kept at reset value.
Page 305
RM0440 Reset and clock control (RCC) Bit 17 USART2RST: USART2 reset Set and cleared by software. 0: No effect 1: Reset USART2 Bit 16 Reserved, must be kept at reset value. Bit 15 SPI3RST: SPI3 reset Set and cleared by software. 0: No effect 1: Reset SPI3 Bit 14 SPI2RST: SPI2 reset...
Page 306
Reset and clock control (RCC) RM0440 7.4.12 APB1 peripheral reset register 2 (RCC_APB1RSTR2) Address offset: 0x3C Reset value: 0x0000 0000 Access: no wait state, word, half-word and byte access Res. Res. Res. Res. Res. Res. Res. Res. Res. Res. Res. Res.
Page 307
RM0440 Reset and clock control (RCC) Bits 31:27 Reserved, must be kept at reset value. Bit 26 HRTIM1RST: HRTIM1 reset Set and cleared by software. 0: No effect 1: Reset HRTIM1 Bits 25:22 Reserved, must be kept at reset value. Bit 21 SAI1RST: Serial audio interface 1 (SAI1) reset Set and cleared by software.
Page 308
Reset and clock control (RCC) RM0440 Bit 11 TIM1RST: TIM1 timer reset Set and cleared by software. 0: No effect 1: Reset TIM1 timer Bits 10:1 Reserved, must be kept at reset value. Bit 0 SYSCFGRST: SYSCFG + COMP + OPAMP + VREFBUF reset 0: No effect 1: Reset SYSCFG + COMP + OPAMP + VREFBUF 7.4.14...
Page 309
RM0440 Reset and clock control (RCC) Bit 2 DMAMUX1EN: DMAMUX1 clock enable Set and reset by software. 0: DMAMUX1 clock disabled 1: DMAMUX1 clock enabled Bit 1 DMA2EN: DMA2 clock enable Set and cleared by software. 0: DMA2 clock disable 1: DMA2 clock enable Bit 0 DMA1EN: DMA1 clock enable Set and cleared by software.
Page 310
Reset and clock control (RCC) RM0440 Bit 18 DAC3EN: DAC3 clock enable Set and cleared by software. 0: DAC3 clock disabled 1: DAC3 clock enabled Bit 17 DAC2EN: DAC2 clock enable Set and cleared by software. 0: DAC2 clock disabled 1: DAC2 clock enabled Bit 16 DAC1EN: DAC1 clock enable Set and cleared by software.
Page 311
RM0440 Reset and clock control (RCC) Bit 2 GPIOCEN: IO port C clock enable Set and cleared by software. 0: IO port C clock disabled 1: IO port C clock enabled Bit 1 GPIOBEN: IO port B clock enable Set and cleared by software. 0: IO port B clock disabled 1: IO port B clock enabled Bit 0 GPIOAEN: IO port A clock enable...
Page 312
Reset and clock control (RCC) RM0440 7.4.17 APB1 peripheral clock enable register 1 (RCC_APB1ENR1) Address: 0x58 Reset value: 0x0000 0400 Access: no wait state, word, half-word and byte access Note: When the peripheral clock is not active, the peripheral registers read or write access is not supported.
Page 313
RM0440 Reset and clock control (RCC) Bit 21 I2C1EN: I2C1 clock enable Set and cleared by software. 0: I2C1 clock disabled 1: I2C1 clock enabled Bit 20 UART5EN: UART5 clock enable Set and cleared by software. 0: UART5 clock disabled 1: UART5 clock enabled Bit 19 UART4EN: UART4 clock enable Set and cleared by software.
Page 314
Reset and clock control (RCC) RM0440 Bit 5 TIM7EN: TIM7 timer clock enable Set and cleared by software. 0: TIM7 clock disabled 1: TIM7 clock enabled Bit 4 TIM6EN: TIM6 timer clock enable Set and cleared by software. 0: TIM6 clock disabled 1: TIM6 clock enabled Bit 3 TIM5EN: TIM5 timer clock enable Set and cleared by software.
Page 315
RM0440 Reset and clock control (RCC) Bits 31:9 Reserved, must be kept at reset value. Bit 8 UCPD1EN: UCPD1 clock enable Set and cleared by software. 0: UCPD1 clock disable 1: UCPD1 clock enable Bits 7:2 Reserved, must be kept at reset value. Bit 1 I2C4EN: I2C4 clock enable Set and cleared by software 0: I2C4 clock disabled...
Page 316
Reset and clock control (RCC) RM0440 7.4.19 APB2 peripheral clock enable register (RCC_APB2ENR) Address: 0x60 Reset value: 0x0000 0000 Access: word, half-word and byte access Note: When the peripheral clock is not active, the peripheral registers read or write access is not supported.
Page 317
RM0440 Reset and clock control (RCC) Bit 15 SPI4EN: SPI4 timer clock enable Set and cleared by software. 0: SPI4 timer clock disabled 1: SPI4 timer clock enabled Bit 14 USART1EN: USART1clock enable Set and cleared by software. 0: USART1clock disabled 1: USART1clock enabled Bit 13 TIM8EN: TIM8 timer clock enable Set and cleared by software.
Page 318
Reset and clock control (RCC) RM0440 Bits 31:13 Reserved, must be kept at reset value. Bit 12 CRCSMEN: CRC clocks enable during Sleep and Stop modes Set and cleared by software. 0: CRC clocks disabled by the clock gating during Sleep and Stop modes 1: CRC clocks enabled by the clock gating during Sleep and Stop modes Bits 11:10 Reserved, must be kept at reset value.
Page 319
RM0440 Reset and clock control (RCC) 7.4.21 AHB2 peripheral clocks enable in Sleep and Stop modes register (RCC_AHB2SMENR) Address offset: 0x6C Reset value: 0x050F 667F Access: no wait state, word, half-word and byte access AESM DAC4 DAC3 DAC2 DAC1 Res. Res.
Page 320
Reset and clock control (RCC) RM0440 Bit 14 ADC345SMEN: ADC345 clock enable Set and cleared by software. 0: ADC345 clock disabled 1: ADC345 clock enabled Bit 13 ADC12SMEN: ADC12 clocks enable during Sleep and Stop modes Set and cleared by software. 0: ADC12 clocks disabled by the clock gating during Sleep and Stop modes 1: ADC12 clocks enabled by the clock gating...
Page 321
RM0440 Reset and clock control (RCC) 1. This register only configures the clock gating, not the clock source itself. Most of the peripherals are clocked by a single clock (AHB or APB clock), which is always disabled in Stop mode. In this case setting the bit has no effect in Stop mode. 7.4.22 AHB3 peripheral clocks enable in Sleep and Stop modes register (RCC_AHB3SMENR)
Page 322
Reset and clock control (RCC) RM0440 Bit 31 LPTIM1SMEN: Low power timer 1 clocks enable during Sleep and Stop modes Set and cleared by software. 0: LPTIM1 clocks disabled by the clock gating during Sleep and Stop modes 1: LPTIM1 clocks enabled by the clock gating during Sleep and Stop modes Bit 30 I2C3SMEN: I2C3 clocks enable during Sleep and Stop modes Set and cleared by software.
Page 323
RM0440 Reset and clock control (RCC) Bit 17 USART2SMEN: USART2 clocks enable during Sleep and Stop modes Set and cleared by software. 0: USART2 clocks disabled by the clock gating during Sleep and Stop modes 1: USART2 clocks enabled by the clock gating during Sleep and Stop modes Bit 16 Reserved, must be kept at reset value.
Page 324
Reset and clock control (RCC) RM0440 Bit 1 TIM3SMEN: TIM3 timer clocks enable during Sleep and Stop modes Set and cleared by software. 0: TIM3 clocks disabled by the clock gating during Sleep and Stop modes 1: TIM3 clocks enabled by the clock gating during Sleep and Stop modes Bit 0 TIM2SMEN: TIM2 timer clocks enable during Sleep and Stop modes Set and cleared by software.
Page 325
RM0440 Reset and clock control (RCC) 7.4.25 APB2 peripheral clocks enable in Sleep and Stop modes register (RCC_APB2SMENR) Address: 0x80 Reset value: 0x0437 F801 Access: word, half-word and byte access HRTIM1 SAI1 TIM20 TIM17 TIM16 TIM15 Res. Res. Res. Res. Res.
Page 326
Reset and clock control (RCC) RM0440 Bit 15 SPI4SMEN: SPI4 timer clocks enable during Sleep and Stop modes Set and cleared by software. 0: SPI4 clocks disabled by the clock gating during Sleep and Stop modes 1: SPI4 clocks enabled by the clock gating during Sleep and Stop mode Bit 14 USART1SMEN: USART1clocks enable during Sleep and Stop modes Set and cleared by software.
Page 327
RM0440 Reset and clock control (RCC) Bits 31:30 ADC345SEL[1:0]: ADC3/4/5 clock source selection These bits are set and cleared by software to select the clock source used by the ADC345 interface. 00: No clock selected 01: PLL “P” clock selected as ADC345 clock 10: System clock selected as ADC3/4/5 clock 11: Reserved.
Page 328
Reset and clock control (RCC) RM0440 Bits 17:16 I2C3SEL[1:0]: I2C3 clock source selection These bits are set and cleared by software to select the I2C3 clock source. 00: PCLK selected as I2C3 clock 01: System clock (SYSCLK) selected as I2C3 clock 10: HSI16 clock selected as I2C3 clock 11: Reserved Bits 15:14 I2C2SEL[1:0]: I2C2 clock source selection...
Page 329
RM0440 Reset and clock control (RCC) Bits 5:4 USART3SEL[1:0]: USART3 clock source selection This bit is set and cleared by software to select the USART3 clock source. 00: PCLK selected as USART3 clock 01: System clock (SYSCLK) selected as USART3 clock 10: HSI16 clock selected as USART3 clock 11: LSE clock selected as USART3 clock Bits 3:2 USART2SEL[1:0]: USART2 clock source selection...
Page 330
Reset and clock control (RCC) RM0440 Bits 31:26 Reserved, must be kept at reset value. Bit 25 LSCOSEL: Low speed clock output selection Set and cleared by software. 0: LSI clock selected 1: LSE clock selected Bit 24 LSCOEN: Low speed clock output enable Set and cleared by software.
Page 331
RM0440 Reset and clock control (RCC) Bits 4:3 LSEDRV[1:0]: LSE oscillator drive capability Set by software to modulate the LSE oscillator’s drive capability. 00: ‘Xtal mode’ lower driving capability 01: ‘Xtal mode’ medium low driving capability 10: ‘Xtal mode’ medium high driving capability 11: ‘Xtal mode’...
Page 332
Reset and clock control (RCC) RM0440 Bit 31 LPWRRSTF: Low-power reset flag Set by hardware when a reset occurs due to illegal Stop, Standby or Shutdown mode entry. Cleared by writing to the RMVF bit. 0: No illegal mode reset occurred 1: Illegal mode reset occurred Bit 30 WWDGRSTF: Window watchdog reset flag Set by hardware when a window watchdog reset occurs.
Page 333
RM0440 Reset and clock control (RCC) Bits 22:2 Reserved, must be kept at reset value. Bit 1 LSIRDY: LSI oscillator ready Set and cleared by hardware to indicate when the LSI oscillator is stable. After the LSION bit is cleared, LSIRDY goes low after 3 LSI oscillator clock cycles. This bit can be set even if LSION = 0 if the LSI is requested by the Clock Security System on LSE, by the Independent Watchdog or by the RTC.
Reset and clock control (RCC) RM0440 7.4.30 Peripherals independent clock configuration register (RCC_CCIPR2) Address: 0x9C Reset value: 0x0000 0000 Access: no wait state, word, half-word and byte access Wait states are inserted in case of successive accesses to this register. QSPISEL Res.
Page 338
Reset and clock control (RCC) RM0440 Table 51. RCC register map and reset values (continued) Offset Register HSI48CAL[8:0] RCC_CRRCR 0x98 X X X X X X X X X Reset value RCC_CCIPR2 0x9C Reset value Refer to Section 2.2 on page 80 for the register boundary addresses.
RM0440 Clock recovery system (CRS) Clock recovery system (CRS) Introduction The clock recovery system (CRS) is an advanced digital controller acting on the internal fine-granularity trimmable RC oscillator HSI48. The CRS provides powerful means for oscillator output frequency evaluation, based on comparison with a selectable synchronization signal.
RM0440 Clock recovery system (CRS) 8.4.3 Frequency error measurement The frequency error counter is a 16-bit down/up counter which is reloaded with the RELOAD value on each SYNC event. It starts counting down till it reaches the zero value, where the ESYNC (expected synchronization) event is generated.
Page 342
Clock recovery system (CRS) RM0440 8.4.4 Frequency error evaluation and automatic trimming The measured frequency error is evaluated by comparing its value with a set of limits: – TOLERANCE LIMIT, given directly in the FELIM field of the CRS_CFGR register –...
RM0440 Clock recovery system (CRS) FELIM value The selection of the FELIM value is closely coupled with the HSI48 oscillator characteristics and its typical trimming step size. The optimal value corresponds to half of the trimming step size, expressed as a number of HSI48 oscillator clock ticks. The following formula can be used: FELIM = (f ) * STEP[%] / 100% / 2...
Page 344
Clock recovery system (CRS) RM0440 CRS registers Refer to Section 1.2 on page 72 for a list of abbreviations used in register descriptions. The peripheral registers can be accessed only by words (32-bit). 8.7.1 CRS control register (CRS_CR) Address offset: 0x00 Reset value: 0x0000 X000(X=4 for products supporting 7-bit TRIM width, otherwise X=2) Res.
Page 345
RM0440 Clock recovery system (CRS) Bit 4 Reserved, must be kept at reset value. Bit 3 ESYNCIE: Expected SYNC interrupt enable 0: Expected SYNC (ESYNCF) interrupt disabled 1: Expected SYNC (ESYNCF) interrupt enabled Bit 2 ERRIE: Synchronization or trimming error interrupt enable 0: Synchronization or trimming error (ERRF) interrupt disabled 1: Synchronization or trimming error (ERRF) interrupt enabled Bit 1 SYNCWARNIE: SYNC warning interrupt enable...
Page 346
Clock recovery system (CRS) RM0440 Bits 26:24 SYNCDIV[2:0]: SYNC divider These bits are set and cleared by software to control the division factor of the SYNC signal. 000: SYNC not divided (default) 001: SYNC divided by 2 010: SYNC divided by 4 011: SYNC divided by 8 100: SYNC divided by 16 101: SYNC divided by 32...
Page 347
RM0440 Clock recovery system (CRS) Bit 9 SYNCMISS: SYNC missed This flag is set by hardware when the frequency error counter reached value FELIM * 128 and no SYNC was detected, meaning either that a SYNC pulse was missed or that the frequency error is too big (internal frequency too high) to be compensated by adjusting the TRIM value, and that some other action has to be taken.
RM0440 Clock recovery system (CRS) 8.7.5 CRS register map Table 55. CRS register map and reset values Offset Register TRIM[5:0] CRS_CR 0x00 Reset value SYNC SYNC CRS_CFGR FELIM[7:0] RELOAD[15:0] 0x04 [1:0] [2:0] Reset value CRS_ISR FECAP[15:0] 0x08 Reset value CRS_ICR 0x0C Reset value Refer to...
Page 350
General-purpose I/Os (GPIO) RM0440 General-purpose I/Os (GPIO) Introduction Each general-purpose I/O port has four 32-bit configuration registers (GPIOx_MODER, GPIOx_OTYPER, GPIOx_OSPEEDR and GPIOx_PUPDR), two 32-bit data registers (GPIOx_IDR and GPIOx_ODR) and a 32-bit set/reset register (GPIOx_BSRR). In addition all GPIOs have a 32-bit locking register (GPIOx_LCKR) and two 32-bit alternate function selection registers (GPIOx_AFRH and GPIOx_AFRL).
RM0440 General-purpose I/Os (GPIO) Figure 25 Figure 26 show the basic structures of a standard and a 5-Volt tolerant I/O port bit, respectively. Table 56 gives the possible port bit configurations. Figure 25. Basic structure of an I/O port bit Analog To on-chip peripheral...
General-purpose I/Os (GPIO) RM0440 Table 56. Port bit configuration table MODE(i) OSPEED(i) PUPD(i) OTYPE(i) I/O configuration [1:0] [1:0] [1:0] GP output GP output PP + PU GP output PP + PD Reserved SPEED [1:0] GP output GP output OD + PU GP output OD + PD Reserved (GP output OD)
Page 353
RM0440 General-purpose I/Os (GPIO) 9.3.1 General-purpose I/O (GPIO) During and just after reset, the alternate functions are not active and most of the I/O ports are configured in analog mode. The debug pins are in AF pull-up/pull-down after reset: • PA15: JTDI in pull-up •...
Page 354
General-purpose I/Os (GPIO) RM0440 – Configure the desired I/O as an alternate function in the GPIOx_MODER register. • Additional functions: – For the ADC, DAC, OPAMP and COMP, configure the desired I/O in analog mode in the GPIOx_MODER register and configure the required function in the ADC, DAC, OPAMP, and COMP registers.
Page 355
RM0440 General-purpose I/Os (GPIO) There is no need for the software to disable interrupts when programming the GPIOx_ODR at bit level: it is possible to modify one or more bits in a single atomic AHB write access. 9.3.6 GPIO locking mechanism It is possible to freeze the GPIO control registers by applying a specific write sequence to the GPIOx_LCKR register.
General-purpose I/Os (GPIO) RM0440 9.3.9 Input configuration When the I/O port is programmed as input: • The output buffer is disabled • The Schmitt trigger input is activated • The pull-up and pull-down resistors are activated depending on the value in the GPIOx_PUPDR register •...
General-purpose I/Os (GPIO) RM0440 9.3.12 Analog configuration When the I/O port is programmed as analog configuration: • The output buffer is disabled • The Schmitt trigger input is deactivated, providing zero consumption for every analog value of the I/O pin. The output of the Schmitt trigger is forced to a constant value (0). •...
Page 359
RM0440 General-purpose I/Os (GPIO) 9.3.15 Using PB8 as GPIO PB8 may be used as boot pin (BOOT0) or as a GPIO. Depending on the nSWBOOT0 bit in the user option byte, it switches from the input mode to the analog input mode: •...
Page 360
General-purpose I/Os (GPIO) RM0440 GPIO registers This section gives a detailed description of the GPIO registers. For a summary of register bits, register address offsets and reset values, refer to Table The peripheral registers can be written in word, half word or byte mode. 9.4.1 GPIO port mode register (GPIOx_MODER) (x =A to G)
Page 361
RM0440 General-purpose I/Os (GPIO) Bits 31:16 Reserved, must be kept at reset value. Bits 15:0 OT[15:0]: Port x configuration I/O pin y (y = 15 to 0) These bits are written by software to configure the I/O output type. 0: Output push-pull (reset state) 1: Output open-drain 9.4.3 GPIO port output speed register (GPIOx_OSPEEDR)
Page 362
General-purpose I/Os (GPIO) RM0440 Bits 31:0 PUPD[15:0][1:0]: Port x configuration I/O pin y (y = 15 to 0) These bits are written by software to configure the I/O pull-up or pull-down 00: No pull-up, pull-down 01: Pull-up 10: Pull-down 11: Reserved 9.4.5 GPIO port input data register (GPIOx_IDR) (x = A to G)
Page 363
RM0440 General-purpose I/Os (GPIO) Reset value: 0x0000 0000 BR15 BR14 BR13 BR12 BR11 BR10 BS15 BS14 BS13 BS12 BS11 BS10 Bits 31:16 BR[15:0]: Port x reset I/O pin y (y = 15 to 0) These bits are write-only. A read to these bits returns the value 0x0000. 0: No action on the corresponding ODx bit 1: Resets the corresponding ODx bit Note: If both BSx and BRx are set, BSx has priority.
Page 364
General-purpose I/Os (GPIO) RM0440 Bits 31:17 Reserved, must be kept at reset value. Bit 16 LCKK: Lock key This bit can be read any time. It can only be modified using the lock key write sequence. 0: Port configuration lock key not active 1: Port configuration lock key active.
Page 365
RM0440 General-purpose I/Os (GPIO) Bits 31:0 AFSEL[7:0][3:0]: Alternate function selection for port x I/O pin y (y = 7 to 0) These bits are written by software to configure alternate function I/Os. 0000: AF0 0001: AF1 0010: AF2 0011: AF3 0100: AF4 0101: AF5 0110: AF6...
Page 366
General-purpose I/Os (GPIO) RM0440 Bits 31:0 AFSEL[15:8][3:0]: Alternate function selection for port x I/O pin y (y = 15 to 8) These bits are written by software to configure alternate function I/Os. 0000: AF0 0001: AF1 0010: AF2 0011: AF3 0100: AF4 0101: AF5 0110: AF6...
RM0440 General-purpose I/Os (GPIO) 9.4.12 GPIO register map The following table gives the GPIO register map and reset values. Table 57. GPIO register map and reset values Offset Register name GPIOA_MODER 0x00 Reset value 1 1 1 1 1 1 1 1 1 1 1 1 GPIOB_MODER 0x00 Reset value...
Page 368
General-purpose I/Os (GPIO) RM0440 Table 57. GPIO register map and reset values (continued) Offset Register name GPIOx_ODR (where x = A to G) 0x14 Reset value 0 0 0 0 0 0 0 0 0 0 0 0 GPIOx_BSRR (where x = A to G) 0x18 Reset value 0 0 0 0...
Page 369
RM0440 System configuration controller (SYSCFG) System configuration controller (SYSCFG) 10.1 SYSCFG main features The STM32G4 Series devices feature a set of configuration registers. The main purposes of the system configuration controller are the following: • Remapping memory areas • Managing the external interrupt line connection to the GPIOs •...
Page 370
System configuration controller (SYSCFG) RM0440 Bits 2:0 MEM_MODE: Memory mapping selection These bits control the memory internal mapping at address 0x0000 0000. These bits are used to select the physical remap by software and so, bypass the BOOT pin and the option bit setting.
Page 371
RM0440 System configuration controller (SYSCFG) Bit 22 I2C3_FMP: I2C3 Fast-mode Plus driving capability activation This bit enables the Fm+ driving mode on I2C3 pins selected through AF selection bits. 0: Fm+ mode is not enabled on I2C3 pins selected through AF selection bits 1: Fm+ mode is enabled on I2C3 pins selected through AF selection bits.
System configuration controller (SYSCFG) RM0440 Table 58. BOOSTEN and ANASWVDD set/reset VDDA BOOSTEN ANASWVDD > 2.4 V > 2.4 V < 2.4 V < 2.4 V < 2.4 V 10.2.3 SYSCFG external interrupt configuration register 1 (SYSCFG_EXTICR1) Address offset: 0x08 Reset value: 0x0000 0000 EXTI3[3:0] EXTI2[3:0]...
Page 373
RM0440 System configuration controller (SYSCFG) Bits 7:4 EXTI1[3:0]: EXTI 1 configuration bits These bits are written by software to select the source input for the EXTI1 external interrupt. 0000: PA[1] pin 0001: PB[1] pin 0010: PC[1] pin 0011: PD[1] pin 0100: PE[1] pin 0101: PF[1] pin 0110: PG[1] pin...
Page 374
System configuration controller (SYSCFG) RM0440 Bits 11:8 EXTI6[3:0]: EXTI 6 configuration bits These bits are written by software to select the source input for the EXTI6 external interrupt. 0000: PA[6] pin 0001: PB[6] pin 0010: PC[6] pin 0011: PD[6] pin 0100: PE[6] pin 0101: PF[6] pin 0110: PG[6] pin...
Page 375
RM0440 System configuration controller (SYSCFG) Bits 15:12 EXTI11[3:0]: EXTI 11 configuration bits These bits are written by software to select the source input for the EXTI11 external interrupt. 0000: PA[11] pin 0001: PB[11] pin 0010: PC[11] pin 0011: PD[11] pin 0100: PE[11] pin 0101: PF[11] pin Bits 11:8 EXTI10[3:0]: EXTI 10 configuration bits...
Page 376
System configuration controller (SYSCFG) RM0440 10.2.6 SYSCFG external interrupt configuration register 4 (SYSCFG_EXTICR4) Address offset: 0x14 Reset value: 0x0000 0000 EXTI15[3:0] EXTI14[3:0] EXTI13[3:0] EXTI12[3:0] Bits 31:16 Reserved, must be kept at reset value. Bits 15:12 EXTI15[3:0]: EXTI 15 configuration bits These bits are written by software to select the source input for the EXTI15 external interrupt.
Page 377
RM0440 System configuration controller (SYSCFG) Note: Some of the I/O pins mentioned in the above register may not be available on small packages. 10.2.7 SYSCFG CCM SRAM control and status register (SYSCFG_SCSR) Address offset: 0x18 System reset value: 0x0000 0000 Bits 31:2 Reserved, must be kept at reset value Bit 1 CCMBSY: CCM SRAM busy by erase operation 0: No CCM SRAM erase operation is on going.
Page 378
System configuration controller (SYSCFG) RM0440 10.2.8 SYSCFG configuration register 2 (SYSCFG_CFGR2) Address offset: 0x1C System reset value: 0x0000 0000 ECCL PVDL rc_w1 Bits 31:9 Reserved, must be kept at reset value Bit 8 SPF: SRAM1 and CCM SRAM parity error flag This bit is set by hardware when an SRAM1 or CCM SRAM parity error is detected.
Page 379
RM0440 System configuration controller (SYSCFG) ® Bit 0 CLL: Cortex -M4 LOCKUP (Hardfault) output enable bit This bit is set by software and cleared only by a system reset. It can be used to ® enable and lock the connection of Cortex -M4 with FPU LOCKUP (Hardfault) output to TIM1/8/15/16/17/20 break input and hrtim_sys_flt input of HRTIM1.
System configuration controller (SYSCFG) RM0440 10.2.11 SYSCFG register map The following table gives the SYSCFG register map and the reset values. Table 59. SYSCFG register map and reset values Offset Register SYSCFG_ MEM_ MODE MEMRMP 0x00 Reset value SYSCFG_CFGR1 FPU_IE[5..0] 0x04 Reset value EXTI3...
Page 381
RM0440 Peripherals interconnect matrix Peripherals interconnect matrix 11.1 Introduction Several peripherals have direct connections between them. This allows autonomous communication and or synchronization between peripherals, saving CPU resources thus power supply consumption. In addition, these hardware connections remove software latency and allow design of predictable system.
RM0440 Peripherals interconnect matrix The burst mode controller counter can be clocked by general purpose timers as well as shown in the Table Table 62. Interconnect 12 HRTIM Burst mode trigger event/ clock signal HRTIM Burst mode trigger event/ clock signal assignment hrtim_bm_trg tim7_trgo...
Page 386
Peripherals interconnect matrix RM0440 Triggering signals The output (from Master) is on signal TIMx_TRGO (and TIMx_TRGO2 for TIM1/TIM8/TIM20) following a configurable timer event. The input (to slave) is on signals TIMx_ITRx The input and output signals for TIM1/TIM8/TIM20 are shown in Figure 269: Advanced- control timer block diagram.
Page 388
Peripherals interconnect matrix RM0440 11.3.3 From ADC (ADCx) to timer (TIMx, HRTIM) See please Table 73: Interconnect 2 Table 81.: Interconnect 10 ADCs Analog watchdogs are connected to TIM1/8/20 for digital power applications (cycle- bycycle current regulation with ADC). A description of the ADC analog watchdog setting is provided in: Section 21.4.28: Analog window watchdog (AWD1EN, JAWD1EN, AWD1SGL, AWD1CH, AWD2CH, AWD3CH, AWD_HTx, AWD_LTx,...
RM0440 Peripherals interconnect matrix The timer break input features two channels: • A break channel which gathers both application fault (from input pins and built-in comparators) and system-level fault (clock failure, parity error, ...). • A break2 channel which only includes application faults (from input pins and built-in comparators).
RM0440 Peripherals interconnect matrix 11.3.10 From system errors to timers (TIMx) and HRTIM TIMx (TIM1/TIM8/TIM20/TIM15/TIM16/TIM17) break inputs and HRTIM system fault input gather MCU internal fault events coming from: • the clock failure event generated by the clock security system (CSS), •...
Page 402
Direct memory access controller (DMA) RM0440 Direct memory access controller (DMA) 12.1 Introduction The direct memory access (DMA) controller is a bus master and system peripheral. The DMA is used to perform programmable data transfers between memory-mapped peripherals and/or memories, upon the control of an off-loaded CPU. The DMA controller features a single AHB master architecture.
Category 2 devices Number of channels Category 3 devices Category 4 devices 1. See Table 1: STM32G4 Series memory density. 12.3.2 DMA request mapping The DMA controller is connected to DMA requests from the AHB/APB peripherals through the DMAMUX peripheral.
RM0440 Direct memory access controller (DMA) may stop the CPU access to the system bus for a number of bus cycles, when CPU and DMA target the same destination (memory or peripheral). According to its configuration through the AHB slave interface, the DMA controller arbitrates between the DMA channels and their associated received requests.
Page 406
Direct memory access controller (DMA) RM0440 peripheral or memory, and is programmed in the DMA_CPARx or DMA_CMARx register. – a single data write (byte, half-word or word) to the peripheral data register or a location in the memory, addressed through an internal current peripheral/memory address register.
Page 407
RM0440 Direct memory access controller (DMA) Programmable data sizes The transfer sizes of a single data (byte, half-word, or word) to the peripheral and memory are programmable through, respectively, the PSIZE[1:0] and MSIZE[1:0] fields of the DMA_CCRx register. Pointer incrementation The peripheral and memory pointers may be automatically incremented after each transfer, depending on the PINC and MINC bits of the DMA_CCRx register.
Page 408
Direct memory access controller (DMA) RM0440 Note: The two last steps of the channel configuration procedure may be merged into a single access to the DMA_CCRx register, to configure and enable the channel. Channel state and disabling a channel A channel x in active state is an enabled channel (read DMA_CCRx.EN = 1). An active channel x is a channel that must have been enabled by the software (DMA_CCRx.EN set to 1) and afterwards with no occurred transfer error (DMA_ISR.TEIFx = 0).
Page 409
RM0440 Direct memory access controller (DMA) automatically reloaded with the initial value programmed during the channel configuration phase, and the DMA requests continue to be served. In order to stop a circular transfer, the software needs to stop the peripheral from generating DMA requests (such as quit the ADC scan mode), before disabling the DMA channel.
Page 410
Direct memory access controller (DMA) RM0440 Regardless of their usual naming, these ‘memory’ register, field and bit are used to define the destination peripheral in peripheral-to-peripheral mode. 410/2126 RM0440 Rev 4...
RM0440 Direct memory access controller (DMA) 12.4.6 DMA data width, alignment and endianness When PSIZE[1:0] and MSIZE[1:0] are not equal, the DMA controller performs some data alignments as described in the table below. Table 87. Programmable data width and endian behavior (when PINC = MINC = 1) Source Destinat Destination...
Page 412
Direct memory access controller (DMA) RM0440 Addressing AHB peripherals not supporting byte/half-word write transfers When the DMA controller initiates an AHB byte or half-word write transfer, the data are duplicated on the unused lanes of the AHB master 32-bit data bus (HWDATA[31:0]). When the AHB slave peripheral does not support byte or half-word write transfers and does not generate any error, the DMA controller writes the 32 HWDATA bits as shown in the two examples below:...
RM0440 Direct memory access controller (DMA) 12.5 DMA interrupts An interrupt can be generated on a half transfer, transfer complete or transfer error for each DMA channel x. Separate interrupt enable bits are available for flexibility. Table 88. DMA interrupt requests Interrupt Interrupt request Interrupt event...
Page 414
Direct memory access controller (DMA) RM0440 Bit 27 TEIF7: transfer error (TE) flag for channel 7 0: no TE event 1: a TE event occurred Bit 26 HTIF7: half transfer (HT) flag for channel 7 0: no HT event 1: a HT event occurred Bit 25 TCIF7: transfer complete (TC) flag for channel 7 0: no TC event 1: a TC event occurred...
Page 415
RM0440 Direct memory access controller (DMA) Bit 12 GIF4: global interrupt flag for channel 4 0: no TE, HT or TC event 1: a TE, HT or TC event occurred Bit 11 TEIF3: transfer error (TE) flag for channel 3 0: no TE event 1: a TE event occurred Bit 10 HTIF3: half transfer (HT) flag for channel 3...
Page 416
Direct memory access controller (DMA) RM0440 12.6.2 DMA interrupt flag clear register (DMA_IFCR) Address offset: 0x04 Reset value: 0x0000 0000 Setting the global clear bit CGIFx of the channel x in this DMA_IFCR register, causes the DMA hardware to clear the corresponding GIFx bit and any individual flag among TEIFx, HTIFx, TCIFx, in the DMA_ISR register.
Page 417
RM0440 Direct memory access controller (DMA) Bit 11 CTEIF3: transfer error flag clear for channel 3 Bit 10 CHTIF3: half transfer flag clear for channel 3 Bit 9 CTCIF3: transfer complete flag clear for channel 3 Bit 8 CGIF3: global interrupt flag clear for channel 3 Bit 7 CTEIF2: transfer error flag clear for channel 2 Bit 6 CHTIF2: half transfer flag clear for channel 2 Bit 5 CTCIF2: transfer complete flag clear for channel 2...
Page 418
Direct memory access controller (DMA) RM0440 Bits 11:10 MSIZE[1:0]: memory size Defines the data size of each DMA transfer to the identified memory. In memory-to-memory mode, this field identifies the memory source if DIR = 1 and the memory destination if DIR = 0. In peripheral-to-peripheral mode, this field identifies the peripheral source if DIR = 1 and the peripheral destination if DIR = 0.
Page 419
RM0440 Direct memory access controller (DMA) Bit 5 CIRC: circular mode 0: disabled 1: enabled Note: this bit is set and cleared by software. It must not be written when the channel is enabled (EN = 1). It is not read-only when the channel is enabled (EN = 1). Bit 4 DIR: data transfer direction This bit must be set only in memory-to-peripheral and peripheral-to-memory modes.
Page 420
Direct memory access controller (DMA) RM0440 12.6.4 DMA channel x number of data to transfer register (DMA_CNDTRx) Address offset: 0x0C + 0x14 * (x - 1), (x = 1 to 8) Reset value: 0x0000 0000 Res. Res. Res. Res. Res. Res.
RM0440 Direct memory access controller (DMA) Bits 31:0 PA[31:0]: peripheral address It contains the base address of the peripheral data register from/to which the data will be read/written. When PSIZE[1:0] = 01 (16 bits), bit 0 of PA[31:0] is ignored. Access is automatically aligned to a half-word address.
Page 422
Direct memory access controller (DMA) RM0440 Table 89. DMA register map and reset values (continued) Offset Register DMA_IFCR 0x004 Reset value DMA_CCR1 0x008 Reset value DMA_CNDTR1 NDTR[15:0] 0x00C Reset value DMA_CPAR1 PA[31:0] 0x010 Reset value DMA_CMAR1 MA[31:0] 0x014 Reset value 0x018 Reserved Reserved.
Page 423
RM0440 Direct memory access controller (DMA) Table 89. DMA register map and reset values (continued) Offset Register DMA_CCR5 0x058 Reset value DMA_CNDTR5 NDTR[15:0] 0x05C Reset value DMA_CPAR5 PA[31:0] 0x060 Reset value DMA_CMAR5 MA[31:0] 0x064 Reset value 0x068 Reserved Reserved. DMA_CCR6 0x06C Reset value DMA_CNDTR6...
Page 424
DMA request multiplexer (DMAMUX) RM0440 DMA request multiplexer (DMAMUX) 13.1 Introduction A peripheral indicates a request for DMA transfer by setting its DMA request signal. The DMA request is pending until it is served by the DMA controller that generates a DMA acknowledge signal, and the corresponding DMA request signal is deasserted.
Number of DMAMUX output request channels Category 3 devices Category 4 devices Number of DMAMUX request generator channels Number of DMAMUX request trigger inputs Number of DMAMUX synchronization inputs Number of DMAMUX peripheral request inputs Table 1: STM32G4 Series memory density RM0440 Rev 4 425/2126...
DMA request multiplexer (DMAMUX) RM0440 13.3.2 DMAMUX mapping The mapping of resources to DMAMUX is hardwired. DMAMUX is used with DMA1 and DMA2: For category 3 and category 4 devices: • DMAMUX channels 0 to 7 are connected to DMA1 channels 0 to 7 •...
Page 431
RM0440 DMA request multiplexer (DMAMUX) Caution: A same non-null DMAREQ_ID can be assigned to two different channels only if the application ensures that these channels are not requested to be served at the same time. In other words, if two different channels receive a same asserted hardware request at the same time, an unpredictable DMA hardware behavior occurs.
DMA request multiplexer (DMAMUX) RM0440 Figure 33. Synchronization mode of the DMAMUX request line multiplexer channel Selected DMA request line transferred to the output DMA requests served DMA request pending Selected dmamux_reqx Not pending dmamux_syncx dmamux_req_outx DMA request counter dmamux_evtx DMA request counter underrun Synchronization event DMA request counter auto-reload to NBREQ...
Page 433
RM0440 DMA request multiplexer (DMAMUX) Note: If EGE is enabled and NBREQ = 0, an event is generated after each served DMA request. Note: A synchronization event (edge) is detected if the state following the edge remains stable for more than two AHB clock cycles. Upon writing into DMAMUX_CxCR register, the synchronization events are masked during three AHB clock cycles.
DMA request multiplexer (DMAMUX) RM0440 Note: The GNBREQ field value must be written by software only when the enable GE bit of the corresponding generator channel x is disabled. A trigger event (edge) is detected if the state following the edge remains stable for more than two AHB clock cycles.
Page 435
RM0440 DMA request multiplexer (DMAMUX) 13.6 DMAMUX registers Refer to the table containing register boundary addresses for the DMAMUX base address. DMAMUX registers may be accessed per (8-bit) byte, (16-bit) half-word, or (32-bit) word. The address must be aligned with the data size. 13.6.1 DMAMUX request line multiplexer channel x configuration register (DMAMUX_CxCR)
Page 436
DMA request multiplexer (DMAMUX) RM0440 Bit 7 Reserved, must be kept at reset value. Bits 6:0 DMAREQ_ID[6:0]: DMA request identification Selects the input DMA request. See the DMAMUX table about assignments of multiplexer inputs to resources. 13.6.2 DMAMUX request line multiplexer interrupt channel status register (DMAMUX_CSR) Address offset: 0x080 Reset value: 0x0000 0000...
RM0440 DMA request multiplexer (DMAMUX) 13.6.7 DMAMUX register map The following table summarizes the DMAMUX registers and reset values. Refer to the register boundary address table for the DMAMUX register base address. Table 96. DMAMUX register map and reset values Offset Register DMAREQ_ID[6:0]...
Nested vectored interrupt controller (NVIC) RM0440 14.3 Interrupt and exception vectors The gray rows in Table 97 describe the vectors without specific position. Table 97. STM32G4 Series vector table Type of Acronym Description Address priority Reserved 0x0000 0000 fixed Reset...
Page 444
Nested vectored interrupt controller (NVIC) RM0440 Table 97. STM32G4 Series vector table (continued) Type of Acronym Description Address priority TIM8_TRG_COM/TIM8 TIM8 trigger and commutation interrupt/TIM8 settable 0x0000 00F4 _DIR/TIM8_IDX Direction Change interrupt/TIM8 Index settable TIM1_CC TIM8 capture compare interrupt 0x0000 00F8...
Page 445
RM0440 Nested vectored interrupt controller (NVIC) Table 97. STM32G4 Series vector table (continued) Type of Acronym Description Address priority settable HRTIM_TIMF_IRQn hrtim_it7 / HRTIM timer F interrupt 0x0000 0168 settable CRS CRS interrupt 0x0000 016C settable SAI 0x0000 0170 TIM20_BRK/...
Page 446
Extended interrupts and events controller (EXTI) RM0440 Extended interrupts and events controller (EXTI) 15.1 Introduction The EXTI main features are as follows: • Generation of up to 42 event/interrupt requests – 28 configurable lines – 14 direct lines • Independent mask on each event/interrupt line •...
MS33393V1 15.3.2 Wakeup event management The STM32G4 Series is able to handle external or internal events in order to wake up the core (WFE). The wakeup event can be generated either by: • enabling an interrupt in the peripheral control register but not in the NVIC, and enabling the SEVONPEND bit in the Cortex -M4 System Control register.
Page 448
Configure the corresponding mask bit (EXTI_IMR, EXTI_EMR). Set the required bit of the software interrupt register (EXTI_SWIER). 15.4 EXTI interrupt/event line mapping In the STM32G4 Series, 42 interrupt/event lines are available. The GPIOs are connected to 16 configurable interrupt/event lines (see Figure 36).
RM0440 Extended interrupts and events controller (EXTI) Figure 36. External interrupt/event GPIO mapping EXTI0[3:0] bits in the SYSCFG_EXTICR1 register EXTI0 EXTI1[3:0] bits in the SYSCFG_EXTICR1 register EXTI1 EXTI15[3:0] bits in the SYSCFG_EXTICR4 register PA15 PB15 PC15 EXTI15 PD15 PE15 PF15 MSv48953V1 The EXTI lines are connected as shown in Table 98: EXTI lines...
Page 450
Extended interrupts and events controller (EXTI) RM0440 Table 98. EXTI lines connections (continued) EXTI line Line source Line type COMP1 output configurable COMP2 output configurable I2C1 wakeup direct I2C2 wakeup direct USART1 wakeup direct USART2 wakeup direct I2C3 wakeup direct USART3 wakeup direct COMP3 output...
Page 451
RM0440 Extended interrupts and events controller (EXTI) 15.5 registers EXTI Refer to Section 1.2 on page 72 for a list of abbreviations used in register descriptions. The peripheral registers have to be accessed by words (32-bit). 15.5.1 Interrupt mask register 1 (EXTI_IMR1) Address offset: 0x00 Reset value: Direct lines are set to '1', others lines are set to '0'.
Page 453
RM0440 Extended interrupts and events controller (EXTI) Bits 31:29 FTx: Falling trigger event configuration bit of line x (x = 31 to 29) 0: Falling trigger disabled (for Event and Interrupt) for input line 1: Falling trigger enabled (for Event and Interrupt) for input line Bits 28:23 Reserved, must be kept at reset value.
Page 454
Extended interrupts and events controller (EXTI) RM0440 Bits 22: 19 SWIx: Software interrupt on line x (x = 22 o 19) If the interrupt is enabled on this line in the EXTI_IMR, writing a '1' to this bit when it is at '0' sets the corresponding pending bit in EXTI_PR resulting in an interrupt request generation.
Page 456
Extended interrupts and events controller (EXTI) RM0440 Bits 31:12 Reserved, must be kept at reset value Bits 11:8 IMx: Interrupt mask on line x (x = 43 to 40) 0: Interrupt request from line x is masked 1: Interrupt request from line x is not masked Bits 7:6 Reserved, must be kept at reset value Bits 5:0 IMx: Interrupt mask on line x (x = 37 to 32) 0: Interrupt request from line x is masked...
Page 457
RM0440 Extended interrupts and events controller (EXTI) Bits 31:10 Reserved, must be kept at reset value. Bits 9:8 RTx: Rising trigger event configuration bit of line x (x = 40 to 41) 0: Rising trigger disabled (for Event and Interrupt) for input line 1: Rising trigger enabled (for Event and Interrupt) for input line Bits 7:2 Reserved, must be kept at reset value.
Page 459
RM0440 Extended interrupts and events controller (EXTI) Bits 31:10 Reserved, must be kept at reset value. Bits 9:8 SWIx: Software interrupt on line x (x = 40 to 41) If the interrupt is enabled on this line in EXTI_IMR, writing a '1' to this bit when it is at '0' sets the corresponding pending bit of EXTI_PR resulting in an interrupt request generation.
Extended interrupts and events controller (EXTI) RM0440 15.5.13 EXTI register map Table 99 gives the EXTI register map and the reset values. Table 99. Extended interrupt/event controller register map and reset values Offset Register EXTI_IMR1 0x00 Reset value EXTI_EMR1 0x04 Reset value EXTI_RTSR1 0x08...
Page 461
RM0440 Cyclic redundancy check calculation unit (CRC) Cyclic redundancy check calculation unit (CRC) 16.1 Introduction The CRC (cyclic redundancy check) calculation unit is used to get a CRC code from 8-, 16- or 32-bit data word and a generator polynomial. Among other applications, CRC-based techniques are used to verify data transmission or storage integrity.
Cyclic redundancy check calculation unit (CRC) RM0440 16.3 CRC functional description 16.3.1 CRC block diagram Figure 37. CRC calculation unit block diagram 32-bit AHB bus 32-bit (read access) Data register (output) crc_hclk CRC computation 32-bit (write access) Data register (input) MS19882V2 16.3.2 CRC internal signals...
Page 463
RM0440 Cyclic redundancy check calculation unit (CRC) The input data can be reversed, to manage the various endianness schemes. The reversing operation can be performed on 8 bits, 16 bits and 32 bits depending on the REV_IN[1:0] bits in the CRC_CR register. For example: input data 0x1A2B3C4D is used for CRC calculation as: •...
Page 464
Cyclic redundancy check calculation unit (CRC) RM0440 16.4 CRC registers 16.4.1 CRC data register (CRC_DR) Address offset: 0x00 Reset value: 0xFFFF FFFF DR[31:16] DR[15:0] Bits 31:0 DR[31:0]: Data register bits This register is used to write new data to the CRC calculator. It holds the previous CRC calculation result when it is read.
Cyclic redundancy check calculation unit (CRC) RM0440 Bits 31:0 CRC_INIT[31:0]: Programmable initial CRC value This register is used to write the CRC initial value. 16.4.5 CRC polynomial (CRC_POL) Address offset: 0x14 Reset value: 0x04C1 1DB7 POL[31:16] POL[15:0] Bits 31:0 POL[31:0]: Programmable polynomial This register is used to write the coefficients of the polynomial to be used for CRC calculation.
Page 467
RM0440 CORDIC co-processor (CORDIC) CORDIC co-processor (CORDIC) 17.1 CORDIC introduction The CORDIC co-processor provides hardware acceleration of certain mathematical functions (mainly trigonometric ones) commonly used in motor control, metering, signal processing and many other applications. It speeds up the calculation of these functions compared to a software implementation, making it possible the use of a lower operating frequency, or freeing up processor cycles in order to perform other tasks.
RM0440 CORDIC co-processor (CORDIC) Table 103. Cosine parameters (continued) Parameter Description Range RES2 m ∙ sin θ [-1, 1] SCALE Not applicable This function calculates the cosine of an angle in the range -π to π. It can also be used to perform polar to rectangular conversion.
CORDIC co-processor (CORDIC) RM0440 Table 105. Phase parameters (continued) Parameter Description Range RES2 Modulus m [0, 1] SCALE Not applicable This function calculates the phase angle in the range -π to π of a vector v = [x y] (also known as atan2(y,x).
RM0440 CORDIC co-processor (CORDIC) Arctangent Table 107. Arctangent parameters Parameter Description Range – ARG1 [-1, 1] ⋅ ARG2 Not applicable RES1 ∙ tan x, in radians, divided by p [-1, 1] RES2 Not applicable SCALE [0 7] This function calculates the arctangent, or inverse tangent, of the input argument x. The primary argument, ARG1, is the input value, x = tan θ.
CORDIC co-processor (CORDIC) RM0440 The primary result, RES1, is the hyperbolic cosine, cosh x. RES1 must be multiplied by 2 to obtain the correct result. The secondary result, RES2, is the hyperbolic sine, sinh x. RES2 must be multiplied by 2 to obtain the correct result.
RM0440 CORDIC co-processor (CORDIC) x ∙ 0.5 is programmed in ARG1 and the factor n = 1 must be programmed in the SCALE parameter. The secondary argument is not used. The primary result is the hyperbolic arctangent, atanh x. RES1 must be multiplied by 2 to obtain the correct value.
CORDIC co-processor (CORDIC) RM0440 Square root Table 113. Square root parameters Parameter Description Range ARG1 x ∙ 2 [0.027 0.875] ARG2 Not applicable ··· – RES1 [0.04 1] RES2 Not applicable SCALE [0 2] This function calculates the square root of the input argument x. The primary argument is the input value x.
RM0440 CORDIC co-processor (CORDIC) required, it has to be calculated in software and programmed into the SCALE field of the CORDIC_CSR register. The input arguments must be scaled accordingly before programming the scaled values in the CORDIC_WDATA register. The scaling must also be undone on the results read from the CORDIC_RDATA register.
RM0440 CORDIC co-processor (CORDIC) Figure 40. CORDIC convergence for square root Note: The convergence rate decreases as the quantization error starts to become significant. The CORDIC can perform four iterations per clock cycle. For each function, the maximum error remaining after every four iterations is shown in Table 115, together with the number of clock cycles required to reach that precision.
Page 478
CORDIC co-processor (CORDIC) RM0440 Table 115. Precision vs. number of iterations (continued) Max residual error Number of Number of Function iterations cycles q1.31 format q1.15 format Sinh, Cosh, Atanh, Ln Sqrt 1. Max residual error is the maximum error remaining after the given number of iterations, compared to the identical calculation performed in double precision floating point.
Page 479
RM0440 CORDIC co-processor (CORDIC) Once the calculation has started, any attempt to read the CORDIC_RDATA register inserts bus wait states until the calculation has finished, before returning the result. Hence it is possible for the software to write the input and immediately read the result without polling to see if it is valid.
Page 480
CORDIC co-processor (CORDIC) RM0440 17.3.8 Interrupt mode By setting the interrupt enable (IE) bit in the CORDIC_CSR register, an interrupt is generated whenever the RRDY flag is set. The interrupt is cleared when the flag is reset. This mode allows the result of the calculation to be read under interrupt service routine, and hence given a priority relative to other tasks.
Page 481
RM0440 CORDIC co-processor (CORDIC) Note: Each DMA request must be acknowledged, as a result of the DMA performing an access to the CORDIC_WDATA or CORDIC_RDATA register. If an extraneous access to the relevant register occurs before this, the acknowledge is asserted prematurely, and could block the DMA channel.
Page 482
CORDIC co-processor (CORDIC) RM0440 Bit 20 NARGS: Number of arguments expected by the CORDIC_WDATA register 0: Only one 32-bit write (or two 16-bit values if ARGSIZE = 1) is needed for the next calculation. 1: Two 32-bit values must be written to the CORDIC_WDATA register to trigger the next calculation.
Page 483
RM0440 CORDIC co-processor (CORDIC) Bits 10:8 SCALE[2:0]: Scaling factor The value of this field indicates the scaling factor applied to the arguments and/or results. A value n implies that the arguments have been multiplied by a factor 2 , and/or the results need to be multiplied by 2 .
Page 484
CORDIC co-processor (CORDIC) RM0440 Bits 31:0 ARG[31:0]: Function input arguments This register is programmed with the input arguments for the function selected in the CORDIC_CSR register FUNC field. If 32-bit format is selected (CORDIC_CSR.ARGSIZE = 0) and two input arguments are required (CORDIC_CSR.NARGS = 1), two successive writes are required to this register.
RM0440 CORDIC co-processor (CORDIC) 17.4.3 CORDIC result register (CORDIC_RDATA) Address offset: 0x8 Reset value: 0x0000 0000 RES[31:16] RES[15:0] Bits 31:0 RES[31:0]: Function result If 32-bit format is selected (CORDIC_CSR.RESSIZE = 0) and two output values are expected (CORDIC_CSR.NRES = 1), this register must be read twice when the RRDY flag is set.
Page 486
Filter math accelerator (FMAC) RM0440 Filter math accelerator (FMAC) 18.1 FMAC introduction The filter math accelerator unit performs arithmetic operations on vectors. It comprises a multiplier/accumulator (MAC) unit, together with address generation logic which allows it to index vector elements held in local memory. The unit includes support for circular buffers on input and output, which allows digital filters to be implemented.
RM0440 Filter math accelerator (FMAC) 18.3 FMAC functional description 18.3.1 General description The FMAC is shown in Figure Figure 41. Block diagram Control and sequencing Read x1, x2 pointer offset pointers Write y offset pointers pointers Buffer base address Local pointers Memory Multiply and...
Page 488
Filter math accelerator (FMAC) RM0440 18.3.2 Local memory and buffers The unit contains a 256 x 16-bit read/write memory which is used for local storage: • Input values (the elements of the input vectors) are stored in two buffers, X1 and X2. •...
RM0440 Filter math accelerator (FMAC) Figure 42. Input buffer areas X1 buffer X2 buffer x1_buf_size x2_buf_size MSv45869V1 The X1 buffer can be used as a circular buffer, in which case new data are continually transferred into the input buffer whenever space is available. Pre-loading this buffer is optional for digital filters, since if no input samples have been written in the buffer when the operation is started, it is flagged as empty, which triggers the CPU or DMA to load new samples until there are enough to begin operation.
Filter math accelerator (FMAC) RM0440 Figure 43. Circular input buffer x1_base Available buffer space x[n-N] x[n-6] x[n-5] These values in use for calculating y[n] x[n-4] x[n-3] x[n-2] x[n-1] x[n] x[n+1] x[n+2] Next values already loaded x[n+3] x[n+4] Write pointer Available buffer space MSv45870V1 The X2 buffer can only be used in vector mode (that is not circular), and needs to be pre- loaded, except if the contents of the buffer do not change from one operation to the next.
RM0440 Filter math accelerator (FMAC) Note: If the flow of samples is controlled by a timer or other peripheral such as an ADC, the buffer regularly goes empty, since the filter processes each new sample faster than the source can provide it.
Filter math accelerator (FMAC) RM0440 Figure 45. Circular output buffer y_base Available buffer space Read pointer y[n-M-4] y[n-M-3] These samples not yet read y[n-M-2] y[n-M-1] y[n-M] y[n-6] These samples in use y[n-5] for calculating y[n] y[n-4] y[n-3] y[n-2] y[n-1] Next sample y[n] Available buffer space MSv45873V1...
Page 494
Filter math accelerator (FMAC) RM0440 Load X2 buffer This function pre-loads the X2 buffer with N + M values, starting from the address in X2_BASE. Successive writes to the FMAC_WDATA register load the write data into the X2 buffer and increment the write address. The function can be used to pre-load the buffer with the elements of a vector, or the coefficients of a filter.
RM0440 Filter math accelerator (FMAC) = B.X , where X = [x ,...,x ] is composed of the N+1 elements of X at indexes n - N to This function corresponds to a finite impulse response (FIR) filter, where vector B contains the filter coefficients and vector X the sampled data.
Page 496
Filter math accelerator (FMAC) RM0440 Parameters: • The parameter P contains the length, N+1, of the coefficient vector B in the range [2:127]. • The parameter R contains the gain to be applied to the accumulator output. The value output to the Y buffer is multiplied by 2 , where R is in the range [0:7] •...
RM0440 Filter math accelerator (FMAC) Figure 48. IIR filter structure (direct form 1) b[0] x[n] y[n] b[1] a[1] x[n-1] y[n-1] b[2] a[2] x[n-2] y[n-2] b[3] a[3] x[n-3] y[n-3] b[N] a[M] x[n-N] y[n-M] MSv47127V1 Input: • X1 buffer contains the elements of vector X. It is a circular buffer of length N + 1+ d. •...
Page 498
Filter math accelerator (FMAC) RM0440 The function completes when the START bit in the FMAC_PARAM register is reset by software. 18.3.7 Fixed point representation The FMAC operates in fixed point signed integer format. Input and output values are q1.15. In q1.15 format, numbers are represented by one sign bit and 15 fractional bits (binary decimal places).
RM0440 Filter math accelerator (FMAC) However, if the memory space is limited, the X1 and Y buffer areas can be overlapped, such that each output sample takes the place of the oldest input sample, which is no longer required: • X2_BASE = 0;...
Page 500
Filter math accelerator (FMAC) RM0440 The filter is started by writing to the FMAC_PARAM register with the following bitfield values: • FUNC = 8 (FIR filter); • P = N (number of coefficients); • Q = “Don’t care”; • R = Gain; •...
Page 501
RM0440 Filter math accelerator (FMAC) The buffer base addresses can be allocated anywhere, but must not overlap. An example configuration is given below: • X2_BASE = 0; • X1_BASE = N + M; • Y_BASE = 2N + M + d1; Note: The FULL_WM bitfield of X1 buffer configuration register must be programmed with a value less than or equal to log...
Filter math accelerator (FMAC) RM0440 filter length is small and the processor relatively slow, in this example. So increasing the Y buffer size would not help. Figure 51. Filtering example 2 FMAC_WDATA FMAC_RDATA FMAC_RDATA register write: register read: register read: WDATA = x[4] RDATA = y[0] RDATA = y[1]...
Page 505
RM0440 Filter math accelerator (FMAC) 18.3.12 Filter design tips The FMAC architecture imposes some constraints detailed below, on the design of digital filters. Implementation of direct form 2, or transposed forms, is not efficient. Filters which have been designed for such forms should be converted to direct form 1. Cascaded filters must either be combined into a single stage, or implemented as separate filters.
Page 506
Filter math accelerator (FMAC) RM0440 18.4 FMAC registers 18.4.1 FMAC X1 buffer configuration register (FMAC_X1BUFCFG) Address offset: 0x00 Reset value: 0x0000 0000 This register can only be modified if START = 0 in the FMAC_PARAM register. Res. Res. Res. Res. Res.
Page 507
RM0440 Filter math accelerator (FMAC) Bits 31:16 Reserved, must be kept at reset value. Bits 15:8 X2_BUF_SIZE[7:0]: Size of X2 buffer in 16-bit words This bitfield can not be modified when a function is ongoing (START = 1). Bits 7:0 X2_BASE[7:0]: Base address of X2 buffer The X2 buffer base address can be modified while START=1, for example to change coefficient values.
Page 508
Filter math accelerator (FMAC) RM0440 18.4.4 FMAC parameter register (FMAC_PARAM) Address offset: 0x0C Reset value: 0x0000 0000 START FUNC[6:0] R[7:0] Q[7:0] P[7:0] Bit 31 START: Enable execution 0: Stop execution 1: Start execution Setting this bit triggers the execution of the function selected in the FUNC bitfield. Resetting it by software stops any ongoing function.
Page 510
Filter math accelerator (FMAC) RM0440 Bit 2 OVFLIEN: Enable overflow error interrupts 0: Disabled. No interrupts are generated upon overflow detection. 1: Enabled. An interrupt request is generated if the OVFL flag is set This bit is set and cleared by software. A read returns the current state of the bit. Bit 1 WIEN: Enable write interrupt 0: Disabled.
Page 511
RM0440 Filter math accelerator (FMAC) Bits 7:2 Reserved, must be kept at reset value. Bit 1 X1FULL: X1 buffer full flag The buffer is flagged as full if the number of available spaces is less than the FULL_WM threshold. The number of available spaces is the difference between the write pointer and the least recent sample currently in use.
Page 512
Filter math accelerator (FMAC) RM0440 18.4.8 FMAC read data register (FMAC_RDATA) Address offset: 0x1C Reset value: 0x0000 0000 Res. Res. Res. Res. Res. Res. Res. Res. Res. Res. Res. Res. Res. Res. Res. Res. RDATA[15:0] Bits 31:16 Reserved, must be kept at reset value. Bits 15:0 RDATA[15:0]: Read data When a read access to this register occurs, the read data are the contents of the Y output buffer at the address offset indicated by the READ pointer.
RM0440 Filter math accelerator (FMAC) 18.4.9 FMAC register map Table 118.FMAC register map and reset values Offset Register name FMAC_X1BUFCFG X1_BUF_SIZE[7:0] X1_BASE[7:0] 0x00 Reset value 0 0 0 FMAC_X2BUFCFG X2_BUF_SIZE[7:0] X2_BASE[7:0] 0x04 Reset value 0 0 0 FMAC_YBUFCFG Y_BUF_SIZE[7:0] Y_BASE[7:0] 0x08 Reset value 0 0 0...
Page 514
Flexible static memory controller (FSMC) RM0440 Flexible static memory controller (FSMC) 19.1 Introduction The flexible static memory controller (FSMC) includes two memory controllers: • The NOR/PSRAM memory controller • The NAND memory controller This memory controller is also named flexible memory controller (FMC). 19.2 FMC main features The FMC functional block makes the interface with: synchronous and asynchronous static...
RM0440 Flexible static memory controller (FSMC) At startup the FMC pins must be configured by the user application. The FMC I/O pins which are not used by the application can be used for other purposes. The FMC registers that define the external device type and associated characteristics are usually set at boot time and do not change until the next reset or power-up.
Page 516
Flexible static memory controller (FSMC) RM0440 19.4 AHB interface The AHB slave interface allows internal CPUs and other bus master peripherals to access the external memories. AHB transactions are translated into the external device protocol. In particular, if the selected external memory is 16- or 8-bit wide, 32-bit wide transactions on the AHB are split into consecutive 16- or 8-bit accesses.
Page 517
RM0440 Flexible static memory controller (FSMC) to any other value than 0, the FMC chip select (FMC_NEx) toggles between the consecutive accesses. This feature is required when interfacing with FRAM memory. • AHB transaction size is smaller than the memory size: The transfer may or not be consistent depending on the type of external device: –...
RM0440 Flexible static memory controller (FSMC) 19.5.2 NAND Flash memory address mapping The NAND bank is divided into memory areas as indicated in Table 121. Table 121. NAND memory mapping and timing registers Start address End address FMC bank Memory space Timing register 0x8800 0000 0x8BFF FFFF...
Page 520
Flexible static memory controller (FSMC) RM0440 19.6 NOR Flash/PSRAM controller The FMC generates the appropriate signal timings to drive the following types of memories: • Asynchronous SRAM, FRAM and ROM – 8 bits – 16 bits • PSRAM (CellularRAM™) – Asynchronous mode –...
Flexible static memory controller (FSMC) RM0440 NOR Flash memory, 16-bit multiplexed I/Os Table 125. 16-bit multiplexed I/O NOR Flash memory FMC signal name Function Clock (for synchronous access) A[25:16] Address bus 16-bit multiplexed, bidirectional address/data bus (the 16-bit address AD[15:0] A[15:0] and data D[15:0] are multiplexed on the databus) NE[x] Chip select, x = 1..4...
RM0440 Flexible static memory controller (FSMC) Table 127. 16-Bit multiplexed I/O PSRAM (continued) FMC signal name I/O Function NE[x] Chip select, x = 1..4 (called NCE by PSRAM (CellularRAM™ i.e. CRAM)) Output enable Write enable NL(= NADV) Address valid PSRAM input (memory signal name: NADV) NWAIT PSRAM wait input signal to the FMC NBL[1:0]...
Page 524
Flexible static memory controller (FSMC) RM0440 Table 128. NOR Flash/PSRAM: example of supported memories and transactions (continued) Allowed/ Memory Device Mode data Comments data size size allowed Asynchronous Asynchronous Use of byte lanes NBL[1:0] Asynchronous Asynchronous Asynchronous Split into 2 FMC accesses PSRAM Asynchronous Split into 2 FMC accesses...
RM0440 Flexible static memory controller (FSMC) 19.6.4 NOR Flash/PSRAM controller asynchronous transactions Asynchronous static memories (NOR Flash, PSRAM, SRAM, FRAM) • Signals are synchronized by the internal clock HCLK. This clock is not issued to the memory • The FMC always samples the data before de-asserting the NOE signal. This guarantees that the memory data hold timing constraint is met (minimum Chip Enable high to data transition is usually 0 ns) •...
Flexible static memory controller (FSMC) RM0440 Figure 55. Mode 1 write access waveforms Memory transaction A[25:0] NBL[x:0] Data bus Data driven by controller NBLSET ADDSET HCLK cycles DATAST HCLK cycles DATAHLD +1 HCLK HCLK cycles cycles MSv41665V1 The DATAHLD time at the end of the read and write transactions guarantee the address and data hold time after the NOE/NWE rising edge.
RM0440 Flexible static memory controller (FSMC) Table 129. FMC_BCRx bitfields (mode 1) (continued) Bit number Bit name Value to set MTYP As needed, exclude 0x2 (NOR Flash memory) MUXE MBKEN Table 130. FMC_BTRx bitfields (mode 1) Bit number Bit name Value to set Duration of the data hold phase (DATAHLD HCLK cycles for read 31:30...
Flexible static memory controller (FSMC) RM0440 Figure 57. Mode A write access waveforms Memory transaction A[25:0] NBL[x:0] Data bus Data driven by controller NBLSET ADDSET HCLK cycles DATAST HCLK cycles DATAHLD +1 HCLK HCLK cycles cycles MSv41665V1 The differences compared with Mode 1 are the toggling of NOE and the independent read and write timings.
RM0440 Flexible static memory controller (FSMC) Table 131. FMC_BCRx bitfields (mode A) (continued) Bit number Bit name Value to set MTYP As needed, exclude 0x2 (NOR Flash memory) MUXEN MBKEN Table 132. FMC_BTRx bitfields (mode A) Bit number Bit name Value to set Duration of the data hold phase (DATAHLD HCLK cycles for read 31:30...
RM0440 Flexible static memory controller (FSMC) Figure 60. Mode B write access waveforms Memory transaction A[25:0] NADV Data bus Data driven by controller ADDSET HCLK cycles DATAST HCLK cycles DATAHLD +1 HCLK cycles MSv41680V1 The differences with mode 1 are the toggling of NWE and the independent read and write timings when extended mode is set (mode B).
Flexible static memory controller (FSMC) RM0440 Table 134. FMC_BCRx bitfields (mode 2/B) (continued) Bit number Bit name Value to set MTYP 0x2 (NOR Flash memory) MUXEN MBKEN Table 135. FMC_BTRx bitfields (mode 2/B) Bit number Bit name Value to set Duration of the data hold phase (DATAHLD HCLK cycles for read 31:30 DATAHLD...
Flexible static memory controller (FSMC) RM0440 Table 137. FMC_BCRx bitfields (mode C) Bit number Bit name Value to set 31:24 Reserved 0x000 23:22 NBLSET[1:0] Don’t care CCLKEN As needed CBURSTRW 0x0 (no effect in Asynchronous mode) 18:16 CPSIZE 0x0 (no effect in Asynchronous mode) ASYNCWAIT Set to 1 if the memory supports this feature.
RM0440 Flexible static memory controller (FSMC) Table 139. FMC_BWTRx bitfields (mode C) Bit number Bit name Value to set Duration of the data hold phase (DATAHLD+1 HCLK cycles for write 31:30 DATAHLD accesses). 29:28 ACCMOD 27:24 DATLAT Don’t care 23:20 CLKDIV Don’t care 19:16...
Flexible static memory controller (FSMC) RM0440 Figure 64. Mode D write access waveforms Memory transaction A[25:0] NADV NBL[x:0] Data bus Data driven by controller NBLSET ADDSET HCLK cycles ADDHLD DATAST HCLK cycles DATAHLD +1 HCLK HCLK cycles HCLK cycles cycles MSv41684V1 The differences with mode 1 are the toggling of NOE that goes on toggling after NADV changes and the independent read and write timings.
RM0440 Flexible static memory controller (FSMC) Table 140. FMC_BCRx bitfields (mode D) (continued) Bit number Bit name Value to set FACCEN Set according to memory support MWID As needed MTYP As needed MUXEN MBKEN Table 141. FMC_BTRx bitfields (mode D) Bit number Bit name Value to set...
RM0440 Flexible static memory controller (FSMC) Figure 66. Muxed write access waveforms Memory transaction A[25:16] NADV NBL[x:0] AD[15:0] Lower address Data driven by controller NBLSET ADDSET HCLK cycles ADDHLD DATAST HCLK cycles DATAHLD +1 HCLK HCLK cycles HCLK cycles cycles MSv41686V1 The difference with mode D is the drive of the lower address byte(s) on the data bus.
Flexible static memory controller (FSMC) RM0440 Table 143. FMC_BCRx bitfields (Muxed mode) (continued) Bit number Bit name Value to set MWID As needed MTYP 0x2 (NOR Flash memory) or 0x1(PSRAM) MUXEN MBKEN Table 144. FMC_BTRx bitfields (Muxed mode) Bit number Bit name Value to set Duration of the data hold phase (DATAHLD HCLK cycles for read...
RM0440 Flexible static memory controller (FSMC) The memory asserts the WAIT signal aligned to NOE/NWE which toggles: DATAST ≥ × HCLK max_wait_assertion_time The memory asserts the WAIT signal aligned to NEx (or NOE/NWE not toggling): > max_wait_assertion_time address_phase hold_phase then: –...
Flexible static memory controller (FSMC) RM0440 Figure 68. Asynchronous wait during a write access waveforms Memory transaction A[25:0] address phase data setup phase NWAIT don’t care don’t care 1HCLK D[15:0] data driven by FMC 3HCLK MSv40168V1 1. NWAIT polarity depends on WAITPOL bit setting in FMC_BCRx register. CellularRAM™...
Page 543
RM0440 Flexible static memory controller (FSMC) register. The FMC does not include the clock cycle when NADV is low in the data latency count. Caution: Some NOR Flash memories include the NADV Low cycle in the data latency count, so that the exact relation between the NOR Flash latency and the FMC DATLAT parameter can be either: •...
Flexible static memory controller (FSMC) RM0440 The FMC supports both NOR Flash wait state configurations, for each chip select, thanks to the WAITCFG bit in the FMC_BCRx registers (x = 0..3). Figure 69. Wait configuration waveforms Memory transaction = burst of 4 half words HCLK addr[25:16] A[25:16]...
Flexible static memory controller (FSMC) RM0440 Table 145. FMC_BCRx bitfields (Synchronous multiplexed read mode) (continued) Bit number Bit name Value to set WAITPOL To be set according to memory BURSTEN Reserved FACCEN Set according to memory support (NOR Flash memory) MWID As needed MTYP...
Flexible static memory controller (FSMC) RM0440 Table 147. FMC_BCRx bitfields (Synchronous multiplexed write mode) (continued) Bit number Bit name Value to set WREN WAITCFG Reserved WAITPOL to be set according to memory BURSTEN no effect on synchronous write Reserved FACCEN Set according to memory support MWID As needed...
Page 549
RM0440 Flexible static memory controller (FSMC) 19.6.6 NOR/PSRAM controller registers SRAM/NOR-Flash chip-select control register for bank x (FMC_BCRx) (x = 1 to 4) Address offset: 8 * (x – 1), (x = 1 to 4) Reset value: Bank 1: 0x0000 30DB Reset value: Bank 2: 0x0000 30D2 Reset value: Bank 3: 0x0000 30D2 Reset value: Bank 4: 0x0000 30D2...
Page 550
Flexible static memory controller (FSMC) RM0440 Bit 20 CCLKEN: Continuous clock enable This bit enables the FMC_CLK clock output to external memory devices. 0: The FMC_CLK is only generated during the synchronous memory access (read/write transaction). The FMC_CLK clock ratio is specified by the programmed CLKDIV value in the FMC_BCRx register (default after reset).
Page 551
RM0440 Flexible static memory controller (FSMC) Bit 13 WAITEN: Wait enable bit This bit enables/disables wait-state insertion via the NWAIT signal when accessing the memory in Synchronous mode. 0: NWAIT signal is disabled (its level not taken into account, no wait state inserted after the programmed Flash latency period).
Page 552
Flexible static memory controller (FSMC) RM0440 Bits 3:2 MTYP[1:0]: Memory type Defines the type of external memory attached to the corresponding memory bank. 00: SRAM/FRAM (default after reset for Bank 2...4) 01: PSRAM (CRAM) / FRAM 10: NOR Flash/OneNAND Flash (default after reset for Bank 1) 11: reserved Bit 1 MUXEN: Address/data multiplexing enable bit When this bit is set, the address and data values are multiplexed on the data bus, valid only with...
Page 553
RM0440 Flexible static memory controller (FSMC) Bits 29:28 ACCMOD[1:0]: Access mode Specifies the asynchronous access modes as shown in the timing diagrams. These bits are taken into account only when the EXTMOD bit in the FMC_BCRx register is 1. 00: Access mode A 01: Access mode B 10: Access mode C 11: Access mode D...
Page 554
Flexible static memory controller (FSMC) RM0440 Bits 15:8 DATAST[7:0]: Data-phase duration These bits are written by software to define the duration of the data phase (refer to Figure 54 Figure 66), used in asynchronous accesses: 0000 0000: Reserved 0000 0001: DATAST phase duration = 1 × HCLK clock cycles 0000 0010: DATAST phase duration = 2 ×...
Page 555
RM0440 Flexible static memory controller (FSMC) SRAM/NOR-Flash write timing registers x (FMC_BWTRx) Address offset: 0x104 + 8 * (x – 1), (x = 1 to 4) Reset value: 0x0FFF FFFF This register contains the control information of each memory bank. It is used for SRAMs, PSRAMs and NOR Flash memories.
Page 556
Flexible static memory controller (FSMC) RM0440 Bits 15:8 DATAST[7:0]: Data-phase duration. These bits are written by software to define the duration of the data phase (refer to Figure 54 Figure 66), used in asynchronous SRAM, PSRAM and NOR Flash memory accesses: 0000 0000: Reserved 0000 0001: DATAST phase duration = 1 ×...
RM0440 Flexible static memory controller (FSMC) Bits 31:20 Reserved, must be kept at reset value. Bit 19 CNTB4EN: Counter Bank 4 enable This bit enables the chip select counter for PSRAM/NOR Bank 4. 0: Counter disabled for Bank 4 1: Counter enabled for Bank 4 Bit 18 CNTB3EN: Counter Bank 3 enable This bit enables the chip select counter for PSRAM/NOR Bank 3.
Flexible static memory controller (FSMC) RM0440 Table 149. Programmable NAND Flash access parameters (continued) Parameter Function Access mode Unit Min. Max. Number of clock cycles (HCLK) during which the address must be AHB clock cycle Memory hold held (as well as the data if a write Read/Write (HCLK) access is performed) after the...
Flexible static memory controller (FSMC) RM0440 19.7.2 NAND Flash supported memories and transactions Table 152 shows the supported devices, access modes and transactions. Transactions not allowed (or not supported) by the NAND Flash controller are shown in gray. Table 152. Supported memories and transactions Memory Allowed/ Device...
Flexible static memory controller (FSMC) RM0440 to implement the prewait functionality needed by some NAND Flash memories (see details in Section 19.7.5: NAND Flash prewait functionality). The controller waits for the NAND Flash memory to be ready (R/NB signal high), before starting a new access to the same or another memory bank.
Page 563
RM0440 Flexible static memory controller (FSMC) When this functionality is required, it can be ensured by programming the MEMHOLD value to meet the t timing. However any CPU read access to the NAND Flash memory has a hold delay of (MEMHOLD + 2) HCLK cycles and CPU write access has a hold delay of (MEMHOLD) HCLK cycles inserted between the rising edge of the NWE signal and the next access.
Page 564
Flexible static memory controller (FSMC) RM0440 To perform an ECC computation: Enable the ECCEN bit in the FMC_PCR register. Write data to the NAND Flash memory page. While the NAND page is written, the ECC block computes the ECC value. Read the ECC value available in the FMC_ECCR register and store it in a variable.
Page 565
RM0440 Flexible static memory controller (FSMC) Bits 12:9 TCLR[3:0]: CLE to RE delay Sets time from CLE low to RE low in number of AHB clock cycles (HCLK). Time is t_clr = (TCLR + SET + 2) × THCLK where THCLK is the HCLK clock period 0000: 1 HCLK cycle (default) 1111: 16 HCLK cycles Note: SET is MEMSET or ATTSET according to the addressed space.
Page 566
Flexible static memory controller (FSMC) RM0440 FIFO status and interrupt register (FMC_SR) Address offset: 0x84 Reset value: 0x0000 0040 This register contains information about the FIFO status and interrupt. The FMC features a FIFO that is used when writing to memories to transfer up to 16 words of data from the AHB. This is used to quickly write to the FIFO and free the AHB for transactions to peripherals other than the FMC, while the FMC is draining its FIFO into the memory.
Page 567
RM0440 Flexible static memory controller (FSMC) Bit 0 IRS: Interrupt rising edge status The flag is set by hardware and reset by software. 0: No interrupt rising edge occurred 1: Interrupt rising edge occurred Note: If this bit is written by software to 1 it is set. Common memory space timing register (FMC_PMEM) Address offset: Address: 0x88 Reset value: 0xFCFC FCFC...
Page 568
Flexible static memory controller (FSMC) RM0440 Bits 7:0 MEMSET[7:0]: Common memory x setup time Defines the number of HCLK (+1) clock cycles to set up the address before the command assertion (NWE, NOE), for NAND Flash read or write access to common memory space on socket x: 0000 0000: 1 HCLK cycle 1111 1110: 255 HCLK cycles...
RM0440 Flexible static memory controller (FSMC) Bits 7:0 ATTSET[7:0]: Attribute memory setup time Defines the number of HCLK (+1) clock cycles to set up address before the command assertion (NWE, NOE), for NAND Flash read or write access to attribute memory space on socket: 0000 0000: 1 HCLK cycle 1111 1110: 255 HCLK cycles...
Quad-SPI interface (QUADSPI) RM0440 Quad-SPI interface (QUADSPI) 20.1 Introduction The QUADSPI is a specialized communication interface targeting single, dual or quad SPI Flash memories. It can operate in any of the three following modes: • indirect mode: all the operations are performed using the QUADSPI registers •...
Quad-SPI interface (QUADSPI) RM0440 20.3.3 QUADSPI command sequence The QUADSPI communicates with the Flash memory using commands. Each command can include 5 phases: instruction, address, alternate byte, dummy, data. Any of these phases can be configured to be skipped, but at least one of the instruction, address, alternate byte, or data phase must be present.
Page 575
RM0440 Quad-SPI interface (QUADSPI) Alternate-bytes phase In the alternate-bytes phase, 1-4 bytes are sent to the Flash memory, generally to control the mode of operation. The number of alternate bytes to be sent is configured in the ABSIZE[1:0] field of QUADSPI_CCR[17:16] register. The bytes to be sent are specified in the QUADSPI_ABR register.
Page 576
Quad-SPI interface (QUADSPI) RM0440 mode). This can be configured using the ABMODE[1:0] field of QUADSPI_CCR[15:14] register. When DMODE = 00, the data phase is skipped, and the command sequence finishes immediately by raising nCS. This configuration must only be used in only indirect write mode.
RM0440 Quad-SPI interface (QUADSPI) SDR mode By default, the DDRM bit (QUADSPI_CCR[31]) is 0 and the QUADSPI operates in single data rate (SDR) mode. In SDR mode, when the QUADSPI is driving the IO0/SO, IO1, IO2, IO3 signals, these signals transition only with the falling edge of CLK. When receiving data in SDR mode, the QUADSPI assumes that the Flash memories also send the data using CLK’s falling edge.
Page 578
Quad-SPI interface (QUADSPI) RM0440 The Flash memory size, as specified in FSIZE[4:0] (QUADSPI_DCR[20:16]), should reflect the total Flash memory capacity, which is double the size of one individual component. If address X is even, then the byte which the QUADSPI gives for address X is the byte at the address X/2 of FLASH 1, and the byte which the QUADSPI gives for address X+1 is the byte at the address X/2 of FLASH 2.
Page 579
RM0440 Quad-SPI interface (QUADSPI) is set when the limit of the external SPI memory is reached according to the Flash memory size defined in the QUADSPI_CR. Triggering the start of a command Essentially, a command starts as soon as firmware gives the last information that is necessary for this command.
Page 580
Quad-SPI interface (QUADSPI) RM0440 The accesses to the Flash memory begin in the same way as in indirect read mode: if no address is required (AMODE = 00), accesses begin as soon as the QUADSPI_CCR is written. Otherwise, if an address is required, the first access begins when QUADSPI_AR is written.
Page 581
RM0440 Quad-SPI interface (QUADSPI) that nCS is released after a period of TIMEOUT[15:0] (QUADSPI_LPTR) cycles have elapsed without any access since when the FIFO becomes full with prefetch data. BUSY goes high as soon as the first memory-mapped access occurs. Because of the prefetch operations, BUSY does not fall until there is a timeout, there is an abort, or the peripheral is disabled.
Page 582
Quad-SPI interface (QUADSPI) RM0440 enabled, the address and the alternate bytes are sent on both clock edges and the data are sent/received on both clock edges. Regardless of the DDRM bit setting, instructions are always sent in SDR mode. The DMA requests are enabled setting the DMAEN bit. In case of interrupt usage, their respective enable bit can be also set during this phase.
Page 583
RM0440 Quad-SPI interface (QUADSPI) When writing the control register (QUADSPI_CR) the user specifies the following settings: • The enable bit (EN) set to ‘1’ • The DMA enable bit (DMAEN) for transferring data to/from RAM • Timeout counter enable bit (TCEN) •...
Page 584
Quad-SPI interface (QUADSPI) RM0440 In case of match, the status match flag is set and an interrupt is generated if enabled, and the QUADSPI can be automatically stopped if the AMPS bit is set. In any case, the latest retrieved value is available in the QUADSPI_DR. Memory-mapped mode In memory-mapped mode, the external Flash memory is seen as internal memory but with some latency during accesses.
RM0440 Quad-SPI interface (QUADSPI) 20.3.14 QUADSPI busy bit and abort functionality Once the QUADSPI starts an operation with the Flash memory, the BUSY bit is automatically set in the QUADSPI_SR. In indirect mode, the BUSY bit is reset once the QUADSPI has completed the requested command sequence and the FIFO is empty.
Quad-SPI interface (QUADSPI) RM0440 When CKMODE = 1 (“mode3”) and DDRM = 1 (DDR mode), nCS falls one CLK cycle before an operation first rising CLK edge, and nCS rises one CLK cycle after the operation final active rising CLK edge, as shown in Figure 80.
RM0440 Quad-SPI interface (QUADSPI) 20.4 QUADSPI interrupts An interrupt can be produced on the following events: • Timeout • Status match • FIFO threshold • Transfer complete • Transfer error Separate interrupt enable bits are available for flexibility. Table 156. QUADSPI interrupt requests Interrupt event Event flag Enable control bit...
Page 588
Quad-SPI interface (QUADSPI) RM0440 20.5 QUADSPI registers 20.5.1 QUADSPI control register (QUADSPI_CR) Address offset: 0x0000 Reset value: 0x0000 0000 PRESCALER[7:0] APMS Res. TOIE SMIE FTIE TCIE TEIE Res. Res. Res. Res. FTHRES[3:0] FSEL Res. SSHIFT TCEN DMAEN ABORT Bits 31:24 PRESCALER[7:0]: Clock prescaler This field defines the scaler factor for generating CLK based on the clock (value+1).
Page 589
RM0440 Quad-SPI interface (QUADSPI) Bit 19 SMIE: Status match interrupt enable This bit enables the status match interrupt. 0: Interrupt disable 1: Interrupt enabled Bit 18 FTIE: FIFO threshold interrupt enable This bit enables the FIFO threshold interrupt. 0: Interrupt disabled 1: Interrupt enabled Bit 17 TCIE: Transfer complete interrupt enable This bit enables the transfer complete interrupt.
Page 590
Quad-SPI interface (QUADSPI) RM0440 Bit 4 SSHIFT: Sample shift By default, the QUADSPI samples data 1/2 of a CLK cycle after the data is driven by the Flash memory. This bit allows the data is to be sampled later in order to account for external signal delays.
Page 592
Quad-SPI interface (QUADSPI) RM0440 20.5.3 QUADSPI status register (QUADSPI_SR) Address offset: 0x0008 Reset value: 0x0000 0000 Res. Res. Res. Res. Res. Res. Res. Res. Res. Res. Res. Res. Res. Res. Res. Res. Res. Res. Res. FLEVEL[4:0] Res. Res. BUSY Bits 31:13 Reserved, must be kept at reset value. Bits 12:8 FLEVEL[4:0]: FIFO level This field gives the number of valid bytes which are being held in the FIFO.
Page 594
Quad-SPI interface (QUADSPI) RM0440 Bits 31:0 DL[31:0]: Data length Number of data to be retrieved (value+1) in indirect and status-polling modes. A value no greater than 3 (indicating 4 bytes) should be used for status-polling mode. All 1s in indirect mode means undefined length, where QUADSPI will continue until the end of memory, as defined by FSIZE.
Page 595
RM0440 Quad-SPI interface (QUADSPI) Bit 28 SIOO: Send instruction only once mode Section 20.3.12: Sending the instruction only once on page 584. This bit has no effect when IMODE = 00. 0: Send instruction on every transaction 1: Send instruction only for the first command This field can be written only when BUSY = 0.
Page 596
Quad-SPI interface (QUADSPI) RM0440 Bits 13:12 ADSIZE[1:0]: Address size This bit defines address size: 00: 8-bit address 01: 16-bit address 10: 24-bit address 11: 32-bit address This field can be written only when BUSY = 0. Bits 11:10 ADMODE[1:0]: Address mode This field defines the address phase mode of operation: 00: No address 01: Address on a single line...
Page 597
RM0440 Quad-SPI interface (QUADSPI) 20.5.8 QUADSPI alternate bytes registers (QUADSPI_ABR) Address offset: 0x001C Reset value: 0x0000 0000 ALTERNATE[31:16] ALTERNATE[15:0] Bits 31:0 ALTERNATE[31:0]: Alternate Bytes Optional data to be send to the external SPI device right after the address. This field can be written only when BUSY = 0. 20.5.9 QUADSPI data register (QUADSPI_DR) Address offset: 0x0020...
Page 598
Quad-SPI interface (QUADSPI) RM0440 20.5.10 QUADSPI polling status mask register (QUADSPI_PSMKR) Address offset: 0x0024 Reset value: 0x0000 0000 MASK[31:16] MASK[15:0] Bits 31:0 MASK[31:0]: Status mask Mask to be applied to the status bytes received in polling mode. For bit n: 0: Bit n of the data received in automatic polling mode is masked and its value is not considered in the matching logic 1: Bit n of the data received in automatic polling mode is unmasked and its value is...
Page 599
RM0440 Quad-SPI interface (QUADSPI) 20.5.12 QUADSPI polling interval register (QUADSPI_PIR) Address offset: 0x002C Reset value: 0x0000 0000 Res. Res. Res. Res. Res. Res. Res. Res. Res. Res. Res. Res. Res. Res. Res. Res. INTERVAL[15:0] Bits 31:16 Reserved, must be kept at reset value. Bits 15:0 INTERVAL[15:0]: Polling interval Number of CLK cycles between to read during automatic polling phases.
Quad-SPI interface (QUADSPI) RM0440 20.5.14 QUADSPI register map Table 157. QUADSPI register map and reset values Register Offset name FTHRES QUADSPI_CR PRESCALER[7:0] [3:0] 0x0000 Reset value QUADSPI_DCR FSIZE[4:0] CSHT 0x0004 Reset value QUADSPI_SR FLEVEL[4:0] 0x0008 Reset value QUADSPI_FCR 0x000C Reset value QUADSPI_DLR DL[31:0] 0x0010...
Page 601
RM0440 Analog-to-digital converters (ADC) Analog-to-digital converters (ADC) 21.1 Introduction This section describes the implementation of up to 5 ADCs: • ADC1 and ADC2 are tightly coupled and can operate in dual mode (ADC1 is master). • ADC3 and ADC4 are tightly coupled and can operate in dual mode (ADC3 is master). •...
Page 602
Analog-to-digital converters (ADC) RM0440 21.2 ADC main features • High-performance features – Up to 5 ADCs, out of which four of them ((in pairs) can operate in dual mode: ADC1 is connected to 14 external channels + 4 internal channels ADC2 is connected to 16 external channels + 2 internal channels ADC3 is connected to 15 external channels + 3 internal channels ADC4 is connected to 16 external channels + 2 internal channels...
RM0440 Analog-to-digital converters (ADC) application (auto-delayed mode) • Number of external analog input channels per ADC – Up to 5 fast channels from GPIO pads – Up to 13 slow channels from GPIO pads • In addition, there are several internal dedicated channels –...
RM0440 Analog-to-digital converters (ADC) 21.4.2 ADC pins and internal signals Table 159. ADC internal input/output signals Signal Internal signal name Description type Up to 32 external trigger inputs for the regular conversions (can be connected to on-chip timers). adc_ext_trg[31:0] Inputs These inputs are shared between the ADC master and the ADC slave.
Page 606
Analog-to-digital converters (ADC) RM0440 Table 160. ADC input/output pins (continued) Pin name Signal type Comments Up to 19 analog input channels (x = ADC number = 1, 2, 3, 4 or 5). Negative external analog ADCx_INNi input signals Refer to Section 21.4.4: ADC1/2/3/4/5 connectivity details.
Page 607
RM0440 Analog-to-digital converters (ADC) Figure 83. ADC clock scheme (ADC1, ADC2) or (ADC3, ADC4, ADC5) (Reset and clock adc_hclk AHB interface controller) Bits CKMODE[1:0] of ADCx_CCR Analog ADC1 or 3 (master) ADC12SEL[1:0] /1 or /2 or /4 Others ADC345SEL[1:0] Analog ADC2 or 4 (slave) /1, 2, 4, 6, 8, 10, adc_ker_ck...
Analog-to-digital converters (ADC) RM0440 21.4.4 ADC1/2/3/4/5 connectivity ADC1, ADC2, ADC3, ADC4 and ADC5 are tightly coupled and share some external channels as described in the below figures. Figure 84. ADC1 connectivity ADC1 Channel selection Fast channel ADC12_INP1 Fast channel ADC12_INN1 ADC12_INP2 Fast channel ADC1_INN2...
Analog-to-digital converters (ADC) RM0440 Figure 88. ADC5 connectivity ADC5 Channel selection Fast channel ADC5_INP1 Fast channel ADC5_INN1 ADC5_INP2 Fast channel OPAMP5 internal Fast channel output Fast channel OPAMP4 internal Fast channel output Reserved ADC345_INP6 Slow channel ADC345_INN6 REF+ ADC345_INP7 Slow channel ADC345_INN7 ADC345_INP8 Slow channel...
Page 613
RM0440 Analog-to-digital converters (ADC) 21.4.5 Slave AHB interface The ADCs implement an AHB slave port for control/status register and data access. The features of the AHB interface are listed below: • Word (32-bit) accesses • Single cycle response • Response to all read/write accesses to the registers with zero wait states. The AHB slave interface does not support split/retry requests, and never generates AHB errors.
Page 614
Analog-to-digital converters (ADC) RM0440 21.4.7 Single-ended and differential input channels Channels can be configured to be either single-ended input or differential input by programming DIFSEL[i] bits in the ADC_DIFSEL register. This configuration must be written while the ADC is disabled (ADEN=0). Note that the DIFSEL[i] bits corresponding to single- ended channels are always programmed at 0.
RM0440 Analog-to-digital converters (ADC) The calibration is then initiated by software by setting bit ADCAL=1. Calibration can only be initiated when the ADC is disabled (when ADEN=0). ADCAL bit stays at 1 during all the calibration sequence. It is then cleared by hardware as soon the calibration completes. At this time, the associated calibration factor is stored internally in the analog ADC and also in the bits CALFACT_S[6:0] or CALFACT_D[6:0] of ADC_CALFACT register (depending on single-ended or differential input calibration)
Analog-to-digital converters (ADC) RM0440 Software procedure to re-inject a calibration factor into the ADC Ensure ADEN=1 and ADSTART=0 and JADSTART=0 (ADC enabled and no conversion is ongoing). Write CALFACT_S and CALFACT_D with the new calibration factors. When a conversion is launched, the calibration factor will be injected into the analog ADC only if the internal analog calibration factor differs from the one stored in bits CALFACT_S for single-ended input channel or bits CALFACT_D for differential input channel.
Analog-to-digital converters (ADC) RM0440 Software procedure to disable the ADC Check that both ADSTART=0 and JADSTART=0 to ensure that no conversion is ongoing. If required, stop any regular and injected conversion ongoing by setting ADSTP=1 and JADSTP=1 and then wait until ADSTP=0 and JADSTP=0. Set ADDIS=1.
Page 619
RM0440 Analog-to-digital converters (ADC) The software can write the register ADC_JSQR at any time, when the ADC is enabled (ADEN=1). Refer to Section 21.6.16: ADC injected sequence register (ADC_JSQR) additional details. Note: There is no hardware protection to prevent these forbidden write accesses and ADC behavior may become in an unknown state.
Page 620
Analog-to-digital converters (ADC) RM0440 21.4.12 Channel-wise programmable sampling time (SMPR1, SMPR2) Before starting a conversion, the ADC must establish a direct connection between the voltage source under measurement and the embedded sampling capacitor of the ADC. This sampling time must be enough for the input voltage source to charge the embedded capacitor to the input voltage level.
RM0440 Analog-to-digital converters (ADC) Figure 93. Bulb mode timing diagram Normal (discontinuous) mode ADC state idle sample conversion idle sample conversion idle Trigger BULB (continuous) mode sample conversion sample conversion sample idle ADC state Trigger Sampling time programmed in SMP bits MSv46157V2 Sampling time control trigger mode When the SMPTRIG bit is set, the sampling time programmed though SMPx bits is not...
Page 622
Analog-to-digital converters (ADC) RM0440 21.4.13 Single conversion mode (CONT=0) In Single conversion mode, the ADC performs once all the conversions of the channels. This mode is started with the CONT bit at 0 by either: • Setting the ADSTART bit in the ADC_CR register (for a regular channel) •...
Page 623
RM0440 Analog-to-digital converters (ADC) Note: To convert a single channel, program a sequence with a length of 1. It is not possible to have both discontinuous mode and continuous mode enabled: it is forbidden to set both DISCEN=1 and CONT=1. Injected channels cannot be converted continuously.
Analog-to-digital converters (ADC) RM0440 21.4.16 ADC timing The elapsed time between the start of a conversion and the end of conversion is the sum of the configured sampling time plus the successive approximation time depending on data resolution: = [2.5 + 12.5 ] x T CONV...
RM0440 Analog-to-digital converters (ADC) Note: In auto-injection mode (JAUTO=1), setting ADSTP bit aborts both regular and injected conversions (JADSTP must not be used). Figure 95. Stopping ongoing regular conversions Trigger Trigger Convert Sample Sample ADC state Ch(N-1) Ch(N-1) Ch(N) JADSTART Cleared by Cleared by ADSTART...
Analog-to-digital converters (ADC) RM0440 21.4.18 Conversion on external trigger and trigger polarity (EXTSEL, EXTEN,JEXTSEL, JEXTEN) A conversion or a sequence of conversions can be triggered either by software or by an external event (e.g. timer capture, input pins). If the EXTEN[1:0] control bits (for a regular conversion) or JEXTEN[1:0] bits (for an injected conversion) are different from 0b00, then external events are able to trigger a conversion with the selected polarity.
RM0440 Analog-to-digital converters (ADC) Note: The regular trigger selection cannot be changed on-the-fly. The injected trigger selection can be anticipated and changed on-the-fly. Refer to Section 21.4.21: Queue of context for injected conversions on page 634 Each ADC master shares the same input triggers with its ADC slave as described in Figure Figure 97.
Analog-to-digital converters (ADC) RM0440 Table 163. ADC1/2 - External triggers for regular channels (continued) Name Source Type EXTSEL[4:0] adc_ext_trg9 TIM1_TRGO Internal signal from on-chip timers 01001 adc_ext_trg10 TIM1_TRGO2 Internal signal from on-chip timers 01010 adc_ext_trg11 TIM2_TRGO Internal signal from on-chip timers 01011 adc_ext_trg12 TIM4_TRGO...
RM0440 Analog-to-digital converters (ADC) Table 164. ADC1/2 - External trigger for injected channels (continued) Name Source Type JEXTSEL[4:0] adc_jext_trg9 TIM8_TRGO Internal signal from on-chip timers 01001 adc_jext_trg10 TIM8_TRGO2 Internal signal from on-chip timers 01010 adc_jext_trg11 TIM3_CC3 Internal signal from on-chip timers 01011 adc_jext_trg12 TIM3_TRGO...
Analog-to-digital converters (ADC) RM0440 Table 165. ADC3/4/5 - External triggers for regular channels (continued) Name Source Type EXTSEL[4:0] adc_ext_trg8 TIM8_TRGO2 Internal signal from on-chip timers 01000 adc_ext_trg9 TIM1_TRGO Internal signal from on-chip timers 01001 adc_ext_trg10 TIM1_TRGO2 Internal signal from on-chip timers 01010 adc_ext_trg11 TIM2_TRGO...
Page 631
RM0440 Analog-to-digital converters (ADC) Table 166. ADC3/4/5 - External triggers for injected channels (continued) Name Source Type JEXTSEL[4:0] adc_jext_trg8 TIM1_TRGO2 Internal signal from on-chip timers 01000 adc_jext_trg9 TIM8_TRGO Internal signal from on-chip timers 01001 adc_jext_trg10 TIM8_TRGO2 Internal signal from on-chip timers 01010 adc_jext_trg11 TIM1_CC3...
Page 632
Analog-to-digital converters (ADC) RM0440 reset and the injected channel sequence switches are launched (all the injected channels are converted once). Then, the regular conversion of the regular group of channels is resumed from the last interrupted regular conversion. If a regular event occurs during an injected conversion, the injected conversion is not interrupted but the regular sequence is executed at the end of the injected sequence.
RM0440 Analog-to-digital converters (ADC) Figure 98. Injected conversion latency adc_ker_ck Injection event Reset ADC max. latency MSv43771V1 1. The maximum latency value can be found in the electrical characteristics of the device datasheet. 21.4.20 Discontinuous mode (DISCEN, DISCNUM, JDISCEN) Regular group mode This mode is enabled by setting the DISCEN bit in the ADC_CFGR register.
Page 634
Analog-to-digital converters (ADC) RM0440 Note: The channel numbers referred to in the above example might not be available on all microcontrollers. When a regular group is converted in discontinuous mode, no rollover occurs (the last subgroup of the sequence can have less than n conversions). When all subgroups are converted, the next trigger starts the conversion of the first subgroup.
Page 635
RM0440 Analog-to-digital converters (ADC) All the parameters of the context are defined into a single register ADC_JSQR and this register implements a queue of 2 buffers, allowing the bufferization of up to 2 sets of parameters: • The JSQR register can be written at any moment even when injected conversions are ongoing.
Analog-to-digital converters (ADC) RM0440 Behavior when changing the trigger or sequence context Figure 99 Figure 100 show the behavior of the context Queue when changing the sequence or the triggers. Figure 99. Example of JSQR queue of context (sequence change) Write JSQR JSQR queue EMPTY...
RM0440 Analog-to-digital converters (ADC) Queue of context: Behavior when a queue overflow occurs Figure 101 Figure 102 show the behavior of the context Queue if an overflow occurs before or during a conversion. Figure 101. Example of JSQR queue of context with overflow before conversion =>...
Analog-to-digital converters (ADC) RM0440 It is recommended to manage the queue overflows as described below: • After each P context write into JSQR register, flag JQOVF shows if the write has been ignored or not (an interrupt can be generated). •...
Analog-to-digital converters (ADC) RM0440 Figure 106. Flushing JSQR queue of context by setting JADSTP=1 (JQM=0). Case when JADSTP occurs during an ongoing conversion and a new trigger occurs. Queue is flushed and maintains the last active context (P2 is lost) Write JSQR JSQR EMPTY...
RM0440 Analog-to-digital converters (ADC) Figure 108. Flushing JSQR queue of context by setting JADSTP=1 (JQM=1) Queue is flushed and becomes empty (P2 is lost) Write JSQR EMPTY P1, P2 EMPTY EMPTY JSQR queue Reset by H/W by S/W JADSTP JADSTART Reset by S/W by H/W...
Analog-to-digital converters (ADC) RM0440 21.4.26 Data management Data register, data alignment and offset (ADC_DR, OFFSETy, OFFSETy_CH, ALIGN) Data and alignment At the end of each regular conversion channel (when EOC event occurs), the result of the converted data is stored into the ADC_DR data register which is 16 bits wide. At the end of each injected conversion channel (when JEOC event occurs), the result of the converted data is stored into the corresponding ADC_JDRy data register which is 16 bits wide.
RM0440 Analog-to-digital converters (ADC) Table 168. Offset computation versus data resolution (continued) Subtraction between raw converted data and offset Resolution Result Comments (bits converted RES[1:0]) Offset Data, left aligned DATA[11:4],00 Signed The user must configure OFFSET[3:0] 10: 8-bit OFFSET[11:0] 8-bit data to “0000”...
Analog-to-digital converters (ADC) RM0440 ADC overrun (OVR, OVRMOD) The overrun flag (OSR) notifies of that a buffer overrun event occurred when the regular converted data has not been read (by the CPU or the DMA) before new converted data became available. The OVR flag is set if the EOC flag is still 1 at the time when a new conversion completes.
Page 651
RM0440 Analog-to-digital converters (ADC) Managing conversions without using the DMA and without overrun It may be useful to let the ADC convert one or more channels without reading the data each time (if there is an analog watchdog for instance). In this case, the OVRMOD bit must be configured to 1 and OVR flag should be ignored by the software.
Page 652
Analog-to-digital converters (ADC) RM0440 DMA circular mode (DMACFG=1) In this mode, the ADC generates a DMA transfer request each time a new conversion data is available in the data register, even if the DMA has reached the last DMA transfer. This allows configuring the DMA in circular mode to handle a continuous analog input data stream.
RM0440 Analog-to-digital converters (ADC) To stop a conversion in continuous auto-injection mode combined with autodelay mode (JAUTO=1, CONT=1 and AUTDLY=1), follow the following procedure: Wait until JEOS=1 (no more conversions are restarted) Clear JEOS, Set ADSTP=1 Read the regular data. If this procedure is not respected, a new regular sequence can restart if JEOS is cleared after ADSTP has been set.
RM0440 Analog-to-digital converters (ADC) 21.4.28 Analog window watchdog (AWD1EN, JAWD1EN, AWD1SGL, AWD1CH, AWD2CH, AWD3CH, AWD_HTx, AWD_LTx, AWDx) The three AWD analog watchdogs monitor whether some channels remain within a configured voltage range (window). Figure 125. Analog watchdog guarded area Analog voltage Higher threshold Guarded area Lower threshold...
Analog-to-digital converters (ADC) RM0440 These thresholds are programmed in bits HT1[11:0] and LT1[11:0] of the ADC_TR1 register for the analog watchdog 1. When converting data with a resolution of less than 12 bits (according to bits RES[1:0]), the LSB of the programmed thresholds must be kept cleared because the internal comparison is always performed on the full 12-bit raw converted data (left aligned).
RM0440 Analog-to-digital converters (ADC) Table 171. Analog watchdog 2 and 3 comparison Analog watchdog comparison between: Resolution Comments Raw converted data, (bits RES[1:0]) Thresholds left aligned 00: 12-bit DATA[11:4] LTx[7:0] and HTx[7:0] DATA[3:0] are not relevant for the comparison 01: 10-bit DATA[11:4] LTx[7:0] and HTx[7:0] DATA[3:2] are not relevant for the comparison 10: 8-bit...
Analog-to-digital converters (ADC) RM0440 Figure 127. ADCy_AWDx_OUT signal generation (AWDx flag not cleared by software) Conversion1 Conversion2 Conversion3 Conversion4 Conversion5 Conversion6 Conversion7 STATE inside outside inside outside outside outside inside EOC FLAG not cleared by S/W AWDx FLAG ADCy_AWDx_OUT - Converting regular channels 1,2,3,4,5,6,7 - Regular channels 1,2,3,4,5,6,7 are all guarded MS31026V1 Figure 128.
Page 661
RM0440 Analog-to-digital converters (ADC) Analog watchdog threshold control LTx[11:0] and HTx[11:0] can be changed when an analog-to-digital conversion is ongoing (that is between the start of conversion and the end of conversion of the ADC internal state). If LTx[11:0] and HTx[11:0] are updated during the ADC conversion of the ADC guarded channel, the watchdog function is masked for this conversion.
Analog-to-digital converters (ADC) RM0440 Figure 130. 20-bit to 16-bit result truncation Raw 20-bit data Shifting Truncation and rounding MS34453V1 Figure 131 gives a numerical example of the processing, from a raw 20-bit accumulated data to the final 16-bit result. Figure 131. Numerical example with 5-bit shift and rounding Raw 20-bit data Final result after 5-bit shift and rounding to nearest...
Page 663
RM0440 Analog-to-digital converters (ADC) conversions, with an equivalent delay equal to N x T = N x (t ). The flags are CONV SMPL set as follow: • The end of the sampling phase (EOSMP) is set after each sampling phase •...
Analog-to-digital converters (ADC) RM0440 If the TROVS bit is set, the content of the DISCEN bit is ignored and considered as 1. Figure 132. Triggered regular oversampling mode (TROVS bit = 1) Trigger Trigger CONT=0 DISCEN = 1 TROVS = 0 Ch(N) Ch(N) Ch(N)
Analog-to-digital converters (ADC) RM0440 Triggered regular oversampling with injected conversions It is possible to have triggered regular mode with injected conversions. In this case, the injected mode oversampling mode must be disabled, and the ROVSM bit is ignored (resumed mode is forced). The JOVSE bit must be reset. The behavior is represented on Figure 135 below.
RM0440 Analog-to-digital converters (ADC) Combined modes summary Table 173 below summarizes all combinations, including modes not supported. Table 173. Oversampler operating modes summary Oversampler mode Regular Injected Triggered Oversampling Oversampling ROVSM Regular mode Comment ROVSE JOVSE 0 = continued TROVS 1 = resumed Regular continued mode Not supported...
Page 668
Analog-to-digital converters (ADC) RM0440 In regular simultaneous or interleaved modes: once the user sets bit ADSTART or bit ADSTP of the master ADC, the corresponding bit of the slave ADC is also automatically set. However, bit ADSTART or bit ADSTP of the slave ADC is not necessary cleared at the same time as the master ADC bit.
Analog-to-digital converters (ADC) RM0440 Injected simultaneous mode This mode is selected by programming bits DUAL[4:0]=00101 This mode converts an injected group of channels. The external trigger source comes from the injected group multiplexer of the master ADC (selected by the JEXTSEL bits in the ADC_JSQR register).
Page 671
RM0440 Analog-to-digital converters (ADC) ongoing regular sequence and the associated delay phases are ignored. There is the same behavior for regular sequences occurring on the slave ADC. Regular simultaneous mode with independent injected This mode is selected by programming bits DUAL[4:0] = 00110. This mode is performed on a regular group of channels.
Analog-to-digital converters (ADC) RM0440 Figure 139. Regular simultaneous mode on 16 channels: dual ADC mode CH16 MASTER ADC SLAVE ADC CH16 CH14 CH13 CH12 Trigger End of regular sequence on MASTER and SLAVE ADC Sampling Conversion ai16054b If DISCEN=1 then each “n” simultaneous conversions of the regular sequence require a regular trigger event to occur (“n”...
RM0440 Analog-to-digital converters (ADC) conversion if the complementary ADC is still sampling its input (only one ADC can sample the input signal at a given time). • The minimum possible DELAY is 1 to ensure that there is at least one cycle time between the opening of the analog switch of the master ADC sampling phase and the closing of the analog switch of the slave ADC sampling phase.
Analog-to-digital converters (ADC) RM0440 Figure 141. Interleaved mode on 1 channel in single conversion mode: dual ADC mode 0.5 ADCCLK 0.5 ADCCLK cycle cycle MASTER ADC SLAVE ADC Trigger 4 ADCCLK End of conversion on 4 ADCCLK End of conversion on cycles master and slave ADC cycles...
RM0440 Analog-to-digital converters (ADC) When the 1st trigger occurs, all injected master ADC channels in the group are converted. When the 2nd trigger occurs, all injected slave ADC channels in the group are converted. And so on. A JEOS interrupt, if enabled, is generated after all injected channels of the master ADC in the group have been converted.
Analog-to-digital converters (ADC) RM0440 If the injected discontinuous mode is enabled for both master and slave ADCs: • When the 1st trigger occurs, the first injected channel of the master ADC is converted. • When the 2nd trigger occurs, the first injected channel of the slave ADC is converted. •...
RM0440 Analog-to-digital converters (ADC) Note: In combined regular simultaneous + alternate trigger mode, one must convert sequences with the same length or ensure that the interval between triggers is longer than the long conversion time of the 2 sequences. Otherwise, the ADC with the shortest sequence may restart while the ADC with the longest sequence is completing the previous conversions.
RM0440 Analog-to-digital converters (ADC) DMA requests in dual ADC mode In all dual ADC modes, it is possible to use two DMA channels (one for the master, one for the slave) to transfer the data, like in single mode (refer to Figure 150: DMA Requests in regular simultaneous mode when MDMA=0b00).
Analog-to-digital converters (ADC) RM0440 Figure 151. DMA requests in regular simultaneous mode when MDMA=0b10 Trigger Trigger Trigger Trigger ADC Master regular ADC Slave EOC ADC Slave regular ADC Slave EOC DMA request from ADC Master DMA request from ADC Slave Configuration where each sequence contains only one conversion MSv31033V2 Figure 152.
Page 681
RM0440 Analog-to-digital converters (ADC) Note: When using MDMA mode, the user must take care to configure properly the duration of the master and slave conversions so that a DMA request is generated and served for reading both data (master + slave) before a new conversion is available. •...
To improve the accuracy of the temperature sensor measurement, calibration values are stored in system memory for each device by ST during production. During the manufacturing process, the calibration data of the temperature sensor and the internal voltage reference are stored in the system memory area.
RM0440 Analog-to-digital converters (ADC) Where: • TS_CAL2 is the temperature sensor calibration value acquired at TS_CAL2_TEMP. • TS_CAL1 is the temperature sensor calibration value acquired at TS_CAL1_TEMP. • TS_DATA is the actual temperature sensor output value converted by ADC. Refer to the device datasheet for more information about TS_CAL1 and TS_CAL2 calibration points.
Analog-to-digital converters (ADC) RM0440 21.4.33 Monitoring the internal voltage reference It is possible to monitor the internal voltage reference (V ) to have a reference point for REFINT evaluating the ADC V voltage level. REF+ The internal reference voltage (V ) is internally connected to ADC1_INP18, REFINT ADC3_INP18, ADC4_INP18 and ADC5_INP18.
RM0440 Analog-to-digital converters (ADC) By replacing V by the formula provided above, the absolute voltage value is given by REF+ the following formula × VREFINT_CAL ADC_DATA × DDA_Charac -------------------------------------------------------------------------------------------------------------------- - CHANNELx × VREFINT_DATA FULL_SCALE For applications where V is known and ADC converted values are right-aligned, the absolute voltage value can be obtained by using the following formula: ------------------------------------ - ×...
Page 686
Analog-to-digital converters (ADC) RM0440 Table 174. ADC interrupts per each ADC (continued) Interrupt event Event flag Enable control bit End of sequence of conversions of an injected group JEOS JEOSIE Analog watchdog 1 status bit is set AWD1 AWD1IE Analog watchdog 2 status bit is set AWD2 AWD2IE Analog watchdog 3 status bit is set...
Page 687
RM0440 Analog-to-digital converters (ADC) 21.6 ADC registers (for each ADC) Refer to Section 1.2 on page 72 for a list of abbreviations used in register descriptions. 21.6.1 ADC interrupt and status register (ADC_ISR) Address offset: 0x00 Reset value: 0x0000 0000 Res.
Page 688
Analog-to-digital converters (ADC) RM0440 Bit 5 JEOC: Injected channel end of conversion flag This bit is set by hardware at the end of each injected conversion of a channel when a new data is available in the corresponding ADC_JDRy register. It is cleared by software writing 1 to it or by reading the corresponding ADC_JDRy register 0: Injected channel conversion not complete (or the flag event was already acknowledged and cleared by software)
Page 690
Analog-to-digital converters (ADC) RM0440 Bit 5 JEOCIE: End of injected conversion interrupt enable This bit is set and cleared by software to enable/disable the end of an injected conversion interrupt. 0: JEOC interrupt disabled. 1: JEOC interrupt enabled. An interrupt is generated when the JEOC bit is set. Note: The software is allowed to write this bit only when JADSTART = 0 (which ensures that no injected conversion is ongoing).
Page 692
Analog-to-digital converters (ADC) RM0440 Bits 27:6 Reserved, must be kept at reset value. Bit 5 JADSTP: ADC stop of injected conversion command This bit is set by software to stop and discard an ongoing injected conversion (JADSTP Command). It is cleared by hardware when the conversion is effectively discarded and the ADC injected sequence and triggers can be re-configured.
Page 693
RM0440 Analog-to-digital converters (ADC) Bit 2 ADSTART: ADC start of regular conversion This bit is set by software to start ADC conversion of regular channels. Depending on the configuration bits EXTEN[1:0], a conversion will start immediately (software trigger configuration) or once a regular hardware trigger event occurs (hardware trigger configuration).
Page 694
Analog-to-digital converters (ADC) RM0440 21.6.4 ADC configuration register (ADC_CFGR) Address offset: 0x0C Reset value: 0x8000 0000 JAWD1 AWD1 AWD1S JDISC DISC JQDIS AWD1CH[4:0] JAUTO DISCNUM[2:0] EXTSE EXTSE EXTSE EXTSE EXTSE ALIGN CONT EXTEN[1:0] RES[1:0] Res. Bit 31 JQDIS: Injected Queue disable These bits are set and cleared by software to disable the Injected Queue mechanism : 0: Injected Queue enabled 1: Injected Queue disabled...
Page 695
RM0440 Analog-to-digital converters (ADC) Bit 24 JAWD1EN: Analog watchdog 1 enable on injected channels This bit is set and cleared by software 0: Analog watchdog 1 disabled on injected channels 1: Analog watchdog 1 enabled on injected channels Note: The software is allowed to write this bit only when JADSTART=0 (which ensures that no injected conversion is ongoing).
Page 696
Analog-to-digital converters (ADC) RM0440 Bits 19:17 DISCNUM[2:0]: Discontinuous mode channel count These bits are written by software to define the number of regular channels to be converted in discontinuous mode, after receiving an external trigger. 000: 1 channel 001: 2 channels 111: 8 channels Note: The software is allowed to write these bits only when ADSTART=0 (which ensures that no regular conversion is ongoing).
Page 697
RM0440 Analog-to-digital converters (ADC) Bit 13 CONT: Single / continuous conversion mode for regular conversions This bit is set and cleared by software. If it is set, regular conversion takes place continuously until it is cleared. 0: Single conversion mode 1: Continuous conversion mode Note: It is not possible to have both discontinuous mode and continuous mode enabled: it is forbidden to set both DISCEN=1 and CONT=1.
Page 698
Analog-to-digital converters (ADC) RM0440 Bit 2 Reserved, must be kept at reset value. Bit 1 DMACFG: Direct memory access configuration This bit is set and cleared by software to select between two DMA modes of operation and is effective only when DMAEN=1. 0: DMA One Shot mode selected 1: DMA Circular mode selected For more details, refer to...
Page 699
RM0440 Analog-to-digital converters (ADC) Bits 31:28 Reserved, must be kept at reset value. Bit 27 SMPTRIG: Sampling time control trigger mode This bit is set and cleared by software to enable the sampling time control trigger mode. 0: Sampling time control trigger mode disabled 1: Sampling time control trigger mode enabled The sampling time starts on the trigger rising edge, and the conversion on the trigger falling edge.
Page 700
Analog-to-digital converters (ADC) RM0440 Bit 9 TROVS: Triggered Regular Oversampling This bit is set and cleared by software to enable triggered oversampling 0: All oversampled conversions for a channel are done consecutively following a trigger 1: Each oversampled conversion for a channel needs a new trigger Note: The software is allowed to write this bit only when ADSTART=0 (which ensures that no conversion is ongoing).
Page 701
RM0440 Analog-to-digital converters (ADC) 21.6.6 ADC sample time register 1 (ADC_SMPR1) Address offset: 0x14 Reset value: 0x0000 0000 SMPPL Res. SMP9[2:0] SMP8[2:0] SMP7[2:0] SMP6[2:0] SMP5[2:1] SMP5[ SMP4[2:0] SMP3[2:0] SMP2[2:0] SMP1[2:0] SMP0[2:0] Bits 31:30 SMPPLUS: Addition of one clock cycle to the sampling time 1: 2.5 ADC clock cycle sampling time becomes 3.5 ADC clock cycles for the ADC_SMPR1 and ADC_SMPR2 registers.
Page 702
Analog-to-digital converters (ADC) RM0440 Bits 31:27 Reserved, must be kept at reset value. Bits 26:0 SMP[18:10][2:0]: Channel x sampling time selection These bits are written by software to select the sampling time individually for each channel. During sampling cycles, the channel selection bits must remain unchanged. 000: 2.5 ADC clock cycles 001: 6.5 ADC clock cycles 010: 12.5 ADC clock cycles...
Page 703
RM0440 Analog-to-digital converters (ADC) Bits 15: Reserved, must be kept at reset value. Bits 14:12 AWDFILT: Analog watchdog filtering parameter This bit is set and cleared by software. 000: No filtering 001: two consecutive detection generates an AWDx flag or an interrupt 111: Eight consecutive detection generates an AWDx flag or an interrupt Note: The software is allowed to write this bit only when ADSTART=0 (which ensures that no conversion is ongoing).
Page 704
Analog-to-digital converters (ADC) RM0440 21.6.10 ADC watchdog threshold register 3 (ADC_TR3) Address offset: 0x28 Reset value: 0x00FF 0000 Res. Res. Res. Res. Res. Res. Res. Res. HT3[7:0] Res. Res. Res. Res. Res. Res. Res. Res. LT3[7:0] Bits 31:24 Reserved, must be kept at reset value. Bits 23:16 HT3[7:0]: Analog watchdog 3 higher threshold These bits are written by software to define the higher threshold for the analog watchdog 3.
Page 705
RM0440 Analog-to-digital converters (ADC) Bits 22:18 SQ3[4:0]: 3rd conversion in regular sequence These bits are written by software with the channel number (0 to 18) assigned as the 3rd in the regular conversion sequence. Note: The software is allowed to write these bits only when ADSTART=0 (which ensures that no regular conversion is ongoing).
Page 706
Analog-to-digital converters (ADC) RM0440 Bits 31:29 Reserved, must be kept at reset value. Bits 28:24 SQ9[4:0]: 9th conversion in regular sequence These bits are written by software with the channel number (0 to 18) assigned as the 9th in the regular conversion sequence. Note: The software is allowed to write these bits only when ADSTART=0 (which ensures that no regular conversion is ongoing).
Page 707
RM0440 Analog-to-digital converters (ADC) Bits 31:29 Reserved, must be kept at reset value. Bits 28:24 SQ14[4:0]: 14th conversion in regular sequence These bits are written by software with the channel number (0 to 18) assigned as the 14th in the regular conversion sequence. Note: The software is allowed to write these bits only when ADSTART=0 (which ensures that no regular conversion is ongoing).
Page 708
Analog-to-digital converters (ADC) RM0440 Bits 31:11 Reserved, must be kept at reset value. Bits 10:6 SQ16[4:0]: 16th conversion in regular sequence These bits are written by software with the channel number (0 to 18) assigned as the 16th in the regular conversion sequence. Note: The software is allowed to write these bits only when ADSTART=0 (which ensures that no regular conversion is ongoing).
Page 709
RM0440 Analog-to-digital converters (ADC) Bits 31:27 JSQ4[4:0]: 4th conversion in the injected sequence These bits are written by software with the channel number (0 to 18) assigned as the 4th in the injected conversion sequence.c Note: The software is allowed to write these bits only when JADSTART=0 (which ensures that no injected conversion is ongoing).
Page 710
Analog-to-digital converters (ADC) RM0440 Bits 8:7 JEXTEN[1:0]: External Trigger Enable and Polarity Selection for injected channels These bits are set and cleared by software to select the external trigger polarity and enable the trigger of an injected group. 00: If JQDIS=0 (queue enabled), Hardware and software trigger detection disabled 00: If JQDIS=1 (queue disabled), Hardware trigger detection disabled (conversions can be launched by software) 01: Hardware trigger detection on the rising edge...
Page 712
Analog-to-digital converters (ADC) RM0440 Bit 24 OFFSETPOS: Positive offset This bit is set and cleared by software to enable the positive offset. 0: Negative offset 1: Positive offset Note: The software is allowed to write these bits only when ADSTART=0 and JADSTART=0 (which ensures that no conversion is ongoing).
Page 713
RM0440 Analog-to-digital converters (ADC) 21.6.19 ADC analog watchdog 2 configuration register (ADC_AWD2CR) Address offset: 0xA0 Reset value: 0x0000 0000 Res. Res. Res. Res. Res. Res. Res. Res. Res. Res. Res. Res. Res. AWD2CH[18:16] AWD2CH[15:0] Bits 31:19 Reserved, must be kept at reset value. Bits 18:0 AWD2CH[18:0]: Analog watchdog 2 channel selection These bits are set and cleared by software.
Page 714
Analog-to-digital converters (ADC) RM0440 Bits 31:19 Reserved, must be kept at reset value. Bits 18:0 AWD3CH[18:0]: Analog watchdog 3 channel selection These bits are set and cleared by software. They enable and select the input channels to be guarded by the analog watchdog 3. AWD3CH[i] = 0: ADC analog input channel i is not monitored by AWD3 AWD3CH[i] = 1: ADC analog input channel i is monitored by AWD3 When AWD3CH[18:0] = 000..0, the analog watchdog 3 is disabled...
Page 715
RM0440 Analog-to-digital converters (ADC) 21.6.22 ADC calibration factors (ADC_CALFACT) Address offset: 0xB4 Reset value: 0x0000 0000 Res. Res. Res. Res. Res. Res. Res. Res. Res. CALFACT_D[6:0] Res. Res. Res. Res. Res. Res. Res. Res. Res. CALFACT_S[6:0] Bits 31:23 Reserved, must be kept at reset value. Bits 22:16 CALFACT_D[6:0]: Calibration Factors in differential mode These bits are written by hardware or by software.
Page 716
Analog-to-digital converters (ADC) RM0440 Bits 31:14 Reserved, must be kept at reset value. Bits 13:0 GCOMPCOEFF[13:0]: Gain compensation coefficient These bits are set and cleared by software to program the gain compensation coefficient. 00 1000 0000 0000: gain factor of 0.5 01 0000 0000 0000: gain factor of 1 10 0000 0000 0000: gain factor of 2 11 0000 0000 0000: gain factor of 3...
Page 717
RM0440 Analog-to-digital converters (ADC) Bit 22 JEOS_SLV: End of injected sequence flag of the slave ADC This bit is a copy of the JEOS bit in the corresponding ADC_ISR register. Bit 21 JEOC_SLV: End of injected conversion flag of the slave ADC This bit is a copy of the JEOC bit in the corresponding ADC_ISR register.
Page 718
Analog-to-digital converters (ADC) RM0440 21.7.2 ADCx common control register (ADCx_CCR) (x=12 or 345) Address offset: 0x08 (this offset address is relative to the master ADC base address + 0x300) Reset value: 0x0000 0000 One interface controls ADC1 and ADC2, while the other interface controls ADC3, ADC4 and ADC5.
Page 719
RM0440 Analog-to-digital converters (ADC) Bits 17:16 CKMODE[1:0]: ADC clock mode These bits are set and cleared by software to define the ADC clock scheme (which is common to both master and slave ADCs): 00: adc_ker_ck (x=123) (Asynchronous clock mode), generated at product level (refer to Section 6: Reset and clock control (RCC)) 01: adc_hclk/1 (Synchronous clock mode).
Analog-to-digital converters (ADC) RM0440 Bits 11:8 DELAY: Delay between 2 sampling phases These bits are set and cleared by software. These bits are used in dual interleaved modes. Refer to Table 175 for the value of ADC resolution versus DELAY bits values. Note: The software is allowed to write these bits only when the ADCs are disabled (ADCAL=0, JADSTART=0, ADSTART=0, ADSTP=0, ADDIS=0 and ADEN=0).
RM0440 Analog-to-digital converters (ADC) 21.7.3 ADCx common regular data register for dual mode (ADCx_CDR) (x=12 or 345) Address offset: 0x0C (this offset address is relative to the master ADC base address + 0x300) Reset value: 0x0000 0000 One interface controls ADC1 and ADC2, while the other interface controls ADC3, ADC4 and ADC5.
Analog-to-digital converters (ADC) RM0440 Table 177. ADC register map and reset values for each ADC (offset=0x000 for master ADC, 0x100 for slave ADC) (continued) Offset Register DIFSEL[18:0] ADC_DIFSEL 0xB0 Reset value CALFACT_D[6:0] CALFACT_S[6:0] ADC_CALFACT 0xB4 Reset value GCOMP[13:0] ADC_GCOMP 0xC0 Reset value Table 178.
Page 725
RM0440 Digital-to-analog converter (DAC) Digital-to-analog converter (DAC) 22.1 Introduction The DAC module is a 12-bit, voltage output digital-to-analog converter. The DAC can be configured in 8- or 12-bit mode and may be used in conjunction with the DMA controller. In 12-bit mode, the data could be left- or right-aligned.
Digital-to-analog converter (DAC) RM0440 22.3 DAC implementation Table 179. DAC implementation DAC features DAC1 DAC2 DAC3 DAC4 Dual channel Output buffer DAC1_OUT1 on PA4 I/O connection DAC2_OUT1 on PA6 No connection to a GPIO DAC1_OUT2 on PA5 Maximum sampling 1MSPS 15MSPS time Autonomous mode...
Digital-to-analog converter (DAC) RM0440 1. MODEx bits in the DAC_MCR control the output mode and allow switching between the Normal mode in buffer/unbuffered configuration and the Sample and hold mode. 2. Refer to Section 22.3: DAC implementation for channel2 availability. 3.
RM0440 Digital-to-analog converter (DAC) Table 181. DAC input/output signals (continued) Internal signal name Signal type Description Analog dac_out1 DAC channel1 output for on-chip peripherals output Analog dac_out2 DAC channel2 output for on-chip peripherals output Table 182. DAC1 interconnection Signal name Source Source type ck_lsi or ck_lse (selected in...
Digital-to-analog converter (DAC) RM0440 Table 182. DAC1 interconnection (continued) Signal name Source Source type dac_inc_chx_trg13 (x = 1, 2) hrtim_dac_step_trg5 Internal signal from on-chip timers dac_inc_chx_trg14 (x = 1, 2) hrtim_dac_step_trg6 Internal signal from on-chip timers Table 183. DAC2 interconnection Signal name Source Source type...
RM0440 Digital-to-analog converter (DAC) Table 183. DAC2 interconnection (continued) Signal name Source Source type dac_inc_ch1_trg13 hrtim_dac_step_trg5 Internal signal from on-chip timers dac_inc_ch1_trg14 hrtim_dac_step_trg6 Internal signal from on-chip timers Table 184. DAC3 interconnection Signal name Source Source type ck_lsi or ck_lse (selected in the LSI or LSE clock selected in the dac_hold_ck RCC)
Digital-to-analog converter (DAC) RM0440 Table 185. DAC4 interconnection (continued) Signal name Source Source type Internal signal from on-chip dac_inc_chx_trg13 (x = 1, 2) hrtim_dac_step_trg5 timers Internal signal from on-chip dac_inc_chx_trg14 (x = 1, 2) hrtim_dac_step_trg6 timers 22.4.3 DAC channel enable Each DAC channel can be powered on by setting its corresponding ENx bit in the DAC_CR register.
RM0440 Digital-to-analog converter (DAC) • Dual DAC channels (when available) There are three possibilities: – 8-bit right alignment: data for DAC channel1 to be loaded into the DAC_DHR8RD [7:0] bits (stored into the DHR1[11:4] bits) and data for DAC channel2 to be loaded into the DAC_DHR8RD [15:8] bits (stored into the DHR2[11:4] bits) –...
Digital-to-analog converter (DAC) RM0440 Table 186. Data format (case of 12-bit data) (continued) DATA written to DHRx SINFORMATx bit DATA transfered to DORx register register 0x000 0x800 0xFFF 0x7FF 0x800 0x000 22.4.5 DAC conversion The DAC_DORx cannot be written directly and any data transfer to the DAC channelx must be performed by loading the DAC_DHRx register (write operation to DAC_DHR8Rx, DAC_DHR12Lx, DAC_DHR12Rx, DAC_DHR8RD, DAC_DHR12RD or DAC_DHR12LD).
RM0440 Digital-to-analog converter (DAC) Figure 159. Timing diagram for conversion with trigger disabled TEN = 0 Bus clock 0x1AC Output voltage available on 0x1AC DAC_OUT pin tSETTLING MSv45319V2 22.4.6 DAC output voltage Digital inputs are converted to output voltages on a linear conversion between 0 and V REF+ The analog output voltages on each DAC channel pin are determined by the following equation:...
Page 738
Digital-to-analog converter (DAC) RM0440 22.4.8 DMA requests Each DAC channel has a DMA capability. Two DMA channels are used to service DAC channel DMA requests. When an external trigger (but not a software trigger) occurs while the DMAENx bit is set, the value of the DAC_DHRx register is transferred into the DAC_DORx register when the transfer is complete, and a DMA request is generated.
RM0440 Digital-to-analog converter (DAC) The following conditions must be met to change from Double data to single data mode or vice versa: • The DAC must be disabled. • DMAEN bit must be cleared (ENx=0 and DMAENx=0). 22.4.9 DAC noise generation In order to generate a variable-amplitude pseudonoise, an LFSR (linear feedback shift register) is available.
Digital-to-analog converter (DAC) RM0440 Note: The DAC trigger must be enabled for noise generation by setting the TENx bit in the DAC_CR register. 22.4.10 DAC triangle-wave generation It is possible to add a small-amplitude triangular waveform on a DC or slowly varying signal. DAC triangle-wave generation is selected by setting WAVEx[1:0] to 10”.
RM0440 Digital-to-analog converter (DAC) 22.4.11 DAC sawtooth wave generation The DAC can generate a sawtooth waveform. Specific register settings for the initial value, increment value and direction control are required: • DAC sawtooth wave generation is selected by setting WAVEx[1:0] to 11 in the DAC_CR register.
Digital-to-analog converter (DAC) RM0440 The STRSTTRIG signal has higher priority than STINCTRIG. Thetrigger signal cannot be faster than the DAC_DORx update rate defined in the Table 187: HFSEL description. If STINCTRIG is asserted faster than the allowed data update rate, the STINCTRIG trigger is ignored.
RM0440 Digital-to-analog converter (DAC) Sample and hold mode In Sample and hold mode, the DAC core converts data on a triggered conversion, and then holds the converted voltage on a capacitor. When not converting, the DAC cores and buffer are completely turned off between samples and the DAC output is tri-stated, therefore reducing the overall power consumption.
Digital-to-analog converter (DAC) RM0440 Example of the sample and refresh time calculation with output buffer on The values used in the example below are provided as indication only. Please refer to the product datasheet for product data. = 100 nF = 3.0 V Sampling phase: = 7 μs + (10 * 2000 * 100 * 10...
RM0440 Digital-to-analog converter (DAC) To disabled the output buffer, MODEx[2:0] bits in DAC_MCR register must be set to: • 110: DAC is connected to external pin and to on chip peripherals • 111: DAC is connected to on chip peripherals When MODEx[2:0] bits are equal to 111, an internal capacitor, C holds the voltage Lint...
Page 746
Digital-to-analog converter (DAC) RM0440 Two calibration techniques are provided: • Factory trimming (default setting) The DAC buffer offset is factory trimmed. The default value of OTRIMx[4:0] bits in DAC_CCR register is the factory trimming value and it is loaded once DAC digital interface is reset.
Page 747
RM0440 Digital-to-analog converter (DAC) 22.4.14 Dual DAC channel conversion modes (if dual channels are available) To efficiently use the bus bandwidth in applications that require the two DAC channels at the same time, three dual registers are implemented: DHR8RD, DHR12RD and DHR12LD. A unique register access is then required to drive both DAC channels at the same time.
Page 748
Digital-to-analog converter (DAC) RM0440 Independent trigger with different LFSR generation To configure the DAC in this conversion mode, the following sequence is required: Set the two DAC channel trigger enable bits TEN1 and TEN2. Configure different trigger sources by setting different values in the TSEL1 and TSEL2 bitfields.
Page 749
RM0440 Digital-to-analog converter (DAC) transferred into DAC_DOR1 (three dac_hclk clock cycles later). The DAC channel1 triangle counter is then updated. When a DAC channel2 trigger arrives, the DAC channel2 triangle counter, with a triangle amplitude configured by MAMP2[3:0], is added to the DHR2 register and the sum is transferred into DAC_DOR2 (three dac_hclk clock cycles later).
Page 750
Digital-to-analog converter (DAC) RM0440 When a trigger arrives, the DHR1 and DHR2 registers are transferred into DAC_DOR1 and DAC_DOR2, respectively (after three dac_hclk clock cycles). Simultaneous trigger with single LFSR generation To configure the DAC in this conversion mode, the following sequence is required: Set the two DAC channel trigger enable bits TEN1 and TEN2.
Page 751
RM0440 Digital-to-analog converter (DAC) At the same time, the DAC channel2 triangle counter, with the same triangle amplitude, is added to the DHR2 register and the sum is transferred into DAC_DOR2 (three dac_hclk clock cycles later). The DAC channel2 triangle counter is then updated. Simultaneous trigger with different triangle generation To configure the DAC in this conversion mode, the following sequence is required: Set the two DAC channel trigger enable bits TEN1 and TEN2...
Digital-to-analog converter (DAC) RM0440 22.5 DAC low-power modes Table 190. Effect of low-power modes on DAC Mode Description Sleep No effect, DAC used with DMA. Low-power run No effect. Low-power sleep No effect. DAC used with DMA. DAC remains active with a static value, if Sample and hold mode is Stop 0 / Stop 1 selected using LSI/LSE clock Standby...
Page 753
RM0440 Digital-to-analog converter (DAC) 22.7 DAC registers Refer to Section 1 on page 72 for a list of abbreviations used in register descriptions. The peripheral registers have to be accessed by words (32-bit). 22.7.1 DAC control register (DAC_CR) Address offset: 0x00 Reset value: 0x0000 0000 DMAU DMAE...
Page 754
Digital-to-analog converter (DAC) RM0440 Bits 27:24 MAMP2[3:0]: DAC channel2 mask/amplitude selector These bits are written by software to select mask in wave generation mode or amplitude in triangle generation mode. 0000: Unmask bit0 of LFSR/ triangle amplitude equal to 1 0001: Unmask bits[1:0] of LFSR/ triangle amplitude equal to 3 0010: Unmask bits[2:0] of LFSR/ triangle amplitude equal to 7 0011: Unmask bits[3:0] of LFSR/ triangle amplitude equal to 15...
Page 755
RM0440 Digital-to-analog converter (DAC) Bit 16 EN2: DAC channel2 enable This bit is set and cleared by software to enable/disable DAC channel2. 0: DAC channel2 disabled 1: DAC channel2 enabled Note: These bits are available only on dual-channel DACs. Refer to Section 22.3: DAC implementation.
Page 756
Digital-to-analog converter (DAC) RM0440 Bits 5:2 TSEL1[3:0]: DAC channel1 trigger selection These bits select the external event used to trigger DAC channel1 0000: SWTRIG1 0001: dac_ch1_trig1 0010: dac_ch1_trig2 1111: dac_ch1_trig15 Refer to the trigger selection tables in Section 22.4.2: DAC pins and internal signals details on trigger configuration and mapping.
Page 757
RM0440 Digital-to-analog converter (DAC) Bit 15:2 Reserved, must be kept at reset value. Bit 1 SWTRIG2: DAC channel2 software trigger This bit is set by software to trigger the DAC in software trigger mode. 0: No trigger 1: Trigger Note: This bit is cleared by hardware (one dac_hclk clock cycle later) once the DAC_DHR2 register value has been loaded into the DAC_DOR2 register.
Page 758
Digital-to-analog converter (DAC) RM0440 22.7.4 DAC channel1 12-bit left aligned data holding register (DAC_DHR12L1) Address offset: 0x0C Reset value: 0x0000 0000 DACC1DHRB[11:0] Res. Res. Res. Res. DACC1DHR[11:0] Res. Res. Res. Res. Bits 31:20 DACC1DHRB[11:0]: DAC channel1 12-bit left-aligned data B These bits are written by software.
Page 759
RM0440 Digital-to-analog converter (DAC) 22.7.6 DAC channel2 12-bit right aligned data holding register (DAC_DHR12R2) This register is available only on dual-channel DACs. Refer to Section 22.3: DAC implementation. Address offset: 0x14 Reset value: 0x0000 0000 Res. Res. Res. Res. DACC2DHRB[11:0] Res.
Page 760
Digital-to-analog converter (DAC) RM0440 22.7.8 DAC channel2 8-bit right-aligned data holding register (DAC_DHR8R2) This register is available only on dual-channel DACs. Refer to Section 22.3: DAC implementation. Address offset: 0x1C Reset value: 0x0000 0000 Res. Res. Res. Res. Res. Res. Res.
Page 761
RM0440 Digital-to-analog converter (DAC) 22.7.10 Dual DAC 12-bit left aligned data holding register (DAC_DHR12LD) Address offset: 0x24 Reset value: 0x0000 0000 DACC2DHR[11:0] Res. Res. Res. Res. DACC1DHR[11:0] Res. Res. Res. Res. Bits 31:20 DACC2DHR[11:0]: DAC channel2 12-bit left-aligned data These bits are written by software which specifies 12-bit data for DAC channel2. Bits 19:16 Reserved, must be kept at reset value.
Page 762
Digital-to-analog converter (DAC) RM0440 22.7.12 DAC channel1 data output register (DAC_DOR1) Address offset: 0x2C Reset value: 0x0000 0000 Res. Res. Res. Res. DACC1DORB[11:0] Res. Res. Res. Res. DACC1DOR[11:0] Bits 31:28 Reserved, must be kept at reset value. Bits 27:16 DACC1DORB[11:0]: DAC channel1 data output These bits are read-only.
Page 764
Digital-to-analog converter (DAC) RM0440 Bits 26:16 Reserved, must be kept at reset value. Bit 15 BWST1: DAC channel1 busy writing sample time flag This bit is systematically set just after Sample and hold mode enable and is set each time the software writes the register DAC_SHSR1, It is cleared by hardware when the write operation of DAC_SHSR1 is complete.
Page 766
Digital-to-analog converter (DAC) RM0440 Bits 15:14 HFSEL[1:0]: High frequency interface mode selection 00: High frequency interface mode disabled 01: High frequency interface mode compatible to AHB>80 MHz enabled 10: High frequency interface mode compatible to AHB>160 MHz enabled 11: Reserved Bits 13:10 Reserved, must be kept at reset value.
Page 767
RM0440 Digital-to-analog converter (DAC) Bits 31:10 Reserved, must be kept at reset value. Bits 9:0 TSAMPLE1[9:0]: DAC channel1 sample time (only valid in Sample and hold mode) These bits can be written when the DAC channel1 is disabled or also during normal operation. in the latter case, the write can be done only when BWST1 of DAC_SR register is low, If BWST1=1, the write operation is ignored.
Page 768
Digital-to-analog converter (DAC) RM0440 Bits 31:26 Reserved, must be kept at reset value. Bits 25:16 THOLD2[9:0]: DAC channel2 hold time (only valid in Sample and hold mode). Hold time= (THOLD[9:0]) x LSI/LSE clock period Note: This register can be modified only when EN2=0. These bits are available only on dual-channel DACs.
Page 769
RM0440 Digital-to-analog converter (DAC) 22.7.21 DAC channel1 sawtooth register (DAC_STR1) Address offset: 0x58 Reset value: 0x0000 0000 STINCDATA1[15:0] STDIR Res. Res. Res. STRSTDATA1[11:0] Bits 31:16 STINCDATA1[15:0]: DAC channel1 sawtooth increment value (12.4 bit format) Bits 15:13 Reserved, must be kept at reset value. Bit 12 STDIR1: DAC channel1 sawtooth direction setting This bit is written by software to select the direction of Sawtooth step direction 0: Decrement...
Voltage reference buffer (VREFBUF) RM0440 Voltage reference buffer (VREFBUF) 23.1 Introduction The devices embed a voltage reference buffer which can be used as voltage reference for ADCs, DACs and also as voltage reference for external components through the VREF+ pin. When the VREF+ pin is double-bonded with VDDA pin in a package, the voltage reference buffer is not available and must be kept disabled (refer to datasheet for packages pinout description).
Page 775
23.3 VREFBUF trimming The VREFBUF output voltage is factory-calibrated by ST. At reset, and each time the VRS setting is changed, the calibration data is automatically loaded to the TRIM register. Optionally user can trim the output voltage by changing the TRIM register bits directly. In this case, the VRS setting will have no more effect on the TRIM register until the device is reset.
Page 778
Comparator (COMP) RM0440 Comparator (COMP) 24.1 COMP introduction The device embeds up to seven ultra-fast analog comparators. The comparators can be used for a variety of functions including: • Wake-up from low-power mode triggered by an analog signal, • Analog signal conditioning, •...
RM0440 Comparator (COMP) 24.3.2 COMP pins and internal signals The I/Os used as comparators inputs must be configured in analog mode in the GPIOs registers. The comparator output can be connected to the I/Os using the alternate function channel given in “Alternate function mapping” table in the datasheet. The output can also be internally redirected to a variety of timer input for the following purposes: •...
Comparator (COMP) RM0440 24.3.4 COMP LOCK mechanism The comparators can be used for safety purposes, such as over-current or thermal protection. For applications having specific functional safety requirements, it is necessary to insure that the comparator programming cannot be altered in case of spurious register access or program counter corruption.
RM0440 Comparator (COMP) Figure 170. Comparator output blanking Current limit Current Raw comp output Blanking window Final comp output Comp out Comp out (to TIM_BK …) Blank MS30964V1 Table 197. Blanking sources BLANKSEL COMP1 COMP2 COMP3 COMP4 COMP5 COMP6 COMP7 [2:0] TIM1_OC5 TIM1_OC5...
Page 782
Comparator (COMP) RM0440 Table 198. Comparator behavior in low-power modes (continued) Mode Description Low-power sleep No effect. COMP interrupts cause the device to exit the Low-power sleep mode. No effect on the comparators. Stop Comparator interrupts cause the device to exit the Stop mode. Standby, The COMP registers are powered down and must be reinitialized after exiting Shutdown...
Page 783
RM0440 Comparator (COMP) Bit 31 LOCK: COMP_CxCSR register lock This bit is set by software and cleared by a hardware system reset. It locks the whole content of the comparator x control register COMP_CxCSR[31:0]. When locked, all control bits and flags can be read only but not written.
Comparator (COMP) RM0440 Bits 7:4 INMSEL[3:0]: Comparator x signal select for inverting input This bitfield controlled by software selects the signal for the inverting input COMPx_INM of the comparator x, as shown in Table 196: COMPx inverting input assignment. Bits 3:1 Reserved, must be kept at reset value Bit 0 EN: Comparator x enable This bit controlled by software enables the operation of comparator x: 0: Disable...
Page 785
RM0440 Comparator (COMP) Table 199. COMP register map and reset values (continued) Offset Register COMP_C6CSR 0x14 Reset value COMP_C7CSR 0x18 Reset value Refer to Section 2.2.2: Memory map and register boundary addresses for the register boundary addresses. RM0440 Rev 4 785/2126...
Page 786
Operational amplifiers (OPAMP) RM0440 Operational amplifiers (OPAMP) 25.1 Introduction The devices embed six operational amplifiers with two inputs and one output each. The three I/Os can be connected to the external pins, thus enabling any type of external interconnections. The operational amplifiers can be configured internally as a follower, as an amplifier with a non-inverting gain ranging from 2 to 64 or with inverting gain ranging from -1 to -63.
RM0440 Operational amplifiers (OPAMP) The bit OPAEN enables and disables the OPAMP operation. The OPAMP registers configurations must be changed before enabling the OPAEN bit in order to avoid spurious effects on the output. When the output of the operational amplifier is no more needed the operational amplifier can be disabled to save power.
Page 788
Operational amplifiers (OPAMP) RM0440 Table 200. Operational amplifier possible connection (continued) Signal Internal Comment The pin is connected when the OPAMP is ADC2_IN3 OPAMP2_VOUT enabled and OPAMP internal output is ADC2_IN16 disabled. The ADC input is controlled by ADC PB2 (VINM0) OPAMP3_VINM OPAMP3_VOUT or PGA controlled by bits PGA_GAIN and VM_SEL...
RM0440 Operational amplifiers (OPAMP) 25.3.5 OPAMP modes The operational amplifier inputs and outputs are all accessible on terminals. The amplifiers can be used in multiple configuration environments: • Standalone mode (external gain setting mode) • Follower configuration mode • PGA modes Note: The impedance of the signal must be maintained below a level which avoids the input leakage to create significant artifacts (due to a resistive drop in the source).
Operational amplifiers (OPAMP) RM0440 Follower configuration mode The procedure to use the OPAMP in follower mode is presented hereafter. • configure VM_SEL bits as “opamp_out connected to OPAMPx_VINM input”, 11 • configure VP_SEL bits as “GPIO connected to OPAMPx_VINP”, 00 •...
RM0440 Operational amplifiers (OPAMP) Programmable gain amplifier mode The procedure to use the OPAMP as programmable gain amplifier is presented hereafter. • configure VM_SEL bits as “Feedback resistor is connected to OPAMPx_VINM input”, • configure PGA_GAIN bits as “internal Gain 2, 4, 8, 16,32, or 64”, 00000 to 00101 •...
Operational amplifiers (OPAMP) RM0440 Programmable gain amplifier mode with external filtering The procedure to use the OPAMP to amplify the amplitude of an input signal, with an external filtering, is presented hereafter. • configure VM_SEL bits as “Feedback resistor is connected to OPAMPx_VINM input”, •...
RM0440 Operational amplifiers (OPAMP) Programmable gain amplifier, non-inverting with external bias or inverting mode The procedure to use the OPAMP to amplify the amplitude of an input signal with bias voltage for non-inverting mode or inverting mode. • configure VM_SEL bits as “Feedback resistor is connected to OPAMPx_VINM input”, •...
Operational amplifiers (OPAMP) RM0440 Figure 176. PGA mode, non-inverting gain setting (x2/x4/x8/x16/x32/x64) or inverting gain setting (x-1/x-3/x-7/x-15/x-31/x-63) with filtering STM32 VINP0 VINP1 VINP2 opamp_out VINP4 or DACx_CHy VINM1 VINM0 Allows optional low-pass filtering Equivalent to VOUT 1. opamp_out can be redirected internally to an ADC channel by setting OPAINTOEN bit. In this case, the I/O on which is mapped the OPAMPx_VOUT is free and can be used for another purpose.
RM0440 Operational amplifiers (OPAMP) 25.3.7 Calibration The OPAMP offset value is minimized using a trimming circuitry. At startup, the trimming values are initialized with the preset ‘factory’ trimming value. Each operational amplifier can also be trimmed by the user if the OPAMP is used in conditions different from the factory trimming conditions.
Page 796
Operational amplifiers (OPAMP) RM0440 Calibration procedure Here are the steps to perform a full calibration of either one of the operational amplifiers: Set the OPAEN bit in OPAMPx_CSR to 1 to enable the operational amplifier. Set the USERTRIM bit in the OPAMPx_CSR register to 1. Choose a calibration mode (refer to Table 201: Operating modes and calibration).
RM0440 Operational amplifiers (OPAMP) the VPS_SEL and VMS_SEL bit fields in the OPAMP timer controlled mode register. If the TxCMEN bit is cleared, the selection is done using the VP_SEL and VM_SEL bit fields in the OPAMP control/status register. Figure 178. Timer controlled Multiplexer mode CCR6 T1 counter T8 counter...
Page 798
Operational amplifiers (OPAMP) RM0440 25.5 OPAMP registers 25.5.1 OPAMP1 control/status register (OPAMP1_CSR) Address offset: 0x00 Reset value: 0x0000 0000 LOCK Res. TRIMOFFSETN TRIMOFFSETP PGA_GAIN USER FORCE PGA_GAIN CALSEL CALON Res. Res. VM_SEL VP_SEL OPAEN INTOEN TRIM. Bit 31 LOCK: OPAMP1_CSR lock This bit is write-once.
Page 799
RM0440 Operational amplifiers (OPAMP) Bits 18:14 PGA_GAIN: Operational amplifier Programmable amplifier gain value 00000: Non inverting internal gain =2 00001: Non inverting internal gain =4 00010: Non inverting internal gain =8 00011: Non inverting internal gain =16 00100: Non inverting internal gain =32 00101: Non inverting internal gain =64 00110: Not used 00111: Not used...
Page 800
Operational amplifiers (OPAMP) RM0440 Bit 8 OPAINTOEN: Operational amplifier internal output enable. 0: The OPAMP output is connected to the output pin 1: The OPAMP output is connected internally to an ADC channel and disconnected from the output pin Bit 7 OPAHSM: Operational amplifier high-speed mode The operational amplifier must be disable to change this configuration.
Page 801
RM0440 Operational amplifiers (OPAMP) 25.5.2 OPAMP2 control/status register (OPAMP2_CSR) Address offset: 0x04 Reset value: 0x0000 0000 LOCK Res. TRIMOFFSETN TRIMOFFSETP PGA_GAIN USER FORCE PGA_GAIN CALSEL CALON Res. Res. VM_SEL VP_SEL OPAEN INTOEN TRIM. Bit 31 LOCK: OPAMP2_CSR lock This bit is write-once. It is set by software. It can only be cleared by a system reset. This bit is used to configure the OPAMP2_CSR register as read-only.
Page 802
Operational amplifiers (OPAMP) RM0440 Bits 18:14 PGA_GAIN: Operational amplifier Programmable amplifier gain value 00000: Non inverting internal gain =2 00001: Non inverting internal gain =4 00010: Non inverting internal gain =8 00011: Non inverting internal gain =16 00100: Non inverting internal gain =32 00101: Non inverting internal gain =64 00110: Not used 00111: Not used...
Page 803
RM0440 Operational amplifiers (OPAMP) Bit 8 OPAINTOEN: Operational amplifier internal output enable. 0: The OPAMP output is connected to the output pin 1: The OPAMP output is connected internally to an ADC channel and disconnected from the output pin Bit 7 OPAHSM: Operational amplifier high-speed mode The operational amplifier must be disable to change this configuration.
Page 804
Operational amplifiers (OPAMP) RM0440 25.5.3 OPAMP3 control/status register (OPAMP3_CSR) Address offset: 0x08 Reset value: 0x0000 0000 LOCK Res. TRIMOFFSETN TRIMOFFSETP PGA_GAIN USER FORCE PGA_GAIN CALSEL CALON Res. Res. VM_SEL VP_SEL OPAEN INTOEN TRIM. Bit 31 LOCK: OPAMP3_CSR lock This bit is write-once. It is set by software. It can only be cleared by a system reset. This bit is used to configure the OPAMP3_CSR register as read-only.
Page 805
RM0440 Operational amplifiers (OPAMP) Bits 18:14 PGA_GAIN: Operational amplifier Programmable amplifier gain value 00000: Non inverting internal gain =2 00001: Non inverting internal gain =4 00010: Non inverting internal gain =8 00011: Non inverting internal gain =16 00100: Non inverting internal gain =32 00101: Non inverting internal gain =64 00110: Not used 00111: Not used...
Page 806
Operational amplifiers (OPAMP) RM0440 Bit 8 OPAINTOEN: Operational amplifier internal output enable. 0: The OPAMP output is connected to the output pin 1: The OPAMP output is connected internally to an ADC channel and disconnected from the output pin Bit 7 OPAHSM: Operational amplifier high-speed mode The operational amplifier must be disable to change this configuration.
Page 807
RM0440 Operational amplifiers (OPAMP) 25.5.4 OPAMP4 control/status register (OPAMP4_CSR) Address offset: 0x0C Reset value: 0x0000 0000 LOCK Res. TRIMOFFSETN TRIMOFFSETP PGA_GAIN USER FORCE PGA_GAIN CALSEL CALON Res. Res. VM_SEL VP_SEL OPAEN INTOEN TRIM. Bit 31 LOCK: OPAMP4_CSR lock This bit is write-once. It is set by software. It can only be cleared by a system reset. This bit is used to configure the OPAMP4_CSR register as read-only.
Page 808
Operational amplifiers (OPAMP) RM0440 Bits 18:14 PGA_GAIN: Operational amplifier Programmable amplifier gain value 00000: Non inverting internal gain =2 00001: Non inverting internal gain =4 00010: Non inverting internal gain =8 00011: Non inverting internal gain =16 00100: Non inverting internal gain =32 00101: Non inverting internal gain =64 00110: Not used 00111: Not used...
Page 809
RM0440 Operational amplifiers (OPAMP) Bit 8 OPAINTOEN: Operational amplifier internal output enable. 0: The OPAMP output is connected to the output pin 1: The OPAMP output is connected internally to an ADC channel and disconnected from the output pin Bit 7 OPAHSM: Operational amplifier high-speed mode The operational amplifier must be disable to change this configuration.
Page 810
Operational amplifiers (OPAMP) RM0440 25.5.5 OPAMP5 control/status register (OPAMP5_CSR) Address offset: 0x10 Reset value: 0x0000 0000 LOCK Res. TRIMOFFSETN TRIMOFFSETP PGA_GAIN USER FORCE PGA_GAIN CALSEL CALON Res. Res. VM_SEL VP_SEL OPAEN INTOEN TRIM. Bit 31 LOCK: OPAMP5_CSR lock This bit is write-once. It is set by software. It can only be cleared by a system reset. This bit is used to configure the OPAMP5_CSR register as read-only.
Page 811
RM0440 Operational amplifiers (OPAMP) Bits 18:14 PGA_GAIN: Operational amplifier Programmable amplifier gain value 00000: Non inverting internal gain =2 00001: Non inverting internal gain =4 00010: Non inverting internal gain =8 00011: Non inverting internal gain =16 00100: Non inverting internal gain =32 00101: Non inverting internal gain =64 00110: Not used 00111: Not used...
Page 812
Operational amplifiers (OPAMP) RM0440 Bit 8 OPAINTOEN: Operational amplifier internal output enable. 0: The OPAMP output is connected to the output pin 1: The OPAMP output is connected internally to an ADC channel and disconnected from the output pin Bit 7 OPAHSM: Operational amplifier high-speed mode The operational amplifier must be disable to change this configuration.
Page 813
RM0440 Operational amplifiers (OPAMP) 25.5.6 OPAMP6 control/status register (OPAMP6_CSR) Address offset: 0x14 Reset value: 0x0000 0000 LOCK Res. TRIMOFFSETN TRIMOFFSETP PGA_GAIN USER FORCE PGA_GAIN CALSEL CALON Res. Res. VM_SEL VP_SEL OPAEN INTOEN TRIM. Bit 31 LOCK: OPAMP6_CSR lock This bit is write-once. It is set by software. It can only be cleared by a system reset. This bit is used to configure the OPAMP6_CSR register as read-only.
Page 814
Operational amplifiers (OPAMP) RM0440 Bits 18:14 PGA_GAIN: Operational amplifier Programmable amplifier gain value 00000: Non inverting internal gain =2 00001: Non inverting internal gain =4 00010: Non inverting internal gain =8 00011: Non inverting internal gain =16 00100: Non inverting internal gain =32 00101: Non inverting internal gain =64 00110: Not used 00111: Not used...
Page 815
RM0440 Operational amplifiers (OPAMP) Bit 8 OPAINTOEN: Operational amplifier internal output enable. 0: The OPAMP output is connected to the output pin 1: The OPAMP output is connected internally to an ADC channel and disconnected from the output pin Bit 7 OPAHSM: Operational amplifier high-speed mode The operational amplifier must be disable to change this configuration.
Page 816
Operational amplifiers (OPAMP) RM0440 25.5.7 OPAMP1 timer controlled mode register (OPAMPx_TCMR) (x = 1...6) Address offset: 0x18 Reset value: 0x0000 0000 LOCK Res. T20CM T8CM_ T1CM_ VMS_ Res. VPS_SEL Bit 31 LOCK: OPAMP1_TCMR lock This bit is write-once. It is set by software. It can only be cleared by a system reset. This bit is used to configure the OPAMP1_TCMR register as read-only.
Page 817
RM0440 Operational amplifiers (OPAMP) Bit 3 T1CM_EN: TIM1 controlled mux mode enable This bit is set and cleared by software. It is used to control automatically the switch between the default selection (VP_SEL and VM_SEL) and the secondary selection (VPS_SEL and VMS_SEL) of the inverting and non inverting inputs.
Page 818
Operational amplifiers (OPAMP) RM0440 25.5.8 OPAMP2 timer controlled mode register (OPAMPx_TCMR) (x = 1...6) Address offset: 0x1C Reset value: 0x0000 0000 LOCK Res. T20CM T8CM_ T1CM_ VMS_ Res. VPS_SEL Bit 31 LOCK: OPAMP2_TCMR lock This bit is write-once. It is set by software. It can only be cleared by a system reset. This bit is used to configure the OPAMP2_TCMR register as read-only.
Page 819
RM0440 Operational amplifiers (OPAMP) Bit 3 T1CM_EN: TIM1 controlled mux mode enable This bit is set and cleared by software. It is used to control automatically the switch between the default selection (VP_SEL and VM_SEL) and the secondary selection (VPS_SEL and VMS_SEL) of the inverting and non inverting inputs.
Page 820
Operational amplifiers (OPAMP) RM0440 25.5.9 OPAMP3 timer controlled mode register (OPAMPx_TCMR) (x = 1...6) Address offset: 0x20 Reset value: 0x0000 0000 LOCK Res. T20CM T8CM_ T1CM_ VMS_ Res. VPS_SEL Bit 31 LOCK: OPAMP3_TCMR lock This bit is write-once. It is set by software. It can only be cleared by a system reset. This bit is used to configure the OPAMP3_TCMR register as read-only.
Page 821
RM0440 Operational amplifiers (OPAMP) Bit 3 T1CM_EN: TIM1 controlled mux mode enable This bit is set and cleared by software. It is used to control automatically the switch between the default selection (VP_SEL and VM_SEL) and the secondary selection (VPS_SEL and VMS_SEL) of the inverting and non inverting inputs.
Page 822
Operational amplifiers (OPAMP) RM0440 25.5.10 OPAMP4 timer controlled mode register (OPAMPx_TCMR) (x = 1...6) Address offset: 0x24 Reset value: 0x0000 0000 LOCK Res. T20CM T8CM_ T1CM_ VMS_ Res. VPS_SEL Bit 31 LOCK: OPAMP4_TCMR lock This bit is write-once. It is set by software. It can only be cleared by a system reset. This bit is used to configure the OPAMP4_TCMR register as read-only.
Page 823
RM0440 Operational amplifiers (OPAMP) Bit 3 T1CM_EN: TIM1 controlled mux mode enable This bit is set and cleared by software. It is used to control automatically the switch between the default selection (VP_SEL and VM_SEL) and the secondary selection (VPS_SEL and VMS_SEL) of the inverting and non inverting inputs.
Page 824
Operational amplifiers (OPAMP) RM0440 25.5.11 OPAMP5 timer controlled mode register (OPAMPx_TCMR) (x = 1...6) Address offset: 0x28 Reset value: 0x0000 0000 LOCK Res. T20CM T8CM_ T1CM_ VMS_ Res. VPS_SEL Bit 31 LOCK: OPAMP5_TCMR lock This bit is write-once. It is set by software. It can only be cleared by a system reset. This bit is used to configure the OPAMP5_TCMR register as read-only.
Page 825
RM0440 Operational amplifiers (OPAMP) Bit 3 T1CM_EN: TIM1 controlled mux mode enable This bit is set and cleared by software. It is used to control automatically the switch between the default selection (VP_SEL and VM_SEL) and the secondary selection (VPS_SEL and VMS_SEL) of the inverting and non inverting inputs.
Page 826
Operational amplifiers (OPAMP) RM0440 25.5.12 OPAMP6 timer controlled mode register (OPAMPx_TCMR) (x = 1...6) Address offset: 0x2C Reset value: 0x0000 0000 LOCK Res. T20CM T8CM_ T1CM_ VMS_ Res. VPS_SEL Bit 31 LOCK: OPAMP6_TCMR lock This bit is write-once. It is set by software. It can only be cleared by a system reset. This bit is used to configure the OPAMP6_TCMR register as read-only.
Page 827
RM0440 Operational amplifiers (OPAMP) Bit 3 T1CM_EN: TIM1 controlled mux mode enable This bit is set and cleared by software. It is used to control automatically the switch between the default selection (VP_SEL and VM_SEL) and the secondary selection (VPS_SEL and VMS_SEL) of the inverting and non inverting inputs.
Operational amplifiers (OPAMP) RM0440 25.5.13 OPAMP register map Table 203. OPAMP register map and reset values Register Offset name OPAMP1_CSR TRIMOFFSETN TRIMOFFSETP PGA_GAIN 0x00 Reset value OPAMP2_CSR TRIMOFFSETN TRIMOFFSETP PGA_GAIN 0x04 Reset value OPAMP3_CSR TRIMOFFSETN TRIMOFFSETP PGA_GAIN 0x08 Reset value OPAMP4_CSR TRIMOFFSETN TRIMOFFSETP...
Page 829
RM0440 Operational amplifiers (OPAMP) Table 203. OPAMP register map and reset values (continued) Register Offset name OPAMP5_ TCMR 0x28 Reset value OPAMP6_ TCMR 0x2C Reset value Refer to Section 2.2 on page 80 for the register boundary addresses. RM0440 Rev 4 829/2126...
Page 830
True random number generator (RNG) RM0440 True random number generator (RNG) 26.1 Introduction The RNG is a true random number generator that provides full entropy outputs to the application as 32-bit samples. It is composed of a live entropy source (analog) and an internal conditioning component.
True random number generator (RNG) RM0440 26.3.3 Random number generation The true random number generator (RNG) delivers truly random data through its AHB interface at deterministic intervals. Within its boundary the RNG implements the entropy source model pictured on Figure 180.
Page 833
RM0440 True random number generator (RNG) Post processing The sample values obtained from a true random noise source consist of 2-bit bitstrings. Because this noise source output is biased, the RNG implements a post-processing component that reduces that bias to a tolerable level. More specifically, for each of the two noise source bits the RNG takes half of the bits from the sampled noise source, and half of the bits from inverted sampled noise source.
Page 834
True random number generator (RNG) RM0440 Health checks This component ensures that the entire entropy source (with its noise source) starts then operates as expected, obtaining assurance that failures are caught quickly and with a high probability and reliability. The RNG implements the following health check features. Continuous health tests, running indefinitely on the output of the noise source –...
RM0440 True random number generator (RNG) The associated initialization time can be found in Section 26.5: RNG processing time. Figure 181. RNG initialization overview Noise source enable RNGEN=0, then RNGEN=1 Conditioning hardware init Drop samples then check again Error state Generate samples Continuous test(s) not OK...
Page 836
True random number generator (RNG) RM0440 To run the RNG in polling mode following steps are recommended: Enable the random number generation by setting the RNGEN bit to “1” in the RNG_CR register. Read the RNG_SR register and check that: –...
Page 837
RM0440 True random number generator (RNG) correctly (see Section 26.3.6: RNG clocking) and then it must clear the CEIS bit interrupt flag. The CECS bit is automatically cleared when clocking condition is normal. Note: The clock error has no impact on generated random numbers, i.e. application can still read RNG_DR register.
True random number generator (RNG) RM0440 26.4 RNG interrupts In the RNG an interrupt can be produced on the following events: • Data ready flag • Seed error, see Section 26.3.7: Error management • Clock error, see Section 26.3.7: Error management Dedicated interrupt enable control bits are available as shown in Table 205.
Page 839
RM0440 True random number generator (RNG) 26.6.3 Data collection In order to run statistical tests it is required to collect samples from the entropy source at raw data level as well as at the output of the entropy source. Contact STMicroelectronics if above samples need to be retrieved for your product. RM0440 Rev 4 839/2126...
Page 840
True random number generator (RNG) RM0440 26.7 RNG registers The RNG is associated with a control register, a data register and a status register. 26.7.1 RNG control register (RNG_CR) Address offset: 0x000 Reset value: 0x0000 0000 Res. Res. Res. Res. Res.
Page 842
True random number generator (RNG) RM0440 26.7.3 RNG data register (RNG_DR) Address offset: 0x008 Reset value: 0x0000 0000 The RNG_DR register is a read-only register that delivers a 32-bit random value when read. After being read this register delivers a new random value after 216 periods of AHB clock if the output FIFO is empty.
RM0440 True random number generator (RNG) 26.7.4 RNG register map Table 206 gives the RNG register map and reset values. Table 206. RNG register map and reset map Offset Register name RNG_CR 0x000 Reset value RNG_SR 0x004 Reset value 0 0 0 RNG_DR RNDATA[31:0] 0x008...
Page 844
High-resolution timer (HRTIM) RM0440 High-resolution timer (HRTIM) 27.1 Introduction The high-resolution timer can generate up to 12 digital signals with highly accurate timings. It is primarily intended to drive power conversion systems such as switch mode power supplies or lighting systems, but can be of general purpose usage, whenever a very fine timing resolution is expected.
Page 845
RM0440 High-resolution timer (HRTIM) 27.2 Main features • High-resolution timing units – 184 ps resolution, compensated against voltage and temperature variations – High-resolution available on all outputs, possibility to adjust duty-cycle, frequency and pulse width in triggered one-pulse mode – 6 16-bit timing units (each one with an independent counter and 4 compare units) –...
Page 846
High-resolution timer (HRTIM) RM0440 27.3 Functional description 27.3.1 General description The HRTIM can be partitioned into several sub entities: • The master timer • The timing units (timer A to timer F) • The output stage • The burst mode controller •...
RM0440 High-resolution timer (HRTIM) Note: As a writing convention, references to the 6 timing units in the text and in registers are generalized using the “x” letter, where x can be any value from A to F. The block diagram of the timer is shown in Figure 182.
High-resolution timer (HRTIM) RM0440 27.3.2 HRTIM pins and internal signals The tables in this section summarize the HRTIM inputs and outputs, both on-chip and off- chip. Table 207. HRTIM inputs/outputs summary Signal name Signal type Description HRTIM_CHA1, HRTIM_CHA2, HRTIM_CHB1, HRTIM_CHB2, HRTIM_CHC1, HRTIM_CHC2, Main HRTIM timer outputs.
Page 849
RM0440 High-resolution timer (HRTIM) Table 207. HRTIM inputs/outputs summary (continued) Signal name Signal type Description hrtim_eev1[4:1] hrtim_eev2[4:1] hrtim_eev3[4:1] hrtim_eev4[4:1] External events. Each of the 10 events can be selected among 4 hrtim_eev5[4:1] sources, either on-chip (from other built-in peripherals: comparator, ADC Digital input analog watchdog, TIMx timers, trigger outputs) or off-chip hrtim_eev6[4:1]...
High-resolution timer (HRTIM) RM0440 deadtime generator clock. For convenience, only the t period (t ) is used in this document. chopper stage clock source. CHPFRQ clock source defining the length of the initial pulse in chopper mode. For 1STPW convenience, only the t period (t = 1/f ) is used in this...
RM0440 High-resolution timer (HRTIM) Figure 183. Counter and capture register format vs clock prescaling factor Prescaling Significant bit: read returns effective value Not significant bit: read returns 0 MS32257V1 Initialization At start-up, it is mandatory to initialize first the prescaler bitfields before writing the compare and period registers.
Page 854
High-resolution timer (HRTIM) RM0440 Burst mode prescaler The burst mode controller counter clock f can be supplied by several sources, among BRST which one is derived from f HRTIM In this case, f ranges from f to f / 32768 (5.188 kHz for = 170 MHz).
RM0440 High-resolution timer (HRTIM) 27.3.4 Timer A..F timing units The HRTIM embeds 6 identical timing units made of a 16-bit up-counter with an auto-reload mechanism to define the counting period, 4 compare and 2 capture units, as per Figure 184. Each unit includes all control features for 2 outputs, so that it operates as a standalone timer.
High-resolution timer (HRTIM) RM0440 Table 214. Period and compare registers min and max values CKPSC[2:0] value 0x0060 0xFFDF 0x0030 0xFFEF 0x0018 0xFFF7 0x000C 0xFFFB 0x0006 0xFFFD ≥ 5 0x0003 0xFFFD 1. The value 0x0000 can be written in CMP1 and CMP3 registers only, to skip a PWM pulse. See Section : Null duty cycle exception case for details.
Page 858
High-resolution timer (HRTIM) RM0440 Roll-over event A counter roll-over event is generated when the counter goes back to 0 after having reached the period value set in the HRTIM_PERxR register in continuous mode. This event is used for multiple purposes in the HRTIM: –...
RM0440 High-resolution timer (HRTIM) Figure 187. Timer reset resynchronization (prescaling ratio above 32) HRTIM Prescaled clock Reset event Counter Counter (PER = 5) HRTIM_CHA1 HRTIM_CHA1: Set on Timer A reset event, Reset on Compare 1 = 2 MS32261V2 Repetition counter A common software practice is to have an interrupt generated when the period value is reached, so that the maximum amount of time is left for processing before the next period begins.
High-resolution timer (HRTIM) RM0440 Figure 188. Repetition rate versus HRTIM_REPxR content in continuous mode Counter HRTIM_REPxR = 0 REP event HRTIM_REPxR = 1 HRTIM_REPxR = 2 * denotes repetition counter internal values (not readable, for explanation purpose only) MS32262V1 The repetition counter can also be used when the counter is reset before reaching the period value (variable frequency operation) either in continuous or in single-shot mode (Figure 189 here-below).
Page 861
RM0440 High-resolution timer (HRTIM) Set / reset crossbar A “set” event correspond to a transition to the output active state, while a “reset” event corresponds to a transition to the output inactive state. The polarity of the waveform is defined in the output stage to accommodate positive or negative logic external components: an active level corresponds to a logic level 1 for a positive polarity (POLx = 0), and to a logic level 0 for a negative polarity (POLx = 1).
High-resolution timer (HRTIM) RM0440 Table 216. Events mapping across timer A to F Timer A Timer B Timer C Timer D Timer E Timer F Source Figure 190 represents how a PWM signal is generated using two compare events. Figure 190. Compare events action on outputs: set on compare 1, reset on compare 2 f HRTIM Clock Counter...
RM0440 High-resolution timer (HRTIM) This mode is enabled by writing HALF bit to 1 in the HRTIM_TIMxCR register. When the HRTIM_PERxR register is written, it causes an automatic update of the compare 1 value with HRTIM_PERxR/2 value. The output on which a square wave is generated must be programmed to have one transition on CMP1 event, and one transition on the period event, as follows: –...
High-resolution timer (HRTIM) RM0440 Table 218. Compare 1..3 values in interleaved mode Dual interleaved Triple interleaved Quad interleaved Mode 180° 120° 90° CMP1 value PERxR/2 PERxR/3 PERxR/4 CMP2 value Not affected 2x (PERxR/3) PERxR/2 CMP3 value Not affected Not affected 3x (PERxR/4) Note: In half and interleaved modes, the compare registers are controlled by hardware and writing...
Page 865
RM0440 High-resolution timer (HRTIM) Consequently, it does not modify the auxiliary outputs in parallel with the regular outputs going to the output stage (see Section 27.3.18 for details). They provide the following internal status, events and signals: – O1CPY, O2CPY, SETxy and RSTxy status flags, together with the corresponding interrupts and DMA requests –...
High-resolution timer (HRTIM) RM0440 Figure 191. Timer A timing unit capture circuitry CMP1 CMP2 Timer B TB1 set TB1 reset Timer C Capture 1 Timer D Trigger Timer E selection (OR) Capture 1 register Timer F External events 1..10 CPT1 Timer A Update (IRQ &...
RM0440 High-resolution timer (HRTIM) Figure 192. Auto-delayed overview (compare 2 only) Capture 1 Counter Trigger: CPT1, DELCMP2[1..0] CMP1 or CMP3 Autodelayed Compare 2 Compare 2 DELCMP2[1..0] Compare 1 Compare 3 MS32266V1 The auto-delayed compare is only valid from the capture up to the period event: once the counter has reached the period value, the system is re-armed with compare disabled until a capture occurs.
High-resolution timer (HRTIM) RM0440 match (DELCMPx[1:0]= 10) or a compare 3 match (DELCMPx[1:0]= 11) to have a timeout function if capture 1/2 event is missing. When the capture occurs, the comparison is done with the (HRTIM_CMP2/4xR + HRTIM_CPT1/2xR) value. If no capture is triggered within the period, the behavior depends on the DELCMPx[1:0] value: •...
Page 869
RM0440 High-resolution timer (HRTIM) A delayed compare is used for the output reset: the compare event can be generated only if a capture event has occurred. No event is generated when the counter matches the delayed compare value (counter = 4). Once the capture event has been triggered by the external event, the content of the capture register is summed to the delayed compare value to have the new compare value.
High-resolution timer (HRTIM) RM0440 have a master-slave system.The slave converter synchronization is continuously adjusted based on the previous switching period of the master converter. This is done using the capture unit. The switching period of the master converter is captured, divided by 2 and then stored in the compare 2 register by hardware. The compare 2 register contains a value equal to half of the captured period, which is the master converter switching period.
RM0440 High-resolution timer (HRTIM) Note: In triggered half mode, the compare2 register is controlled by hardware and writing it has no effect. However the written value is stored in the preload register and becomes active on the update event following the exit of this mode. Push-pull mode This mode primarily aims at driving converters using push-pull topologies.
High-resolution timer (HRTIM) RM0440 Figure 196. Push-pull mode example Period Counter Compare 1 Roll-over events Push-Pull logic Set on Reset on Crossbar output period compare 1 HRTIM_CHx1 HRTIM_CHx2 MS32269V2 Figure 197 shows how the deadtime is inserted in push-pull mode, for both positive and negative deadtimes.
High-resolution timer (HRTIM) RM0440 Figure 198. Complementary outputs with deadtime insertion Counter Compare Crossbar output 1 Deadtime rising Deadtime falling HRTIM_CHx1 HRTIM_CHx2 MS32270V2 Negative deadtime values can be defined when some control overlap is required. This is done using the deadtime sign bits (SDTFx and SDTRx bits in HRTIM_DTxR register). Figure 199 shows complementary signal waveforms depending on respective signs.
High-resolution timer (HRTIM) RM0440 27.3.6 Up-down counting mode The HRTIM is natively designed with up-counters. It offers however an operating mode with up-down counters, also called center-aligned mode. This mode is enabled using the UDM bit in the HRTIM_TIMxCR2 register. This bit must not be changed once the timer is operating (TxEN bit set).
RM0440 High-resolution timer (HRTIM) Figure 206 below shows how to generate some more complex waveforms, using the 4 available compare units and the toggle mode. Figure 206. Complex symmetric waveform in up-down counting mode Counter CMP4 CMP3 CMP2 CMP1 Set on CMP1 Set on CMP2 Reset on CMP3 Reset on CMP4...
High-resolution timer (HRTIM) RM0440 The behavior of the software forcing bits and external events EXTEVNT1..10 is identical for up-only and up-down counting mode. The Figure 208 below shows how a pulse can be shorten in response to external events. Figure 208. External event management in up-down counting mode Counter CMP2 CMP1...
RM0440 High-resolution timer (HRTIM) Figure 210. Interleaved up-down counter operation TimA TimB HRTIM_CHx1 HRTIM_CHy1 Shorten pulse on TB1 on TimB counter reset MSv47420V2 Note: In up-down counting mode, the compare values must be 3 periods of the fHRTIM clock below the period value (TIMx_PER - 0xC0 if CKPSC[2:0] = 0, TIMx_PER - 0x60 if CKPSC[2:0] = 1, TIMx_PER - 0x30 if CKPSC[2:0] = 2,...).
High-resolution timer (HRTIM) RM0440 Figure 212. Up-down mode with “greater than” comparison Set on CMP1 HRTIM_CHx1 MSv50805V1 Caution: The following features are not supported in up-down counting mode: – Auto-delayed mode – Balanced Idle – Triggered-half mode The capture function is supported with the following differences: –...
RM0440 High-resolution timer (HRTIM) Note: For events where both reset and roll-over are considered (IRQ/DMA and TxRSTU), the ROM[1:0] only influences the roll-over generation. The reset event is always taken into account whatever the ROM[1:0] value. The roll-over event generation is defined as per following xxROM[1:0] bitfield setting: •...
High-resolution timer (HRTIM) RM0440 Figure 214 below shows how the repetition counter is decremented in up-down counting mode. Figure 214. Repetition counter behavior in up-down counting mode Counter REP = 0 ROM[1:0] = 00 REP = 0 ROM[1:0] = 01 REP = 0 ROM[1:0] = 10 REP = 1...
Page 885
RM0440 High-resolution timer (HRTIM) 27.3.7 Set / reset events priorities and narrow pulses management This section describes how the output waveform is generated when several set and/or reset requests are occurring within 3 consecutive periods. HRTIM Case 1: clock prescaler CKPSC[2:0] < 5 An arbitration is performed during each t period, in 3 steps: HRTIM...
High-resolution timer (HRTIM) RM0440 Figure 215. Short distance set/reset management for narrow pulse generation clock HRTIM Simulaneous set/reset Reset Set event is discarded Reset/set within the same period Set event is postponed if interval is < t HRTIM HRTIM Reset/set within Set event is anticipated if interval is >...
Page 887
RM0440 High-resolution timer (HRTIM) If the set and reset events are generated with an interval above 3 periods, the high- HRTIM resolution is always available. Concurrent set requests/ Concurrent reset requests When multiple sources are selected for a set event, an arbitration is performed when the set requests occur within the same f clock period.
Page 888
High-resolution timer (HRTIM) RM0440 If a reset event is followed by a set event within the same prescaler clock cycle, the latest event is considered. 27.3.8 External events global conditioning The HRTIM timer can handle events not generated within the timer, referred to as “external event”.
High-resolution timer (HRTIM) RM0440 transmitted as a correct external event. Consequently, the digital filter adds a latency to the external events being filtered, depending on the sampling clock and on the filter length (number of valid samples expected). The sampling clock is either the f clock or a specific prescaled clock f derived HRTIM...
RM0440 High-resolution timer (HRTIM) Table 223. Output set/reset latency and jitter versus external event operating mode Response time Jitter on output pulse EExFAST Response time jitter latency (counter reset by ext. event) 5 to 6 cycles of f 1 cycles of f No jitter, pulse width maintained with HRTIM HRTIM...
RM0440 High-resolution timer (HRTIM) 27.3.9 External event filtering in timing units Once conditioned, the 10 external events are available for all timing units. They can be used directly and are active as soon as the timing unit counter is enabled (TxCEN bit set).
High-resolution timer (HRTIM) RM0440 The blanking signal comes from several sources: • the timer itself: the blanking lasts from the counter reset to the compare match (EExFLTR[3:0] = 0001 to 0100 for compare 1 to compare 4). In up/down mode (UDM bit set to 1), the counter reset event is defined as per the ROM[1:0] bit setting.
High-resolution timer (HRTIM) RM0440 Windowing mode In event windowing mode, the event is taken into account only if it occurs within a given time window, otherwise it is ignored. This mode is active for EExFLTR[3:0] ranging from 1101 to 1111. Figure 223.
High-resolution timer (HRTIM) RM0440 External event counter Each timing unit also features an external event counter following the filtering unit, typically for valley skipping implementation. The circuitry allows to filter any of the 10 external events filtered, as shown on Figure 226.
RM0440 High-resolution timer (HRTIM) Figure 227. External event counter cumulative mode (EEVxRSTM = 1, EEVxCNT = 2) Counter EEV input EEV edge detector EEV counter EEV event PWM output MSv47423V2 27.3.10 Delayed protection The HRTIM features specific protection schemes, typically for resonant converters when it is necessary to shut down the PWM outputs in a delayed manner, either once the active pulse is completed or once a push-pull period is completed.
High-resolution timer (HRTIM) RM0440 idle is applied to a single output. When the push-pull mode is enabled, the IPPSTAT flag in HRTIM_TIMxISR indicates during which period the delayed protection request occurred. This mode is available whatever the timer operating mode (regular, push-pull, deadtime). It is available with 2 external events only: •...
Page 904
High-resolution timer (HRTIM) RM0440 while the IPPSTAT flag indicates during which period the external event occurred, to determine the sequence of shorten pulses (A1 then A2 or vice versa). The timer operation is not interrupted (the counter continues to run). To enable the balanced idle mode, it is necessary to have the following initialization: –...
Page 905
RM0440 High-resolution timer (HRTIM) The balanced idle mode has a higher priority than the burst mode: any burst mode exit request is discarded once the balanced idle protection has been triggered. On the contrary, if the delayed protection is exited while the burst mode is active, the burst mode is resumed normally.
High-resolution timer (HRTIM) RM0440 Table 226 lists the registers which can be preloaded, together with a summary of available update events. Table 226. HRTIM preloadable control registers and associated update sources Timer Preloadable registers Preload enable Update sources HRTIM_DIER HRTIM_MPER Software HRTIM_MREP Repetition event...
Page 907
RM0440 High-resolution timer (HRTIM) Each timer (TIMA..F) can also have the update done as follows: • By software: writing 1 into TxSWU bit in HRTIM_CR2 forces an immediate update of the registers. In this case, any pending hardware update request is canceled. •...
High-resolution timer (HRTIM) RM0440 Figure 232. Resynchronized timer update (TAU=1 in HRTIM_TIMBCR) TIMA Counter HRTIM_CHx1 TIMA update RSYNCU=0 TIMB update RSYNCU=1 TIMB Counter HRTIM_CHy1 MSv47432V2 MUDIS and TxUDIS bits in the HRTIM_CR1 register allow to temporarily disable the transfer from preload to active registers, whatever the selected update event. This allows to modify several registers in multiple timers.
Page 909
RM0440 High-resolution timer (HRTIM) When the power converter set-point has to be adjusted by software, TAUDIS, TDUDIS and TEUDIS bits of the HRTIM_CR register must be set prior to write accessing the registers to update the values (for instance the compare values). From this time on, any hardware update request is ignored and the preload registers can be accessed without any risk to have them transferred into the active registers.
High-resolution timer (HRTIM) RM0440 In the fixed frequency configuration, the period event must trigger the output set and the “greater than” compare triggers the output reset (or vice versa the period must trigger the reset if the “greater-than” compare triggers the set). For variable frequency configuration, the event selected as counter reset source must also be selected as set or reset source for the timer output (opposite direction as the “greater than”...
RM0440 High-resolution timer (HRTIM) TIMx update triggered by the master timer update The sources listed in Table 227 are generating a master timer update. The table indicates if the source event can be used to trigger a simultaneous update in any of TIMx timing units. Operating condition: MSTU bit is set in HRTIM_TIMxCR register.
Page 912
High-resolution timer (HRTIM) RM0440 Table 228. TIMx update event propagation (continued) Source Condition Propagation Comment TyRST=1 in Can be done simultaneously with update in Counter software reset HRTIM_CR2 HRTIM_CR2 register Counter reset caused TIMzCMPn in by a TIMz compare HRTIM_RSTyR Counter reset caused EXTEVNTn in by external events...
RM0440 High-resolution timer (HRTIM) TIMx counter reset causing a TIMx update Table 229 lists the counter reset sources and indicates whether they can be used to generate an update. Operating condition: TxRSTU bit in HRTIM_TIMxCR register. Table 229. Reset events able to generate an update Source Condition Propagation...
Page 914
High-resolution timer (HRTIM) RM0440 Table 230. Update event propagation for a timer reset (continued) Source Condition Propagation Comment Master update caused by a repetition event following a MSTU = 1 in roll-over HRTIM_TIMxCR Master update caused by a MREPU = 1 in repetition event following a HRTIM_MCR counter reset (software or...
RM0440 High-resolution timer (HRTIM) 27.3.14 Output management Each timing unit controls a pair of outputs. The outputs have three operating states: • RUN: this is the main operating mode, where the output can take the active or inactive level as programmed in the crossbar unit. •...
High-resolution timer (HRTIM) RM0440 Section 27.3.17, while the Idle state can be entered when the burst mode or delayed protections are active. Figure 235. HRTIM output states and transitions IDLE State OEN = 0 ODS = 0 (Fault or breakpoint*) &...
RM0440 High-resolution timer (HRTIM) The level of the output in IDLE state is configured using IDLESx bit in HRTIM_OUTxR, as follows: • 0: output at inactive level when in IDLE • 1: output at active level when in IDLE When TxyOEN bit is set to enter the RUN state, the output is immediately connected to the crossbar output.
High-resolution timer (HRTIM) RM0440 The burst mode controller is able to take over the control of any of the 10 PWM outputs. The state of each output during a burst mode operation is programmed using IDLESx and IDLEMx bits in the HRTIM_OUTxR register, as in Table 232.
Page 919
RM0440 High-resolution timer (HRTIM) start or timer A start), a pulse is sent on the HRTIM_SCOUT output when exiting the burst mode. Note: TxBM bit must not be set when the balanced idle mode is active (DLYPRT[1:0] = 0x11). Burst mode clock The burst mode controller counter can be clocked by several sources, selected with BMCLK[3:0] bits in the HRTIM_BMCR register: •...
High-resolution timer (HRTIM) RM0440 Figure 237. Burst mode trigger on external event External event Counter Output Trigger on Output external event IDLE state Output Trigger on timer period following Output IDLE external event state MS32284V1 For TAEEV7 and TDEEV8 combined triggers (trigger on a timer period following an external event), the external event detection is always active, regardless of the burst mode programming and the on-going burst operation: •...
High-resolution timer (HRTIM) RM0440 Figure 239. Delayed burst mode entry during deadtime Burst mode entry IDLES HRTIM_CHx1 HRTIM_CHx2 IDLES Regular deadtime (aborted when burst is triggered) Delayed Burst mode entry deadtime MS32286V3 Burst mode exit The burst mode exit is either forced by software (in continuous mode) or once the idle period is elapsed (in single-shot mode).
RM0440 High-resolution timer (HRTIM) Figure 240. Burst mode exit when the deadtime generator is enabled Timx counter Out1 crossbar waveform Burst state IDLE HRTIM_CHx1 HRTIM_CHx2 Burst state IDLE HRTIM_CHx1 HRTIM_CHx2 MS32287V3 The behavior described above is slightly different when the push-pull mode is enabled. The push-pull mode forces an output reset at the beginning of the period if the output is inactive, or symmetrically forces an active level if the output was high during the preceding period.
Page 924
High-resolution timer (HRTIM) RM0440 When BMPREN bits is reset, the write access into BMCMPR and BMPER directly updates the active register. In this case, it is necessary to consider when the update is done during the overall burst period, for the 2 cases below: Compare register update If the new compare value is above the current burst mode counter value, the new compare is taken into account in the current period.
High-resolution timer (HRTIM) RM0440 The chopper parameters can be adjusted using the HRIM_CHPxR register, with the possibility to define a specific pulsewidth at the beginning of the pulse, to be followed by a carrier frequency with programmable frequency and duty cycle, as in Figure 243.
High-resolution timer (HRTIM) RM0440 The EEVx_muxout event mentioned in Table 233 above is taken after the hrtim_eevx[4:1] input multiplexer controlled by the EExSRC[1:0]bits. Refer to Figure 216 for details. The polarity of the signal can be selected to define the active level, using the FLTxP polarity bit in HRTIM_FLTINRx registers.
High-resolution timer (HRTIM) RM0440 Figure 246. Fault counter cumulative mode (FLTxRSTM = 1, FLTxCNT[3:0] = 2) Counter FLT input FLT edge detector FLT counter FLT event PWM output MSv47426V1 A given FLTx input counter can be reset by a single source. The Table 236 indicates which timer unit associated with a given fault.
Page 931
RM0440 High-resolution timer (HRTIM) For each FAULT channel, a write-once FLTxLCK bit in the HRTIM_FLTxR register allows to lock FLTxE, FLTxP, FLTxSRC, FLTxF[3:0] bits (it renders them read-only), for functional safety purpose. If enabled, the fault conditioning set-up is frozen until the next HRTIM or system reset.
RM0440 High-resolution timer (HRTIM) Figure 248. Auxiliary and main outputs during burst mode (DIDLx = 0) Burst mode Burst mode entry exit Auxiliary output1 Auxiliary output2 HRTIM_CHx1 IDLES level HRTIM_CHx2 IDLES level IDLES level continued up to the transition to the opposite level MS32291V2 The signal on the auxiliary output can be slightly distorted when exiting from the burst mode...
Page 934
High-resolution timer (HRTIM) RM0440 27.3.19 Synchronizing the HRTIM with other timers or HRTIM instances The HRTIM provides options for synchronizing multiple HRTIM instances, as a master unit (generating a synchronization signal) or as a slave (waiting for a trigger to be synchronized). This feature can also be used to synchronize the HRTIM with other timers, either external or on-chip.
RM0440 High-resolution timer (HRTIM) Synchronization input The HRTIM can be synchronized by external sources, as per the programming of the SYNCIN[1:0] bits in the HRTIM_MCR register: • 00: synchronization input is disabled • 01: reserved configuration • 10: the On-chip timer TRGO output connected to hrtim_in_sync[2] input (refer to Table 207 for details).
Page 936
High-resolution timer (HRTIM) RM0440 Table 237. Effect of sync event versus timer operating modes (continued) SYNC SYNC Operating mode Behavior following a SYNC reset or start event RSTx STRTx The counter start is effective only if the counter is not started or period is elapsed.
RM0440 High-resolution timer (HRTIM) 27.3.21 DAC triggers The HRTIM allows to have the embedded DACs updated synchronously with the timer updates. The update events from the master timer and the timer units can generate DAC update triggers on any of the 3 hrtim_dac_trgx outputs. Note: Each timer has its own DAC-related control register.
Page 942
High-resolution timer (HRTIM) RM0440 Dual channel DAC trigger Slope compensation techniques and hysteretic control to be easily implemented using HRTIM built-in features and the DAC sawtooth generator. The principle is to have a DAC generating a decreasing saw-tooth synchronized with the PWM period, or a square wave synchronized with PWM signal.
RM0440 High-resolution timer (HRTIM) Table 238 below gives an example, for generating 6 triggers within a PWM period. It shows that it is necessary to round up the division result to the upper value. Let’s consider a counter period TIMxPER = 8192. Dividing 8192 by 6 yields 1365.33. –...
High-resolution timer (HRTIM) RM0440 14 interrupts can be generated by each timing unit: • Delayed protection triggered • Counter reset or roll-over event • Output 1 and output 2 reset (transition active to inactive) • Output 1 and output 2 set (transition inactive to active) •...
Page 947
RM0440 High-resolution timer (HRTIM) Table 239. HRTIM interrupt summary (continued) Interrupt Enable Flag clearing Interrupt event Event flag vector control bit Delayed protection triggered DLYPRT DLYPRTIE DLYPRTC Counter reset or roll-over event RSTIE RSTC RSTx1 RSTx1IE RSTx1C Output 1 and output 2 reset (transition active to inactive) RSTx2 RSTx2IE...
RM0440 High-resolution timer (HRTIM) The burst DMA feature is only available for one DMA channel, but any of the 6 channels can be selected for burst DMA transfers. The principle is to program which registers are to be written by DMA. The master timer and TIMA..E have the burst DMA update register, where most of their control and data registers are associated with a selection bit: HRTIM_BDMUPR, HRTIM_BDTAUPR to HRTIM_BDTEUPR (this is applicable only for registers with write accesses).
High-resolution timer (HRTIM) RM0440 Figure 259. Burst DMA operation flowchart Write access to HRTIM_BDMADR Parse Parse Parse HRTIM_BDMUPR HRTIM_BDTAUPR HRTIM_BDTFUPR Write data into Write data into Write data into TIMACR bit TIMFCR bit MCR bit set? set? set? HRTIM_MCR HRTIM_TIMACR HRTIM_TIMFCR Write data into Write data into...
RM0440 High-resolution timer (HRTIM) The chronogram on Figure 260 presents the active register content for 3 cases: PREEN=0, UPDGAT[3:0] = 0001 and UPDGAT[3:0] = 0001 (when PREEN = 1). Figure 260. Registers update following DMA burst transfer DMA request on CMP1 event starts DMA burst Timer A Counter...
Page 952
High-resolution timer (HRTIM) RM0440 The HRTIM control registers can be initialized as per the power converter topology and the timing units use case. All inputs have to be configured (source, polarity, edge-sensitivity). The HRTIM outputs must be set up eventually, with the following sequence: •...
RM0440 High-resolution timer (HRTIM) Synchronization, counter reset, start and reset-start events are discarded in debug mode, as well as capture events. This is to keep all related registers stable as long as the MCU is halted. The counter stops counting when a breakpoint is reached. However, the counter enable signal is not reset;...
High-resolution timer (HRTIM) RM0440 Figure 262. Dual Buck converter management CMP4 TIMA CMP3 counter CMP2 CMP1 TIMA HRTIM_CHA1 outputs (BUCK 1) HRTIM_CHA2 (BUCK 2) MS32344V2 Timers A..E provide either 12 buck converters coupled by pairs (both with identical switching frequencies) or 7 completely independent converters (each of them having a different switching frequency), using the master timer as the 7 time base.
RM0440 High-resolution timer (HRTIM) Figure 264. Buck with synchronous rectification TIMA counter CMP2 CMP1 HRTIM_CHA1 TIMA outputs HRTIM_CHA2 Synchronous Rectification (SR) active SR disabled MS32346V2 27.4.3 Multiphase converters Multiphase techniques can be applied to multiple power conversion topologies (buck, flyback). Their main benefits are: •...
High-resolution timer (HRTIM) RM0440 The master timer is responsible for the phase management: it defines the phase relationship between the converters by resetting the timers periodically. The phase-shift is 360° divided by the number of phases, 120° in the given example. The duty cycle is then programmed into each of the timers.
RM0440 High-resolution timer (HRTIM) Figure 267. Transition mode PFC HRTIM_ CHA2 MS32349V3 This converter operates with a constant Ton time and a variable frequency due the Toff time variation (depending on the input voltage). It must also include some features to operate when no zero-crossing is detected, or to limit the Ton time in case of over-current (OC).
Page 960
High-resolution timer (HRTIM) RM0440 Bit 21 TECEN: Timer E counter enable This bit starts the timer E counter. 0: Timer E counter disabled 1: Timer E counter enabled Note: This bit must not be changed within a minimum of 8 cycles of f clock.
Page 961
RM0440 High-resolution timer (HRTIM) Bit 10 SYNCRSTM: Synchronization resets master This bit enables the master timer reset when receiving a synchronization input event: 0: No effect on the master timer 1: A synchronization input event resets the master timer Bits 9:8 SYNCIN[1:0] Synchronization input These bits are defining the synchronization input source.
Page 965
RM0440 High-resolution timer (HRTIM) Bit 4 MREPIE: Master repetition interrupt enable This bit is set and cleared by software to enable/disable the master timer repetition interrupts 0: Master repetition interrupt disabled 1: Master repetition interrupt enabled Bit 3 MCMP4IE: Master compare 4 interrupt enable Refer to MCMP1IE description Bit 2 MCMP3IE: Master compare 3 interrupt enable Refer to MCMP1IE description...
Page 971
RM0440 High-resolution timer (HRTIM) Bits 31:28 UPDGAT[3:0]: Update gating These bits define how the update occurs relatively to the burst DMA transaction and the external update request on update enable inputs hrtim_upd_en[3:1] (see Table 209). The update events, as mentioned below, can be: MSTU, TFU, TEU, TDU, TCU, TBU, TAU, TxRSTU, TxREPU.
Page 972
High-resolution timer (HRTIM) RM0440 Bit 21 TCU: Timer C update Register update is triggered by the timer C update 0: Update by timer C disabled 1: Update by timer C enabled Note: This bit is reserved for HRTIM_TIMCCR. It is only available for HRTIM_TIMACR, HRTIM_TIMBCR, HRTIM_TIMDCR, HRTIM_TIMECR, HRTIM_TIMFCR.
Page 973
RM0440 High-resolution timer (HRTIM) Bits 13:12 DELCMP2[1:0]: CMP2 auto-delayed mode This bitfield defines whether the compare register is behaving in standard mode (compare match issued as soon as counter equal compare), or in auto-delayed mode (see Section : Auto-delayed mode). 00: CMP2 register is always active (standard compare mode) 01: CMP2 value is recomputed and is active following a capture 1 event 10: CMP2 value is recomputed and is active following a capture 1 event, or is recomputed and...
Page 974
High-resolution timer (HRTIM) RM0440 Bit 4 RETRIG: Re-triggerable mode This bit defines the counter behavior in single shot mode. 0: The timer is not re-triggerable: a counter reset is done if the counter is stopped (period elapsed in single-shot mode or counter stopped in continuous mode) 1: The timer is re-triggerable: a counter reset is done whatever the counter state.
Page 976
High-resolution timer (HRTIM) RM0440 Bit 16 CPPSTAT: Current push-pull status This status bit indicates on which output the signal is currently applied, in push-pull mode. It is only significant in this configuration. 0: Signal applied on output 1 and output 2 forced inactive 1: Signal applied on output 2 and output 1 forced inactive Bit 15 Reserved, must be kept at reset value.
Page 977
RM0440 High-resolution timer (HRTIM) Bit 2 CMP3: Compare 3 interrupt flag Refer to CMP1 description Bit 1 CMP2: Compare 2 interrupt flag Refer to CMP1 description Bit 0 CMP1: Compare 1 interrupt flag This bit is set by hardware when the timer x counter matches the value programmed in the compare 1 register.
Page 978
High-resolution timer (HRTIM) RM0440 Bit 7 CPT1C: Capture 1 interrupt flag clear Writing 1 to this bit clears the CPT1 flag in HRTIM_TIMxISR register Bit 6 UPDC: Update interrupt flag clear Writing 1 to this bit clears the UPD flag in HRTIM_TIMxISR register Bit 5 Reserved, must be kept at reset value.
Page 979
RM0440 High-resolution timer (HRTIM) Bit 31 Reserved, must be kept at reset value. Bit 30 DLYPRTDE: Delayed protection DMA request enable This bit is set and cleared by software to enable/disable DMA requests on delayed protection. 0: Delayed protection DMA request disabled 1: Delayed protection DMA request enabled Bit 29 RSTDE: Reset/roll-over DMA request enable This bit is set and cleared by software to enable/disable DMA requests on timer x counter reset or...
Page 980
High-resolution timer (HRTIM) RM0440 Bit 16 CMP1DE: Compare 1 DMA request enable This bit is set and cleared by software to enable/disable the compare 1 DMA requests. 0: Compare 1 DMA request disabled 1: Compare 1 DMA request enabled Bit 15 Reserved, must be kept at reset value. Bit 14 DLYPRTIE: Delayed protection interrupt enable This bit is set and cleared by software to enable/disable interrupts on delayed protection.
Page 981
RM0440 High-resolution timer (HRTIM) Bit 2 CMP3IE: Compare 3 interrupt enable Refer to CMP1IE description Bit 1 CMP2IE: Compare 2 interrupt enable Refer to CMP1IE description Bit 0 CMP1IE: Compare 1 interrupt enable This bit is set and cleared by software to enable/disable the compare 1 interrupts. 0: Compare 1 interrupt disabled 1: Compare 1 interrupt enabled RM0440 Rev 4...
Page 983
RM0440 High-resolution timer (HRTIM) Bits 31:16 Reserved, must be kept at reset value. Bits 15:0 PERx[15:0]: Timer x period value This register holds timer x period value. This register holds either the content of the preload register or the content of the active register if preload is disabled.
Page 985
RM0440 High-resolution timer (HRTIM) Bits 31:16 Reserved, must be kept at reset value. Bits 15:0 CMP1x[15:0]: Timer x compare 1 value This register holds the compare 1 value. This register holds either the content of the preload register or the content of the active register if preload is disabled.
Page 987
RM0440 High-resolution timer (HRTIM) Bits 31:16 Reserved, must be kept at reset value. Bits 15:0 CMP2x[15:0]: Timer x compare 2 value This register holds the compare 2 value. This register holds either the content of the preload register or the content of the active register if preload is disabled.
Page 993
RM0440 High-resolution timer (HRTIM) Bit 14 DTRSLKx: Deadtime rising sign lock This write-once bit prevents the sign of deadtime to be modified, if enabled. 0: Deadtime rising sign is writable 1: Deadtime rising sign is read-only Note: This bit is not preloaded. Bit 13 Reserved, must be kept at reset value.
Page 995
RM0440 High-resolution timer (HRTIM) Bit 19 TIMEVNT8: Timer event 8 Refer to TIMEVNT1 description. Bit 18 TIMEVNT7: Timer event 7 Refer to TIMEVNT1 description. Bit 17 TIMEVNT6: Timer event 6 Refer to TIMEVNT1 description. Bit 16 TIMEVNT5: Timer event 5 Refer to TIMEVNT1 description.
Page 996
High-resolution timer (HRTIM) RM0440 Bit 2 PER: Timer x period Timer A period event forces the output to its active state. Note: In up/down mode (UDM bit set to 1), the counter period event is defined as per the OUTROM[1:0] bit setting. Bit 1 RESYNC: Timer A resynchronization Timer A reset event coming solely from software or SYNC input forces the output to its active state.
Page 1000
High-resolution timer (HRTIM) RM0440 Bit 5 Reserved, must be kept at reset value. Bits 4:1 EE1FLTR[3:0]: External event 1 filter 0000: No filtering 0001: Blanking from counter reset/roll-over to compare 1 0010: Blanking from counter reset/roll-over to compare 2 in up-counting mode (UDM bit reset) In up-down counting mode (UDM bit set): blanking from compare 1 to compare 2, only during the up-counting phase.
Need help?
Do you have a question about the STM32G4 Series and is the answer not in the manual?
Questions and answers