For ordering information, mechanical and electrical device characteristics, refer to the corresponding datasheets. ® ® ® For information on the Arm Cortex -Mx cores, refer to the corresponding Arm Technical Reference Manuals available on http://infocenter.arm.com. Related documents • STM32WL55xx STM32WL54xx datasheet (DS13293) November 2020 RM0453 Rev 1 1/1461 www.st.com...
Page 6
Contents RM0453 5.7.7 Receive mode (RX) ........173 5.7.8 Active mode switching time .
Page 7
RM0453 Contents 5.10.12 Sub-GHz radio generic synchronization word control register 3 (SUBGHZ_GSYNCR3) ........211 5.10.13 Sub-GHz radio generic synchronization word control register 2 (SUBGHZ_GSYNCR2) .
Page 13
RM0453 Contents 10.3.2 I/O pin alternate function multiplexer and mapping ....396 10.3.3 I/O port control registers ........397 10.3.4 I/O port data registers .
Page 19
RM0453 Contents 18.5.1 Data register and data alignment (ADC_DR, ALIGN) ... . . 552 18.5.2 ADC overrun (OVR, OVRMOD) ......552 18.5.3 Managing a sequence of data converted without using the DMA .
Page 44
List of tables RM0453 List of tables Table 1. Device boot mode ............62 Table 2.
Page 45
RM0453 List of tables Table 52. Stop 1 mode ............248 Table 53.
Page 46
List of tables RM0453 Table 104. Configuring the trigger polarity ..........547 Table 105.
Page 47
RM0453 List of tables Table 156. Arithmetic multiplication ..........711 Table 157.
Page 48
List of tables RM0453 Table 207. RTC input/output pins ........... 1000 Table 208.
Page 49
RM0453 List of tables Table 258. I2S interrupt requests ........... 1312 Table 259.
Page 50
List of figures RM0453 List of figures Figure 1. System architecture ............61 Figure 2.
Page 51
RM0453 List of figures Figure 49. DMA block diagram ........... . 456 Figure 50.
Page 52
List of figures RM0453 Figure 101. AES block diagram ............651 Figure 102.
Page 53
RM0453 List of figures Figure 153. Control circuit in external clock mode 1 ........750 Figure 154.
Page 54
List of figures RM0453 Figure 204. Counter timing diagram, internal clock divided by 4, TIMx_ARR=0x36 ....842 Figure 205. Counter timing diagram, internal clock divided by N......843 Figure 206.
Page 55
RM0453 List of figures Figure 254. Edge-aligned PWM waveforms (ARR=8) ........919 Figure 255.
Page 56
List of figures RM0453 Figure 301. Transfer sequence flowchart for SMBus slave receiver N Bytes + PEC ... . 1100 Figure 302. Bus transfer diagrams for SMBus slave receiver (SBC=1)..... . . 1101 Figure 303.
Page 57
RM0453 List of figures Figure 347. Full-duplex single master/ single slave application ......1270 Figure 348.
Documentation conventions RM0453 Documentation conventions General information ®(a) ® ® The STM32WL5x devices embed an Arm Cortex -M4 with DSP and an Arm ® Cortex -M0+ 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.
RM0453 Documentation conventions Glossary This section gives a brief definition of acronyms and abbreviations used in this document: • Word: data of 32-bit length. • Half-word: data of 16-bit length. • Byte: data of 8-bit length. • Option bytes: product configuration bits stored in the Flash memory. •...
Memory and bus architecture RM0453 Memory and bus architecture The following definitions are used in this section: • CPU1 = Arm Cortex-M4 with MPU and DSP • CPU2 = Arm Cortex-M0+ with MPU When ESE = 0, CPU2 is non-secure. When ESE = 1, CPU2 is secure. System architecture The main system consists of a 32-bit multilayer AHB bus matrix that interconnects the following masters and slaves:...
RM0453 Memory and bus architecture This architecture is shown in the figure below. Figure 1. System architecture CPU1 CPU2 DMA1 DMA2 Cortex-M4 Cortex-M0+ Flash memory FLASH arbiter SRAM1 SRAM2 AHB1 AHB2 AHB3 when remapped Bus matrix MSv60752V1 2.1.1 S0: CPU1 I-bus This bus connects the instruction bus of the CPU1 core to the bus matrix.
Memory and bus architecture RM0453 SRAM2, the AHB1 peripherals including the APB1 and APB2 peripherals, the AHB2 peripherals and the AHB3 peripherals including the APB3 peripherals. 2.1.5 S4, S5: DMA-bus These buses connect the AHB master interface of the DMAs to the bus matrix.The targets of this bus are the internal Flash memory, SRAM1, SRAM2 the AHB1 peripherals including the APB1 and APB2 peripherals, the AHB2 peripherals and the AHB3 peripherals including the APB3 peripherals.
Page 63
RM0453 Memory and bus architecture Table 1. Device boot mode (continued) Boot mode selection CPU1 aliasing space CPU2 boot User Flash boot SBRV boot System Flash boot SBRV boot (1)(2)(3) Hold SFI/RSS boot Hold SBRV boot System Flash boot SBRV boot SRAM1 boot SBRV boot User Flash boot...
Memory and bus architecture RM0453 the Flash memory contents can be accessed starting from address 0x0000 0000 or 0x0800 0000. • Boot from system Flash memory The system Flash memory is aliased in the CPU1 or CPU2 boot memory space at address 0x0000 0000 and is also still accessible from its physical address 0x1FFF 0000.
RM0453 Memory and bus architecture CPU2 system Flash boot CPU2 system Flash memory SFI/RSS boot can be selected via BOOT0 and BOOT1. If, after a reset, the user options are not valid and BOOT0/BOOT1 select CPU1 to boot from the main Flash memory, CPU2 boots instead from the system Flash memory SFI/RSS. Note: When Engi bytes are not valid, or PKA or AES is not available in the product, the SFI/RSS boot firmware install is not available.
Page 66
Memory and bus architecture RM0453 The memory protection allows the following areas to be defined within a memory: • When memory unprivileged address offset > secure address offset – Secure privileged – Flash memory only: secure privileged and unprivileged read execute only (non base thread mode) –...
RM0453 Memory and bus architecture A memory protection example with all different areas is given in Figure 2: Memory protection example. In this example the secure privileged hide protection area is only accessible read, write, execute by the secure privileged bus masters when hide protection area access is enabled in HDPADIS bit.
Memory and bus architecture RM0453 This example show only a secure and privileged protected memory map. The security and unprivileged parameters can freely be programmed in any order as detailed below: • When HDPSA > SFSA> unprivileged watermark > unprivileged write watermark, the areas appear in the following order: –...
RM0453 Memory organization 2.6.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.
Page 76
RM0453 Example The following example shows how to map bit [2] of the byte located at SRAM1 address 0x2000 0300 to the alias region. The formula is then: 0x2200 6008 = 0x2200 0000 + 0x0300 * 32 + 2 * 4 Writing to address 0x2200 6008 has the same effect as a read-modify-write operation on bit [2] of the byte at SRAM1 address 0x2000 0300.
RM0453 Global security controller (GTZC) Global security controller (GTZC) GTZC introduction This section includes the description of the two following sub-blocks: • TZSC: security controller This sub-block defines the secure/privileged state of slave peripherals. It also controls the unprivileged area size for the watermark memory peripheral controller (MPCWM). •...
Global security controller (GTZC) RM0453 Application information The TZSC and TZIC sub-blocks can be used in one of the following ways: • programmed during secure boot only, locked and not changed afterwards • dynamically re-programmed when using specific application code or secure kernel (microvisor).
Page 80
Global security controller (GTZC) RM0453 Note: Some registers have only write security protection and can be accessed read non-secure (refer to individual register descriptions). • Illegal unprivileged read write access Any unprivileged transaction trying to access a privileged resource is considered as illegal.
RM0453 Global security controller (GTZC) address with a length defined through GTZC_TZSC_MPCWM1_UPWWMR.LGTH[11:0]. Only the area which is also defined as unprivileged in GTZC_TZSC_MPCWM1_UPWMR.LGTH[11:0] is unprivileged writable. Note: Where n represents the target memory (1 = Flash memory, 2 = SRAM1 and 3 = SRAM2). Figure 6.
Global security controller (GTZC) RM0453 3.4.7 Interrupts TZIC is a secure peripheral that generates systematically an illegal access event when accessed by a non-secure access. TZSC is a security-aware peripheral, meaning that secure and non-secure registers co-exist. GTZC TZSC registers All GTZC TZSC registers are accessed only by words (32-bit).
RM0453 Global security controller (GTZC) 3.5.2 GTZC TZSC security configuration register (GTZC_TZSC_SECCFGR1) Address offset: 0x010 Reset value: 0x0000 0000 Secure write access only. A bit of this register can be written only by a secure privileged transaction, when the corresponding bit in GTZC_TZSC_PRIVCFGR1 is set to privileged. If unprivileged, the register bit can be written by secure privileged and secure unprivileged transactions.
Global security controller (GTZC) RM0453 3.5.3 GTZC TZSC privileged configuration register (GTZC_TZSC_PRIVCFGR1) Address offset: 0x020 Reset value: 0x0000 0000 Privileged write access only. A bit of this register can be written only by a secure privileged transaction, when the corresponding bit in GTZC_TZSC_SECCFGR1 register or the Flash user option is set to secure.
RM0453 Global security controller (GTZC) 3.5.4 GTZC TZSC unprivileged watermark 1 register (GTZC_TZSC_MPCWM1_UPWMR) Address offset: 0x130 Reset value: 0x0FFF 0000 Privileged write access only. This register can be written only by secure privileged transaction, when the corresponding Flash user option FSD is configured as secure. If non-secure, this register can be written by secure privileged and non-secure privileged transaction.
Global security controller (GTZC) RM0453 3.5.5 GTZC TZSC unprivileged writable watermark 1 register (GTZC_TZSC_MPCWM1_UPWWMR) Address offset: 0x134 Reset value: 0x0FFF 0000 Privileged write access only. This register can be written only by secure privileged transaction when the corresponding Flash user option FSD is configured as secure. If non-secure, this register can be written by secure privileged and non-secure privileged transaction.
RM0453 Global security controller (GTZC) 3.5.6 GTZC TZSC unprivileged watermark 2 register (GTZC_TZSC_MPCWM2_UPWMR) Address offset: 0x138 Reset value: 0x0FFF 0000 Privileged write access only. This register can be written only by secure privileged transaction, when the corresponding Flash user option NBRSD is configured as secure. If non-secure, this register can be written by secure privileged and non-secure privileged transaction.
Global security controller (GTZC) RM0453 3.5.7 GTZC TZSC unprivileged watermark 3 register (GTZC_TZSC_MPCWM3_UPWMR) Address offset: 0x140 Reset value: 0x0FFF 0000 Privileged write access only. This register can be written only by secure privileged transaction, when the corresponding Flash user option BRSD is configured as secure. If non-secure, this register can be written by secure privileged and non-secure privileged transaction.
Global security controller (GTZC) RM0453 GTZC TZIC registers All GTZC TZIC registers are accessed by words (32-bit), halfwords (16-bit) and bytes (8-bit). 3.6.1 GTZC TZIC interrupt enable register 1 (GTZC_TZIC_IER1) Address offset: 0x000 Reset value: 0xFFFF FFFF when security is enabled (ESE = 1) Reset value: 0x0000 0000 when security is disabled (ESE = 0) This register can only be access by a secure privileged access for read and write.
RM0453 Global security controller (GTZC) Bit 7 DMA1IE: Illegal access event interrupt enable bit for DMA1 0: Disabled (masked) 1: Enabled (unmasked) Bit 6 FLASHIFIE: Illegal access event interrupt enable bit for FLASH interface 0: Disabled (masked) 1: Enabled (unmasked) Bit 5 PWRIE: Illegal access event interrupt enable bit for PWR 0: Disabled (masked) 1: Enabled (unmasked)
Page 94
Global security controller (GTZC) RM0453 Bit 13 PKAMF: Illegal access event interrupt status flag before masking for PKA 0: No illegal access event interrupt pending 1: Illegal access event interrupt pending Bit 12 SRAM2MF: Illegal access event interrupt status flag before masking for SRAM2 0: No illegal access event interrupt pending 1: Illegal access event interrupt pending Bit 11 SRAM1MF: Illegal access event interrupt status flag before masking for SRAM1...
RM0453 Global security controller (GTZC) 3.6.3 GTZC TZIC interrupt status clear register 1 (GTZC_TZIC_ICR1) Address offset: 0x020 Reset value: 0x0000 0000 This register can only be access by a secure privileged access for read and write. A non secure or unprivileged access is ignored and return zero data and an illegal access event is generated.
Global security controller (GTZC) RM0453 Bit 4 SUBGHZSPICF: Illegal access event interrupt status flag clear bit for sub-GHz SPI 0: No action 1: Clear status flag Bit 3 RNGCF: Illegal access event interrupt status flag clear bit for RNG 0: No action 1: Clear status flag Bit 2 AESCF: Illegal access event interrupt status flag clear bit for AES 0: No action...
RM0453 Embedded Flash memory (FLASH) Embedded Flash memory (FLASH) FLASH introduction The Flash memory interface manages the CPU1 AHB ICode and DCode accesses and the CPU2 AHB access to the Flash memory. It implements the access arbitration between the two CPUs, the erase and program Flash memory operations, the security mechanisms, and the read and write protection.
Embedded Flash memory (FLASH) RM0453 The Flash memory is organized as follows: • A main memory block containing 128 pages of 2 Kbytes, each page with eight rows of 256 bytes. • An information block containing: – System memory from which the CPU1 boots in system memory boot mode This area is reserved and contains the bootloader used to reprogram the Flash memory through one of the following interfaces: USART1, USART2, I2C1, I2C2, I2C3, SPI1, SPI2S2.
RM0453 Embedded Flash memory (FLASH) boot from. It prevents the system to boot from the Flash main memory area when, for example, no user code is programmed. The Flash main memory empty check status can be read from the EMPTY bit in the FLASH_ACR register.
Embedded Flash memory (FLASH) RM0453 After power-on reset and wakeup from Standby, the HCLK3 clock frequency is 4 MHz in range 1 and 0 wait state (WS) is configured in FLASH_ACR. When changing the frequency of the Flash memory clock or the V range, the software CORE sequences detailed below must be applied in order to tune the number of wait states...
Page 101
RM0453 Embedded Flash memory (FLASH) The CPU2 fetches the instruction and the literal pool (constant/data) over the S-bus. The prefetch block aims at increasing the efficiency of S-bus accesses. Each Flash memory read operation provides 64 bits from either two instructions of 32 bits or four instructions of 16 bits according to the program launched.
Embedded Flash memory (FLASH) RM0453 The figure below shows the execution of sequential 16-bit instructions with and without prefetch when three wait states are needed to access the Flash memory. Figure 7. Sequential 16 bits instructions execution WAIT WITHOUT PREFETCH WAIT ins 1 ins 2...
Page 103
RM0453 Embedded Flash memory (FLASH) When the code is not sequential (branch), the instruction may not be present in the currently used instruction line or in the prefetched instruction line. In this case (miss), the penalty in terms of number of cycles is at least equal to the number of wait states. If a loop is present in the current buffer, no new access is performed.
Embedded Flash memory (FLASH) RM0453 are saved in a current buffer. The CPU2 pipeline is consequently stalled until the requested literal pool is provided. No data cache is available on CPU2. 4.3.6 Flash program and erase operations The embedded Flash memory can be programmed using in-circuit programming or in- application programming.
RM0453 Embedded Flash memory (FLASH) Note: FLASH_CR and FLASH_C2CR cannot be written when BSY is set respectively in FLASH_SR or FLASH_C2SR. Any attempt to write to these registers with BSY set causes the AHB bus to stall until BSY is cleared. 4.3.7 Flash main memory erase sequences The Flash memory erase operation can be performed at page level (page erase) or on the...
Embedded Flash memory (FLASH) RM0453 change due to Flash operation requests by the other CPU, to limit the risk of receiving a bus error when starting page erase). Check and clear all error programming flags due to a previous programming. If not, PGSERR is set.
RM0453 Embedded Flash memory (FLASH) Check and clear all error programming flags due to a previous programming. If not, PGSERR is set. Set MER in FLASH_CR or FLASH_C2CR. Set STRT in FLASH_CR or FLASH_C2CR. Wait for BSY to be cleared in FLASH_SR or FLASH_C2SR. Note: The internal oscillator HSI16 (16 MHz) is enabled automatically when the STRT bit is set, and disabled automatically when the STRT bit is cleared, except if the HSI16 is previously...
Page 108
Embedded Flash memory (FLASH) RM0453 Check and clear all error programming flags due to a previous programming. If not, PGSERR is set. Set PG in FLASH_CR or FLASH_C2CR. Perform the data write operation at the desired memory address, inside the main memory block or OTP area.
Page 109
RM0453 Embedded Flash memory (FLASH) change due to Flash operation requests by the other CPU, to limit the risk of receiving a bus error when starting programming). Check and clear all error programming flag due to a previous programming. Set FSTPG in FLASH_CR or FLASH_C2CR. Write the 32 double-words to program a row (256 bytes).
Page 110
Embedded Flash memory (FLASH) RM0453 PGAERR is set if one of the following conditions occurs: – In standard programming, the first word to be programmed is not aligned with a double-word address, or the second word does not belong to the same double- word address.
RM0453 Embedded Flash memory (FLASH) In fast programming, all the data must be written successively. MISSERR is set if the previous data programming 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: –...
Embedded Flash memory (FLASH) RM0453 Programming and caches If a Flash memory write access impacts data in the data cache, the Flash memory write access modifies the data in the memory and in the cache. If an erase operation in the Flash memory also concerns data in the data cache or instruction cache, the user must ensure that these data are rewritten before they are accessed during code execution.
RM0453 Embedded Flash memory (FLASH) Table 16. Option bytes organization (continued) Address PCROP1B_END[7:0] 0x1FFF 7830 0x1FFF 7838 0x1FFF 7860 IPCCDBA[13:0] 0x1FFF 7868 HDPSA[6:0] SFSA[6:0] 0x1FFF 7870 SNBRSA[4:0] SBRSA[4:0] SBRV[15:0] 0x1FFF 7878 OPVAL[31:0] 0x1FFF 7FF8 1. The upper 32 bits of the double-word address contain the inverted data from the lower 32 bits. 4.4.2 Option bytes programming After a reset, the options related bits in FLASH_CR and FLASH_C2CR are write-protected.
Page 114
Embedded Flash memory (FLASH) RM0453 Clear OPTLOCK option lock bit with the clearing sequence described above Write the desired options value in the options registers. Check that no Flash memory operation is ongoing by checking the BSY bit in FLASH_SR or FLASH_C2SR. Check that Flash program and erase operation is allowed by checking the PESD bit in FLASH_SR or FLASH_C2SR (these checks are recommended even if status may change due to Flash operation requests by the other CPU, to limit the risk of receiving...
RM0453 Embedded Flash memory (FLASH) If the comparison between the word and its complement fails, a status bit OPTVERR is set. Mismatch values are forced into the option registers as follows: • For USR OPT option, the value of mismatch is all options at ‘1’, except for BOR_LEV that is “000”...
Secure system memory 4.5.1 Introduction The secure system memory stores RSS (root secure services) firmware that is programmed by ST during STM32WL5x production. The RSS provides secure services to the bootloader and the user firmware. 4.5.2 RSSLIB functions The RSS provides runtime services thanks to the RSS library. As other microcontroller peripheral features and mapping, the RSS library functions are exposed to user within the CMSIS device header file provided by the STM32CubeWL firmware package.
RM0453 Embedded Flash memory (FLASH) Arguments: • HdpArea: Input parameter, bitfield that identifies which HDP area to close. Values can be: RSSLIB_HDP_AREA1 • VectorTableAddr: Input parameter, address of the next vector table to apply. The vector table format is the one used by the Cortex-M0+ core. Description: The user calls CloseExitHDP() to close Flash HDP secure memory area and to jump to the reset handler embedded within the vector table, which address is passed as input...
Page 118
Embedded Flash memory (FLASH) RM0453 The system memory area is read accessible whatever the protection level. It is never accessible for program/erase operation. Level 0: no protection Read, program and erase operations into the main Flash memory area are possible. The option bytes, SRAM2 and backup registers are also accessible by all operations.
RM0453 Embedded Flash memory (FLASH) FLASH_PCROP1AER. Backup registers (RTC_BKPxR in the RTC), SRAM1, SRAM2 and PKA SRAM are also erased. The user options except PCROP protection are set to their previous values copied from FLASH_OPTR, FLASH_WRP1xR (x= A or B). PCROP is disabled.
Embedded Flash memory (FLASH) RM0453 Note: Full mass erase or partial mass erase is performed only when level 1 is active and level 0 is requested. When the protection level is increased (0→1, 1→2, 0→2, or directly decreased from level 2 to level 0), there is no mass erase. To validate the protection level change, the option bytes must be reloaded through the OBL_LAUNCH bit in FLASH_CR, or a POR, or wakeup from Standby or Shutdown mode.
RM0453 Embedded Flash memory (FLASH) 1. When the protection level 2 is active, the debug port, the boot from RAM and the boot from system memory are disabled. 2. The system memory is only read-accessible, whatever the protection level (0, 1 or 2) and execution mode. 3.
Embedded Flash memory (FLASH) RM0453 When option bit PCROP_RDP is cleared and when the RDP is changing from level 1 to level 0, the full mass erase is replaced by a partial mass erase to preserve the PCROP area (refer to Change the readout protection level).
RM0453 Embedded Flash memory (FLASH) Table 22: WRP protection WRPx registers values (x = A or B) WRP protection area WRP1x_STRT = WRP1x_END Page WRP1x is protected WRP1x_STRT > WRP1x_END No WRP, unprotected WRP1x_STRT < WRP1x_END Pages from WRP1x_STRT to WRP1x_END are protected Note: To validate the WRP options, the option bytes must be reloaded through the OBL_LAUNCH bit in FLASH_CR.
Page 124
Embedded Flash memory (FLASH) RM0453 CPU2 secure SRAM areas SRAM1 and SRAM2 areas are only secure when the Flash memory security is enabled (ESE = 1). The CPU2 secure SRAM2 and SRAM1 areas have a 1-Kbyte granularity and are defined by the secure “backup”...
RM0453 Embedded Flash memory (FLASH) When ESE = 1 and the secure hide protection area is disabled, the CPU2 debug is enabled with the C2SWDBGEN bit after restarting OBL. However when the secure hide protection area is enabled, the CPU2 debug is disabled with the C2SWDBGEN bit and may subsequently be enabled by software.
Embedded Flash memory (FLASH) RM0453 When at least one PES bit is set, the following occurs: • Any ongoing program or erase operation is completed. The maximum latency for a Flash program erase suspension is the maximum time for one program or erase operation to complete (see product datasheets for more information on the Flash program and erase timing).
RM0453 Embedded Flash memory (FLASH) Register access protection The user option registers may be protected by security and privilege. When the system is secure (ESE = 1) and the user option registers in the Flash memory are also protected by privileged (FLASH_PRIVMODER.PRIV = 1), the Flash memory secure user option bits (FSD, SFSA, BRSD, SBRSA, NBRSD, SNBRSA, SBRV, C2OPT, HDPAD, HDPSA and DDS) are secure and privileged.
RM0453 Embedded Flash memory (FLASH) Bit 8 PRFTEN: CPU1 prefetch enable 0: CPU1 prefetch disabled 1: CPU1 prefetch enabled Bits 7:3 Reserved, must be kept at reset value. Bits 2:0 LATENCY[2:0]: Latency These bits represent the ratio of the Flash HCLK clock period to the Flash memory access time.
Embedded Flash memory (FLASH) RM0453 Bits 31:3 Reserved, must be kept at reset value. Bit 2 C2SWDBGEN: CPU2 software debug enable This bit is set and reset by software. When HDPAD = 0 (hide protection area enabled), the CPU2 software debug is disabled after a system reset.
RM0453 Embedded Flash memory (FLASH) Bits 31:0 OPTKEY[31:0]: Option byte key lower bits The following values must be written consecutively to unlock the Flash memory option registers, enabling option byte programming/erasing operations: KEY1: 0x0819 2A3B KEY2: 0x4C5D 6E7F 4.10.5 FLASH status register (FLASH_SR) Address offset: 0x010 Reset value: 0x000X 0000 Res.
Page 132
Embedded Flash memory (FLASH) RM0453 Bit 14 RDERR: PCROP read error Set by hardware when an address to be read through the D-bus belongs to a read protected area of the Flash memory (PCROP protection). An interrupt is generated if RDERRIE is set in FLASH_CR.
RM0453 Embedded Flash memory (FLASH) Bit 2 Reserved, must be kept at reset value. Bit 1 OPERR: Operation error This bit is set by hardware when a Flash memory operation (program/erase) completes unsuccessfully. This bit is set only if error interrupts are enabled (ERRIE = 1). This bit is cleared by writing 1.
Page 134
Embedded Flash memory (FLASH) RM0453 Bit 31 LOCK: FLASH_CR lock This bit can only be set by software. When set, the FLASH_CR register is locked. This bit 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. Bit 30 OPTLOCK: Options lock This bit can only be set by software.
RM0453 Embedded Flash memory (FLASH) Bits 9:3 PNB[6:0]: page number selection These bits select the 2-Kbyte page to erase. 0x00: page 0 0x01: page 1 0x7F: page 127 Bit 2 MER: mass erase When set, this bit triggers the mass erase (all user pages). Bit 1 PER: page erase 0: page erase disabled 1: page erase enabled...
FLASH option register (FLASH_OPTR) Address offset: 0x020 Reset value: 0x3FFF F0AA Default reset value from ST production is given. Subsequently, 0bXX11 XXXX X111 XXXX 1XXX XXXX XXXX XXXX, the option bits are loaded with user values from the Flash memory at reset release.
Page 137
RM0453 Embedded Flash memory (FLASH) Bit 31 C2BOOT_LOCK: CPU2 boot lock enable option bit This bit may be set by software at any time but a write to clear is only taken into account in one of the following conditions: - when ESE = 0 and staying in RDP level 0 - when ESE = 1 and staying in RDP level 0 by regressing FSD - when ESE = 0 and regressing RDP level from 1 to 0...
Page 138
Embedded Flash memory (FLASH) RM0453 Bit 17 IWDG_STOP: independent watchdog counter freeze in Stop mode 0: Independent watchdog counter frozen in Stop mode 1: Independent watchdog counter running in Stop mode Bit 16 IWDG_SW: independent watchdog selection 0: Hardware independent watchdog 1: Software independent watchdog Bit 15 Reserved, must be kept at reset value.
(FLASH_PCROP1ASR) Address offset: 0x024 Reset value: 0xFFFF FFFF Default reset value from ST production is given. Subsequently, 0b1111 1111 1111 1111 1111 1111 XXXX XXXX, the option bits are loaded with user values from the Flash memory at reset release.
FLASH WRP area A address register (FLASH_WRP1AR) Address offset: 0x02C Reset value: 0xFF80 FFFF Default reset value from ST production is given as.0b1111 1111 1XXX XXXX 1111 1111 1XXX XXXX, the option bits are loaded with user values from the Flash memory at reset release.
FLASH WRP area B address register (FLASH_WRP1BR) Address offset: 0x030 Reset value: 0xFF80 FFFF Default reset value from ST production is given as 0b1111 1111 1XXX XXXX 1111 1111 1XXX XXXX, the option bits are loaded with user values from Flash memory at reset release.
(FLASH_PCROP1BSR) Address offset: 0x034 Reset value: 0xFFFF FFFF Default reset value from ST production is given. Subsequently, 0b1111 1111 1111 1111 1111 1111 XXXX XXXX, the option bits are loaded with user values from the Flash memory at reset release.
Address offset: 0x03C Reset value: 0xFFFF FFFF Default reset value from ST production is given. Subsequently, 0b1111 1111 1111 1111 11XX XXXX XXXX XXXX, the option bits are loaded with user values from the Flash memory at power-on reset release.
Page 145
RM0453 Embedded Flash memory (FLASH) Bits 31:20 Reserved, must be kept at reset value. Bit 19 PESD: program/erase operation suspended This bit is set and reset by hardware. This bit is set when at least one PES bit in FLASH_ACR or FLASH_C2ACR is set. This bit is cleared when both PES in FLASH_ACR and FLASH_C2ACR are cleared.
Embedded Flash memory (FLASH) RM0453 Bit 5 PGAERR: programming alignment error This bit is set by hardware when the data to program cannot be contained in the same double-word (64-bit) Flash memory in case of standard programming, or if there is a change of page during fast programming.
Page 147
RM0453 Embedded Flash memory (FLASH) Res. Res. Res. Res. Res. ERRIE EOPIE Res. Res. Res. Res. Res. FSTPG Res. STRT Res. Res. Res. Res. Res. Res. PNB[6:0] Bits 31:27 Reserved, must be kept at reset value. Bit 26 RDERRIE: PCROP read error interrupt enable This bit enables the interrupt generation when RDERR in FLASH_SR is set to 1.
Address offset: 0x080 Reset value: 0xFFFF EFFF Default reset value from ST production is given as 0bX111 1111 XXXX XXXX 111X 1111 XXXX XXXX, the option bits are loaded with user values from the Flash memory at power- on reset release.
Address offset: 0x084 Reset value: 0xFFFF 8000 Default reset value from ST production is given. Subsequently, 0bXXXX XXX1 XXXX XX11 XXXX XXXX XXXX XXXX The option bits are loaded with user values from the Flash memory at power-on reset release.
Page 150
Embedded Flash memory (FLASH) RM0453 write access privilege and can only be written by a privileged access. Unprivileged write access from is ignored and an illegal access event is generated. Unprivileged read access is still allowed. This register, except for C2OPT and SBRV bits, is further write protected by HDPADIS when HDPAD = 0.
Page 151
RM0453 Embedded Flash memory (FLASH) Bits 22:18 SBRSA[4:0]: secure “backup” SRAM2 start address This bit is write protected when HDPAD = 0 and HDPADIS = 1. When FSD = BRSD =0, SRAM2 is secure. SBRSA[4:0] contains the start address of the first 1-Kbyte page of the secure backup SRAM2 area.
Sub-GHz radio (SUBGHZ) RM0453 Sub-GHz radio (SUBGHZ) Sub-GHz radio introduction The sub-GHz radio is an ultra-low-power sub-GHz radio operating in the 150 - 960 MHz ISM ® band. LoRa , (G)FSK/(G)MSK modulation in transmit and receive, and (D)BPSK in transmit only, allow an optimal trade-off between range, data rate and power consumption.
RM0453 Sub-GHz radio (SUBGHZ) Sub-GHz radio functional description 5.3.1 General description The sub-GHz radio provides an internal processing unit to handle communication with the system CPU. Communication is handled by commands sent over the SPI interface, and a set of interrupts is used to signal events. BUSY information signals operation activity and is used to indicate when the sub-GHz radio commands cannot be received.
Sub-GHz radio (SUBGHZ) RM0453 Table 26. Sub-GHz internal input/output signals (continued) Signal name Signal type Description Enable VDDTCXO regulator HSEBYPPWR Digital input control HSERDY Digital output HSE32 clock ready indication SUBGHZSPI Digital in/output Sub-GHz radio SPI interface BUSY Digital output BUSY signal Interrupts Digital output...
RM0453 Sub-GHz radio (SUBGHZ) The table below gives the maximum transmit output power versus the V supply level. DDPA Table 27. Sub-GHz radio transmit high output power supply (V) Transmit output power (dBm) DDPA + 22 + 20 + 16 Transmitter low output power The transmit low output power up to + 15 dBm, is supported through the RFO_LP pin.
Sub-GHz radio (SUBGHZ) RM0453 The receiver features automatic I and Q calibration, that improves image rejection. The calibration is done automatically at startup before using the receiver, and can be requested by command (see Image calibration for specific frequency bands for more details).
Sub-GHz radio (SUBGHZ) RM0453 The sub-GHz radio, depending on the transmit output power (max + 22 dBm), can heat up the device. The heating depends on the used transmit output power and the device package. Careful PCB design using thermal heat dissipation techniques must be applied to avoid heat transfer to the HSE32 reference clock source.
RM0453 Sub-GHz radio (SUBGHZ) Spreading factor (SF) The LoRa spread spectrum modulation is performed by representing each data bit of the packet payload by multiple chips of information. The rate at which the spread information is sent, is referred to as the symbol rate (Rs). The ratio between the nominal data rate and the chip rate is the spreading factor (SF).
Sub-GHz radio (SUBGHZ) RM0453 A higher coding rate provides better immunity to interference at the expense of longer transmission time. In normal conditions and factor of 4 / 5 provides the best trade off. In case of strong interference, a higher coding rate may be used. The coding rate and overhead ratio is given in the table below.
RM0453 Sub-GHz radio (SUBGHZ) The LoRa packet frames are illustrated in the figure below. Figure 12. LoRa packet frames format Explicit packet frame n preamble symbols n header symbols Preamble Header + CRC Payload CR defined by coding rate CR = 4/8 SF defined by spreading factor Implicit packet frame n preamble symbols...
Sub-GHz radio (SUBGHZ) RM0453 Implicit header mode In certain operation modes where the payload coding rate and CRC presence are fixed or known in advance, it can be advantageous to reduce transmission time by invoking implicit header mode. In this mode, the header is not present in the packet frame. The payload length, forward error correction coding rate and presence of the payload CRC must be configured on both sides of the sub-GHz radio link.
RM0453 Sub-GHz radio (SUBGHZ) index. An optional Gaussian filter can be used. All modulation parameters are set using Set_ModulationParams() command. The bit rate (or equivalent chip) is referenced to the HSE32 frequency and controlled by the BR parameter, defined as follows: BR = 32 x HSE32 / BitRate where HSE32 = 32 MHz...
RM0453 Sub-GHz radio (SUBGHZ) Fixed length generic packet mode In certain operation modes where the payload length is fixed or known in advance, it may be advantageous to reduce transmission time by invoking fixed length generic packet mode. In this mode, the header is not present in the packet frame and the payload length must be configured on both sides of the sub-GHz radio link.
Sub-GHz radio (SUBGHZ) RM0453 length definition. The full packet (preamble, synch word, device id to CRC) must be provided in the transmit data buffer. Sub-GHz radio data buffer The sub-GHz radio uses a 256-byte RAM data buffer that is accessible by the CPU through the SUBGHZSPI interface in all sub-GHz radio operating modes except Sleep and Deep-Sleep.
RM0453 Sub-GHz radio (SUBGHZ) 5.6.1 Receive data buffer operation In receive mode, RxBaseAddr, configured through Set_BufferBaseAddress(), determines the receive buffer offset in the sub-GHz radio RAM. RxBaseAddr can be set anywhere within the RAM data buffer. If needed, the whole 256-byte RAM data buffer can be used.
Sub-GHz radio (SUBGHZ) RM0453 • Calibration mode – intermediate mode between Deep-Sleep or Sleep, and Standby – used to calibrate the sub-GHz radio RC 64 kHz, sub-GHz radio RC 13 MHz, RF- PLL, RF-ADC and image • Standby mode – sub-GHz radio clocked by its internal RC 13 MHz clock –...
RM0453 Sub-GHz radio (SUBGHZ) 5.7.1 Startup mode At POR or after a sub-GHz radio reset, the Startup mode is entered. BUSY is set. When internal supply and clocks become available, the sub-GHz radio enters Sleep mode. 5.7.2 Sleep mode In Sleep mode, only the sub-GHz radio startup and Sleep control is operational and the configuration is lost.
Sub-GHz radio (SUBGHZ) RM0453 When in Standby mode, the calibration of different blocks can be requested by Calibrate() command. Image calibration for specific frequency bands The image calibration is performed as part of the calibration process, by default in the band 902 - 928 MHz.
RM0453 Sub-GHz radio (SUBGHZ) When entering TX mode, BUSY is set. In TX mode, BUSY is cleared when the PA ramped up and preamble transmission starts. PA ramping The PA ramping time can be selected while setting the output power, by Set_TxParams(). 5.7.7 Receive mode (RX) The RX mode can be requested to be entered from Standby mode.
Sub-GHz radio (SUBGHZ) RM0453 BUSY timing is shown in the figure below. Figure 16. Sub-GHz radio BUSY timing BUSY Opcode Param 1 Param n Write command SWMODE MSv64330V1 For the different mode transitions, typical busy timing values are given in the table below. Table 33.
RM0453 Sub-GHz radio (SUBGHZ) For each access, the sub-GHz radio SPI NSS goes low at the start of the transfer and is set high at the end, after all bytes have been transfered. The following transaction types are supported: • configuration transaction: provides the CPU with a direct access to control registers.
Page 176
Sub-GHz radio (SUBGHZ) RM0453 byte 0 bits 7:0 Opcode: 0x0D bytes 2:1 bits 15:0 Addr[15:0]: first write address byte 3 bits 7:0 Data0[7:0]: data to write to first address byte n+3 bits 7:0 Datan[7:0]: data to write to address + n (n = number of bytes to write) Read_Register() command Read_Register(Addr, Status, Data0, Data1, to Datan) allows a block of bytes to be read in a contiguous memory area starting from the specified address.
RM0453 Sub-GHz radio (SUBGHZ) offset. The offset is auto incremented after each byte. When the offset exceeds the value 255, it is wrapped around to 0 (providing a 256 byte circular buffer). Opcode Offset[7:0] Status[7:0] Data0[7:0] Datan[7:0] byte 0 bits 7:0 Opcode: 0x1E byte 1 bits 7:0 Offset[7:0]: first read address offset byte 2...
Page 178
Sub-GHz radio (SUBGHZ) RM0453 Set_Standby() command Set_Standby(StandbyCfg) is used to set the sub-GHz radio in Standby mode. The StandbyCfg parameter allows some optional functions to be selected in Standby mode. Opcode StandbyCfg byte 0 bits 7:0 Opcode: 0x80 byte 1 bits 7:1 Reserved, must be kept at reset value.
Page 179
RM0453 Sub-GHz radio (SUBGHZ) Set_Rx() command Set_Rx(Timeout) is used to set the sub-GHz radio in Receive mode. Opcode Timeout[23:0] byte 0 bits 7:0 Opcode: 0x82 bytes 3:1 bits 23:0 Timeout[23:0]: Transmit packet timeout 0x000000: timeout disabled 0x000001 - 0xFFFFFE: timeout enabled, single packet receive mode, resolution 15.625 μs 0xFFFFFF: timeout disabled, continuous receive mode Time-out duration is computed by the following formula:...
Sub-GHz radio (SUBGHZ) RM0453 The following steps are performed: Save sub-GHz radio configuration. Enter Receive mode and listen for a preamble for the specified RxPeriod period. Upon the detection of a preamble, the RxPeriod timeout is stopped and restarted with the value 2 x RxPeriod +SleepPeriod.
Page 181
RM0453 Sub-GHz radio (SUBGHZ) Set_Cad() command Set_Cad() is used to detect the channel activity and can only be used with LoRa packet types. The channel activity detection (CAD) is a specific LoRa operation mode, where the sub-GHz radio searches for a LoRa radio signal. After the search is completed, the Standby mode is automatically entered, CAD is done and IRQ is generated.
Sub-GHz radio (SUBGHZ) RM0453 5.8.4 Sub-GHz radio configuration commands Set_PacketType() command Set_PacketType(PktType) allows the selection of packet frame format. This command must be the first command of a sub-GHz radio configuration sequence. Changing from one sub-GHz radio configuration to another is done using Set_PacketType().
Page 183
RM0453 Sub-GHz radio (SUBGHZ) Set_RfFrequency() command Set_RfFrequency(RfFreq) is used to lock the RF-PLL frequency to the transmit and receive frequency. Opcode RfFreq[31:0] byte 0 bits 7:0 Opcode: 0x86 bytes 4:1 bits 31:0 RfFreq[31:0]: RF frequency RF-PLL frequency = 32e x RFfreq / 2 Note: The RF-PLL frequency formula is the same for RF-PLL high-resolution mode and RF-PLL low-resolution mode.
Page 184
Sub-GHz radio (SUBGHZ) RM0453 byte 0 bits 7:0 Opcode: 0x8E byte 1 bits 7:0 Power[7:0]: Output power setting LP PA selected in Set_PaConfig() 0x0E:+ 14 dB 0x00: 0 dB 0xEF: - 17 dB Others: reserved HP PA selected in Set_PaConfig() 0x16:+ 22 dB 0x00: 0 dB 0xF7: - 9 dB...
RM0453 Sub-GHz radio (SUBGHZ) Table 35 byte 2 bits 2:0 HpMax[2:0]: HP PA output power (see for settings) bits 7:3 Reserved, must be kept at reset value. byte 3 bits 7:1 Reserved, must be kept at reset value. bit 0 PaSel: PA selection. 0: HP PA selected 1: LP PA selected (default) byte 4...
Page 186
Sub-GHz radio (SUBGHZ) RM0453 Set_CadParams() command Set_CadParams(NbCadSymbol,CadDetPeak,CadDetMin,CadExtiMode,Timeout) allows the CAD configuration for LoRa packet types. Opcode Timeout[23:0] byte 0 bits 7:0 Opcode: 0x88 byte 1 bits 7:3 Reserved, must be kept at reset value. bits 2:0 NbCadSymbol[2:0]: Number of symbols used for CAD scan 0x0: 1 symbol 0x1: 2 symbols 0x2: 4 symbols...
RM0453 Sub-GHz radio (SUBGHZ) The correct values selected in the table below must be carefully tested to ensure a good detection at sensitivity level and to limit the number of false detections. Table 36. Recommended CAD configuration settings CadDetPeak[7:0] CadDetMin[7:0] 0x18 0x10 0x19...
Page 188
Sub-GHz radio (SUBGHZ) RM0453 type in Set_PacketType() sent prior to this function, the parameters for generic packets are interpreted as follows: • Br and Fdev are used for the transmission and reception. • Bw is used only for reception. • PulseShape represents the Gaussian filter that can be used to filter the modulation stream at the transmitter.
Page 191
RM0453 Sub-GHz radio (SUBGHZ) Generic Set_PacketParams() command Set_PacketParams(PbLength,PbDetLength,SynchWordLength,AddrComp, PktType,PayloadLength,CrcType,Whitening) is used to configure the packet handling for the sub-GHz radio. When the generic packet is selected with packet type in Set_PacketType() sent prior to this function, the parameters are interpreted as below. Opcode PbLength[15:0] PktType...
Page 192
Sub-GHz radio (SUBGHZ) RM0453 byte 8 bits 7:3 Reserved, must be kept at reset value. bits 2:0 CrcType[2:0]: CRC type definition The CRC initialization value is provided in SUBGHZ_GCRCINIRL and SUBGHZ_GCRCINIRH. The polynomial is defined in SUBGHZ_GCRCPOLRL and SUBGHZ_GCRCPOLRH. 0x0: 1-byte CRC 0x1: no CRC 0x2: 2-byte CRC 0x4: 1-byte inverted CRC...
Page 193
RM0453 Sub-GHz radio (SUBGHZ) byte 5 bits 7:1 Reserved, must be kept at reset value. bit 0 CrcType CRC enable 0: CRC disabled 1: CRC enabled byte 6 bits 7:1 Reserved, must be kept at reset value. bit 0 InvertIQ: IQ setup 0: standard IQ setup 1: inverted IQ setup BPSK Set_PacketParams() command...
Sub-GHz radio (SUBGHZ) RM0453 5.8.5 Communication status information commands Get_Status() command Get_Status(Status) can be issued at any time. Opcode Status[7:0] byte 0 bits 7:0 Opcode: 0xC0 byte 1 bit 7 Reserved, must be kept at reset value. bits 6:4 Status_Mode[2:0] sub-GHz radio operating mode 0x2: Standby mode with RC 13 MHz 0x3: Standby mode with HSE32 0x4: FS mode...
Page 195
RM0453 Sub-GHz radio (SUBGHZ) byte 1 bits 7:0 Status[7:0]: see Get_Status() command. byte 2 bits 7:0 RxPayloadLenght[7:0]: indicate the number of bytes received in the last received packet byte 3 bits 7:0 RxStartBufferPointer[7:0]: indicates the offset in the RAM data buffer where the first byte of the last received packet is stored (G)FSK Get_PacketStatus() command Get_PacketStatus(Status, RxStatus, RssiSync, RssiAvg) returns information...
Page 196
Sub-GHz radio (SUBGHZ) RM0453 byte 0 bits 7:0 Opcode: 0x14 byte 1 bits 7:0 Status[7:0]: see Get_Status() command byte 2 bits 7:0 RssiPkt[7:0]: Average RSSI level over the received packet Signal power = - RssiPkt / 2 (in dBm) byte 3 bits 7:0 SnrPkt[7:0]: Estimation of SNR over the received packet SNR = SnrPkt / 4 (in dB) byte 4...
RM0453 Sub-GHz radio (SUBGHZ) type in Set_PacketType() sent prior to this function, the parameters for LoRa packets are interpreted as below. Opcode Status[7:0] NbPktReceived[15:0] NbPktCrcError[15:0] NbPktHeaderError[15:0] byte 0 bits 7:0 Opcode: 0x10 byte 1 bits 7:0 Status[7:0]: see Get_Status() command bytes 3:2 bits 15:0 NbPktReceived[15:0]: Number of packets received bytes 5:4...
Sub-GHz radio (SUBGHZ) RM0453 byte 1 bit 7 Reserved, must be kept at reset value. bit 6 CalibCfg_Image: Image calibration 0: Image calibration disabled 1: Image calibration enabled bit 5 CalibCfg_AdcBulkP: RF-ADC bulk P calibration 0: RF-ADC bulk P calibration disabled 1: RF-ADC bulk P calibration enabled bit 4 CalibCfg_AdcBulkN: RF-ADC bulk N calibration 0: RF-ADC bulk N calibration disabled...
Page 201
RM0453 Sub-GHz radio (SUBGHZ) Opcode CalFreq1[7:0] CalFreq2[7:0] byte 0 bits 7:0 Opcode: 0x98 byte 1 bits 7:0 CalFreq1[7:0]: Lower frequency of the band to calibrate (see Table byte 2 bits 7:0 CalFreq2[7:0]: Higher frequency of the band to calibrate (see Table The calibration frequencies are computed as follows: Calibration...
Sub-GHz radio (SUBGHZ) RM0453 byte 0 bits 7:0 Opcode: 0x17 byte 1 bits 7:0 Status[7:0]: see Get_Status() command bytes 3:2 bits 15:9 Reserved, must be kept at reset value. bit 8 OpError_PaRampError: PA ramping failed bit 7 Reserved, must be kept at reset value. bit 6 OpError_PllLockError: RF-PLL locking failed bit 5 OpError_XoscStartError: HSE32 clock startup failed bit 4 OpError_ImageCalibrationError: Image calibration failed...
RM0453 Sub-GHz radio (SUBGHZ) Sub-GHz radio application configuration The sub-GHz radio is controlled via the SPI command interface. The following sections describe the basic sequence for some sub-GHz radio operations. After releasing the sub-GHz radio reset and waking it up with sub-GHz radio SPI NSS, the sub-GHz radio automatically performs a calibration and enters Standby mode.
Sub-GHz radio (SUBGHZ) RM0453 5.9.2 Basic sequence for LoRa and (G)FSK receive operation The sub-GHz radio can be set in LoRa or (G)FSK receive operation mode with the following steps: Define the location where the received payload data must be stored in the data buffer, with Set_BufferBaseAddress().
RM0453 Sub-GHz radio (SUBGHZ) 5.9.3 Basic sequence for BPSK transmit operation The sub-GHz radio can be set in BPSK transmit operation mode by the following steps: Define the location of the transmit payload data in the data buffer, with Set_BufferBaseAddress() Write the packet data (synchronization word, payload data) to the transmit data buffer with Write_Buffer().
Sub-GHz radio (SUBGHZ) RM0453 Bit 7 Reserved, must be kept at reset value. Bit 6 SBITSYNCEN: LoRa simple bit synchronization enable This bit must be cleared to 0 when using generic packet and BPSK type. 0: simple bit synchronization disabled 1: simple bit synchronization enabled Bit 5 RXDINV: LoRa receive data inversion This bit must be cleared to 0 when using generic packet and BPSK type.
RM0453 Sub-GHz radio (SUBGHZ) Bits 7:0 SYNCWORD[47:40]: Sixth byte of generic packet synchronization word 5.10.11 Sub-GHz radio generic synchronization word control register 4 (SUBGHZ_GSYNCR4) Address offset: 0x06C3 Reset value: 0x25 SYNCWORD[39:32] Bits 7:0 SYNCWORD[39:32]: Fifth byte of generic packet synchronization word 5.10.12 Sub-GHz radio generic synchronization word control register 3 (SUBGHZ_GSYNCR3)
Sub-GHz radio (SUBGHZ) RM0453 Bits 7:0 SYNCWORD[15:8]: Second byte of generic packet synchronization word 5.10.15 Sub-GHz radio generic synchronization word control register 0 (SUBGHZ_GSYNCR0) Address offset: 0x06C7 Reset value: 0x64 SYNCWORD[7:0] Bits 7:0 SYNCWORD[7:0]: First byte of generic packet synchronization word 5.10.16 Sub-GHz radio LoRa synchronization word MSB register (SUBGHZ_LSYNCRH)
RM0453 Sub-GHz radio (SUBGHZ) 5.10.18 Sub-GHz radio random number register 3 (SUBGHZ_RNGR3) Address offset: 0x0819 Reset value: 0x00 RNDATA[31:24] Bits 7:0 RNDATA[31:24]: Random number data bits [31:24] 5.10.19 Sub-GHz radio random number register 2 (SUBGHZ_RNGR2) Address offset: 0x081A Reset value: 0x00 RNDATA[23:16] Bits 7:0 RNDATA[23:16]: Random number data bits [23:16] 5.10.20...
Sub-GHz radio (SUBGHZ) RM0453 5.10.22 Sub-GHz radio receiver gain control register (SUBGHZ_RXGAINCR) Address offset: 0x08AC Reset value: 0x94 RXGAIN[5:0] PMODE[1:0] Bits 7:2 RXGAIN[5:0]: Receiver gain selection. Default gain 0x25. Bits 1:0 PMODE[1:0]: Receiver power mode selection between normal mode and power saving mode 00: power saving mode (reduced sensitivity) 10: normal mode (best receiver sensitivity) Others: reserved...
Sub-GHz radio (SUBGHZ) RM0453 5.10.27 Sub-GHz radio power control register (SUBGHZ_PCR) Address offset: 0x091A Reset value: 0x50 This register is retained in Sleep mode but lost in Deep-Sleep mode. Res. CLV[1:0] Res. Res. Res. Res. Bit 7 Reserved, must be kept at reset value. Bit 6 CLE: Power-supply current limiter enable 0: power-supply current limiter disabled (unlimited current) 1: power-supply current limiter enabled (current limited according to CLV[1:0])
RM0453 Power control (PWR) Power control (PWR) Power supplies The STM32WL5x devices require a V operating voltage supply between 1.71 V and 3.6 V. Several independent supplies (V ) can be provided for DDSMPS FBSMPS DDRF specific peripherals: • = 1.71 V to 3.6 V is the external power supply for the I/Os, the system analog blocks such as reset, power management, internal clocks and low-power regulator.
Power control (PWR) RM0453 VREF+ pin is not available on all packages. When not available, this pin is internally bonded to VDDA. When VREF+ is double-bonded with VDDA in a package, the internal voltage reference buffer is not available and must be kept disabled (refer to the datasheet for pinout descriptions).
RM0453 Power control (PWR) The different supply configurations are shown in the figure below. Figure 19. Supply configurations DDSMPS DDSMPS LDO/SMPS LDO/SMPS LXSMPS LXSMPS FBSMPS FBSMPS DDRF1V5 DDRF1V5 LDO/SMPS supply LDO supply MSv50974V1 The LDO or SMPS step-down converter operating mode can be configured by one of the following: •...
Power control (PWR) RM0453 The inrush current of the LDO and SMPS step-down converter can be controlled via the sub- GHz radio SUBGHZ_PCR register. This information is retained in all but the sub-GHz radio Deep-Sleep mode. For more details see Section 5: Sub-GHz radio (SUBGHZ).
RM0453 Power control (PWR) 6.1.2 Battery Backup domain To retain the content of the backup registers and supply the RTC and TAMP functions when is turned off, the VBAT pin can be connected to an optional backup voltage supplied by a battery or by another source.
Power control (PWR) RM0453 Backup domain access After a system reset, the Backup domain (RTC and TAMP backup registers) is protected against possible unwanted write accesses. The DBP bit must be set in the PWR control register 1 (PWR_CR1) to enable access to the Backup domain VBAT battery charging When V is present, It is possible to charge the external battery on VBAT through an...
RM0453 Power control (PWR) Dynamic voltage scaling to increase V is known as “overvolting”. It is used to improve CORE the device performance. Dynamic voltage scaling to decrease V is known as “undervolting”. It is used to save CORE power, particularly in laptop and other mobile devices where the energy comes from a battery and is thus limited.
Power control (PWR) RM0453 Figure 20. Brownout reset waveform 1. The reset temporization t is present only for the BOR lowest threshold (V RSTTEMPO BOR0 6.2.2 Programmable voltage detector (PVD) The PVD can be used to monitor V by comparing it to a threshold selected by the PLS[2:0] bits in the PWR control register 2 (PWR_CR2).
RM0453 Power control (PWR) Figure 21. PVD thresholds , or PVD_IN rise hysteresis fall PVDO PVDE SW enable PDR reset MS44481V1 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.
Power control (PWR) RM0453 The independent supply V is not considered as present by default and a logical and electrical isolation is applied to ignore any information coming from the peripherals supplied by these dedicated supplies: • If V is shorted externally to V , the application must assume that V is available without enabling any peripheral voltage monitoring.
RM0453 Power control (PWR) the SUBGHZSPI_NSS activity, and masks the RFBUSYS status low time (not busy) after an SPI command transfer (see the figure below). Figure 23. Radio busy management SUBGHZSPI_DATA SUBGHZSPI_NSS RFBUSY/RFBUSYS RFBUSYMS minimum RFBUSYSM delay EXTI RFBUSY interrupt (Stop, Run) WRFBUSYF wakeup (from Standby) MSv50975V1 At reset, the radio is busy (as signaled by the RFBUSY signal).
Power control (PWR) RM0453 CPU2 boot The CPU2 boot is controlled by the following sources: • from C2BOOT bit in PWR control register 4 (PWR_CR4) This allows the CPU1 to initialize the system after a reset or wakeup from system Low- power mode, before booting the CPU2.
Power control (PWR) RM0453 When CPU2 is prevented from booting (C2BOOT = 0, boot hold), the wakeup from low- power mode boot procedure is the following: • When the system is secure (ESE = 1) and the secure CPU2 boots after reset (POR/NRST or wakeup from Standby), CPU2 checks the reset source (C2BOOT or illegal access) in the C2BOOTS bit, as follows: –...
Page 233
RM0453 Power control (PWR) radio may remain active independently from the CPUs. Some peripherals with the wakeup capability can enable HSI16 RC during the Stop mode to detect their wakeup condition. Stop 1 offers the largest number of active peripherals and wakeup sources, a smaller wakeup time but a higher consumption compared with Stop 2.
Page 234
Power control (PWR) RM0453 The system operation mode depends on the CPU1 and the CPU2 sub-system operating mode. The system only enters a low-power mode when both sub-systems allow it to do so. After a system reset, CPU1 is in CRUN mode. CPU2 only boots if enabled by CPU1 via the C2BOOT bit, or when the system is secure on an illegal access detection.
RM0453 Power control (PWR) Figure 25. CPUs low-power modes possible transitions Sub-system modes Bus modes System modes LP-RUN Wakeup from STOP with CPU HOLD CPU2 sub-system having allocated peripheral in the HCLK1 domain CPU1 CRUN or CSLEEP CPU1 CSTOP C1_wakeup C1STOP CPU2 CRUN or CSLEEP CPU2 CRUN or CSLEEP...
Power control (PWR) RM0453 Table 44. Low-power mode summary Voltage Wakeup Wakeup regulators Mode name Entry Effect on clocks source system clock WFI or return CPU clock OFF Sleep Any interrupt Same as before from ISR (Sleep-now or No effect on other clocks entering Sleep mode Sleep-on-exit) or analog clock sources...
RM0453 Power control (PWR) 6. 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 that requested it. HSI16 is automatically put off when the peripheral does not need it anymore.
Power control (PWR) RM0453 Debug mode By default, the debug connection is lost if the application puts the MCU in Stop 0, Stop 1, Stop 2, Standby or Shutdown mode while the debug features are used. This is because the CPU core is no longer clocked.
RM0453 Power control (PWR) Refer to the product datasheet for more details on voltage regulator and peripherals operating conditions. I/O states in LPRun mode In LPRun mode, all I/O pins keep the same state as in Run mode. Enter LPRun mode To enter the LPRun mode, proceed as follows (refer to Table 47):...
Page 242
Power control (PWR) RM0453 mode was entered, as detailed below: • If the WFI instruction or return from ISR was used to enter the low-power mode, any peripheral interrupt acknowledged by the NVIC can wake up the device. • If the WFE instruction is used to enter the low-power mode, the CPU exits the low-power mode as soon as an event occurs.
RM0453 Power control (PWR) Table 48. CPU wakeup versus system operating mode CPU1 CPU2 System CPU1 wakeup CPU2 wakeup mode Wakeup from Run Wakeup from Run Wakeup from Stop, but system is Wakeup from Run already in Run due to CPU2 Wakeup from Stop, but system is Wakeup from Run already in Run due to CPU1...
Power control (PWR) RM0453 Table 49. Sleep mode Sleep mode Description WFI (wait for interrupt) or WFE (wait for event) while: – SLEEPDEEP = 0 – No interrupt (for WFI) or event (for WFE) is pending Refer to the Cortex system control register. Mode entry On return from ISR while: –...
RM0453 Power control (PWR) The table below details how to exit the LPSleep mode. Table 50. LPSleep LPSleep mode Description LPSleep mode is entered from the LPRun mode. WFI (wait for interrupt) or WFE (wait for event) while: – SLEEPDEEP = 0 –...
Page 246
Power control (PWR) RM0453 Enter Stop 0 mode The Stop 0 mode is entered according Section 6.5.3, when the SLEEPDEEP bit in the Cortex system control register is set (see Table 51). If Flash memory programming is ongoing, the Stop 0 mode entry is delayed until the operation is completed.
RM0453 Power control (PWR) When exiting the Stop 0 mode, the MCU is either in Run mode (range 1 or range 2 depending on VOS bit in PWR control register 1 (PWR_CR1)) or in LPRun mode if the bit LPR is set in the same register. Table 51.
Power control (PWR) RM0453 REGLPS bit can be used to check that the low-power regulator is ready (see the table below). Table 52. Stop 1 mode Stop 1 Description WFI (wait for interrupt) or WFE (wait for event) while: – SLEEPDEEP bit is set in Cortex system control register –...
Page 249
RM0453 Power control (PWR) SRAM1, SRAM2, PWR, Flash memory interface, RCC, GTZC TZSC, GTZC TZIC, EXTI, IPCC, IWDG, WWDG, GPIO, CRC, SYSCFG, RTC and TAMP contents and registers in the Backup domain are also preserved. The content of all other peripherals is reset and must be reprogrammed.
Power control (PWR) RM0453 exiting the Stop 2 mode, the MCU is in Run mode (range 1 or range 2 depending on VOS bit in PWR_CR1). Table 53. Stop 2 mode Stop 2 Description WFI (wait for interrupt) or WFE (wait for event) while: –...
Page 251
RM0453 Power control (PWR) I/O states in Standby mode In Standby mode, the I/Os can be configured either with a pull-up (refer to PWR_PUCRx registers (x = A, B, C, H)), or with a pull-down (refer to PWR_PDCRx registers (x = A, B, C, H)), or can be kept in analog state.
Power control (PWR) RM0453 Refer to the table below for more details on how to exit Standby mode. Table 54. Standby mode Standby Description WFI (wait for interrupt) or WFE (wait for event) while: – SLEEPDEEP bit is set in Cortex system control register –...
RM0453 Power control (PWR) In Shutdown mode, the following features can be selected by programming individual control bits: • Real-time clock (RTC): this is configured by the RTCEN bit in the Backup domain control register (RCC_BDCR). Caution: In case of V power-down, the RTC content is lost.
Power control (PWR) RM0453 following alternative RTC clock sources can be selected by programming the RTCSEL[1:0] bits in the RCC Backup domain control register (RCC_BDCR): • Low-power 32.768 kHz external crystal oscillator (LSE OSC) This clock source provides a precise time base with very low-power consumption. •...
Page 255
RM0453 Power control (PWR) Bits 31:15 Reserved, must be kept at reset value. Bit 14 LPR: LPRun When this bit is set, the supply mode is switched from main regulator mode (MR) to low- power regulator mode (LPR). Note: Stop 2 mode cannot be entered when LPR bit is set. Stop 1 is entered instead. Bits 13:11 Reserved, must be kept at reset value.
Power control (PWR) RM0453 Bit 4 FPDR: Flash memory power-down mode during LPRun for CPU1 This bit can only be written to 1 after unlocking this register bit, by first writing (code 0xC1B0) into this register (when writing the code, the register bits are not updated). Selects whether the Flash memory is in power-down mode or Idle mode when in LPRun mode.
RM0453 Power control (PWR) Bits 3:1 PLS[2:0]: Power voltage detector level selection. These bits select the voltage threshold detected by the power voltage detector: 000: V around 2.0 V PVD0 001: V around 2.2 V PVD1 010: V around 2.4 V PVD2 011: V around 2.5 V...
Page 258
Power control (PWR) RM0453 Bit 13 EWRFIRQ: radio IRQ[2:0] wakeup for CPU1 enable When this bit is set, the radio IRQ[2:0] is enabled and triggers a wakeup from Standby event to CPU1. Bit 12 Reserved, must be kept at reset value. Bit 11 EWRFBUSY: radio busy wakeup from Standby for CPU1 enable When this bit is set, the radio busy is enabled and triggers a wakeup from Standby event to CPU1 when a rising or a falling edge occurs.
RM0453 Power control (PWR) Bit 2 EWUP3: wakeup pin WKUP3 for CPU1 enable When this bit is set, the external wakeup pin WKUP3 is enabled and triggers an interrupt and wakeup from Stop, Standby or Shutdown event when a rising or a falling edge occurs to CPU1.
Power control (PWR) RM0453 Bit 9 VBRS: V battery charging resistor selection 0: V charging through a 5 kΩ resistor 1: V charging through a 1.5 kΩ resistor Bit 8 VBE: V battery charging enable 0: V battery charging disabled 1: V battery charging enabled Bits 7:3 Reserved, must be kept at reset value.
RM0453 Power control (PWR) Bit 11 WRFBUSYF: Radio busy wakeup flag This bit is set when a wakeup event is detected on radio busy. It is cleared by writing ‘1’ in the CWRFBUSYF bit of the PWR_SCR register. Bits 10:9 Reserved, must be kept at reset value. Bit 8 WPVDF: Wakeup PVD flag This bit is set when a wakeup event is detected on PVD.
Page 262
Power control (PWR) RM0453 Bit 10 VOSF: Voltage scaling flag A delay is required for the internal regulator to be ready after the voltage scaling has been changed. VOSF indicates that the regulator reached the voltage level defined with VOS bits of the PWR control register 1 (PWR_CR1).
RM0453 Power control (PWR) Bit 2 RFBUSYMS: Radio busy masked signal status This bit indicates the actual status of the radio busy masked signal. 0: radio busy masked signal low (not busy) 1: radio busy masked signal high (busy) Bit 1 RFBUSYS: Radio busy signal status This bit indicates the actual status of the radio busy signal.
Power control (PWR) RM0453 Bit 2 CWUF3: Clear wakeup flag 3 Setting this bit clears the WUF3 flag in the PWR_SR1 register. This bit is always read as 0. Bit 1 CWUF2: Clear wakeup flag 2 Setting this bit clears the WUF2 flag in the PWR_SR1 register. This bit is always read as 0. Bit 0 CWUF1: Clear wakeup flag 1 Setting this bit clears the WUF1 flag in the PWR_SR1 register.
RM0453 Power control (PWR) 6.6.9 PWR port A pull-up control register (PWR_PUCRA) This register is not reset when exiting Standby modes. Access: additional APB cycles are needed to access this register versus those needed for a standard APB access (three for a write and two for a read). Address offset: 0x020 Reset value: 0x0000 0000 Res.
Power control (PWR) RM0453 6.6.11 PWR port B pull-up control register (PWR_PUCRB) This register is not reset when exiting Standby modes. Access: additional APB cycles are needed to access this register versus those needed for a standard APB access (three for a write and two for a read). Address offset: 0x028 Reset value: 0x0000 0000 Res.
RM0453 Power control (PWR) 6.6.13 PWR port C pull-up control register (PWR_PUCRC) This register is not reset when exiting Standby modes. Access: additional APB cycles are needed to access this register versus those needed for a standard APB access (three for a write and two for a read). Address offset: 0x030 Reset value: 0x0000 0000 Res.
Power control (PWR) RM0453 Bits 15:13 PD[15:13]: Port PC[y] pull-down (y = 13 to 15) When set, each bit activates the pull-down on PC[y] when both APC bits are set in control register 3 (PWR_CR3) and in PWR CPU2 control register 3 (PWR_C2CR3).
RM0453 Power control (PWR) Bits 31:4 Reserved, must be kept at reset value. Bit 3 PD3: Port PH[3] pull-down When set, this bit activates the pull-down on PH[3] when both APC bits are set in control register 3 (PWR_CR3) and in PWR CPU2 control register 3 (PWR_C2CR3).
Power control (PWR) RM0453 Bit 3 Reserved, must be kept at reset value. Bits 2:0 LPMS[2:0]: Low-power mode selection for CPU2 These bits are not reset when exiting Standby mode. These bits select the low-power mode entered when CPU2 enters the Deep-Sleep mode. The system low-power mode entered depends also on the PWR_CR1.LPMS[2:0] allowed Low-power mode from CPU1.
RM0453 Power control (PWR) Bit 10 APC: Apply pull-up and pull-down configuration for CPU2 When this bit for CPU2, and the PWR_CR3.APC bit for CPU1, are set, the I/O pull-up and pull-down configurations defined in the PWR_PUCRx and PWR_PDCRx registers are applied.
Page 272
Power control (PWR) RM0453 Bits 31:16 Reserved, must be kept at reset value. Bit 15 C2DS: CPU2 Deep-Sleep mode This bit is set by hardware when CPU2 enters Deep-Sleep mode or is hold by C2BOOT. 0: CPU2 running or in sleep 1: CPU2 in Deep-Sleep or hold by C2BOOT Bit 14 C1DS: CPU1 Deep-Sleep mode This bit is set by hardware when CPU1 enters Deep-Sleep mode.
RM0453 Power control (PWR) 6.6.20 PWR security configuration register (PWR_SECCFGR) This register is not reset when exiting Standby modes. Access: three additional APB cycles are needed to write this register versus a standard APB write. This register can only be accessed by a secure privileged access for read and write. Non- secure and unprivileged accesses are ignored and return zero data.
Power control (PWR) RM0453 Bits 31:16 Reserved, must be kept at reset value. Bit 15 NSS: sub-GHz SPI NSS control This bit is set and cleared by software and is used to control the sub-GHz SPI NSS level from software. 0: sub-GHz SPI NSS signal at level low 1: sub-GHz SPI NSS signal is at level high Bits 14:0 Reserved, must be kept at reset value.
RM0453 Reset and clock control (RCC) Reset and clock control (RCC) Reset There are three types of reset, defined as system reset, power reset and Backup domain reset. 7.1.1 Power reset A power reset is generated when one of the following events occurs: •...
Reset and clock control (RCC) RM0453 In case on an internal reset, the internal pull-up R is deactivated in order to save the power consumption through the pull-up resistor. Figure 26. Simplified diagram of the reset circuit System reset External Filter reset NRST...
RM0453 Reset and clock control (RCC) 7.1.3 Backup domain reset The Backup domain has two specific resets. A Backup domain reset is generated when one of the following events occurs: • a software reset, triggered by setting the BDRST bit in the RCC Backup domain control register (RCC_BDCR) •...
Page 280
Reset and clock control (RCC) RM0453 Most peripheral clocks are derived from their bus clock (HCLK, PCLK) except the following: • The clock used for true RNG, is derived (selected by software) from one of the following sources: – PLL VCO (PLLQCLK) (only available in Run mode) –...
Page 281
RM0453 Reset and clock control (RCC) – LSI clock – HSE32 clock divided by 32 The functionality in Stop mode (including wakeup) is supported only when the clock is LSI or LSE. • The IWDG clock is always the LSI clock. The RCC feeds the CPU1 system timer (SysTick) external clock with the AHB clock (HCLK1) divided by eight.
RM0453 Reset and clock control (RCC) HSE32 is controlled from the CPUs and from the sub-GHz radio (see Section 5: Sub-GHz radio (SUBGHZ)). HSE32 can be switched on and off using the HSEON bit in the RCC clock control register (RCC_CR).
Reset and clock control (RCC) RM0453 Frequency trimming When using HSE32 with external crystal, the load capacitors are provided by the integrated capacitor banks, that can be trimmed. The HSE32 load capacitor trimming allows a compensation of device manufacturing process variations, used crystal and PCB design. The HSE32 frequency can be tuned in the application via the sub-GHz radio registers SUBGHZ_HSEINTRIMR and SUBGHZ_HSEOUTRIMR.
Calibration The 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 = 25 °C. After a reset, the factory calibration value is loaded in the HSICAL[7:0] bits in the internal clock sources calibration register (RCC_ICSCR).
Software calibration The MSI RC oscillator frequency 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 an ambient temperature T = 25 °C. After reset, the factory calibration value is loaded in the...
RM0453 Reset and clock control (RCC) An interrupt can be generated when the PLL is ready, if enabled in the RCC clock interrupt enable register (RCC_CIER). The PLLQCLK and PLLRCLK output frequency must not exceed 48 MHz. The PLLPCLK output frequency must not exceed 62 MHz. The enable bits of the PLL output clock (PLLPEN, PLLQEN, PLLREN) can be modified at any time without stopping the PLL.
Reset and clock control (RCC) RM0453 indicate when LSE system clock is ready (due clock synchronization) after having been enabled by the LSESYSEN. External source (LSE bypass) In this mode, an external clock source must be provided. It can have a frequency of up to 1 MHz.
RM0453 Reset and clock control (RCC) The system clock maximum frequency in range 1 is 48 MHz. After a system reset, the MSI oscillator, at 4 MHz, is selected as system clock. When a clock source is used directly or through the PLL as a system clock, it is not possible to stop it.
Reset and clock control (RCC) RM0453 the disabling of the HSE32 oscillator. If the HSE32 clock (divided or not) is the clock entry of the PLL used as system clock when the failure occurs, the PLL is disabled too. 7.2.11 Clock security system on LSE (LSECSS) A CSS on LSE can be activated by software writing the LSECSSON bit in the RCC Backup...
RM0453 Reset and clock control (RCC) 7.2.13 Sub-GHz radio SPI clock The sub-GHz radio SPI clock is derived from the PCLK3 clock. The SUBGHZSPI_SCK frequency is obtained by PCLK3 divided by two. The SUBGHZSPI_SCK clock maximum speed must not exceed 16 MHz. Table 60.
Reset and clock control (RCC) RM0453 The following cases are possible: • If the APB prescaler (PPREx) selects the PCLKx clock to be HCLK1 not divided, the timer clock frequencies are set to the HCLK1 frequency (timer clock = HCLK1). •...
RM0453 Reset and clock control (RCC) The configuration registers of the corresponding GPIO port must be programmed in alternate function mode. 7.2.20 Internal/external clock measurement with TIM16/TIM17 The frequency of all on-board clock sources can be indirectly measured by mean of the TIM16 or TIM17 channel 1 input capture, as shown in Figure 31 Figure...
Page 294
Reset and clock control (RCC) RM0453 The TIM17 input capture channel can be a GPIO line or an internal clock of the MCU. This selection is performed through the TI1_RMP[1:0] bits in the TIM17_OR register. The possibilities are listed below: •...
RM0453 Reset and clock control (RCC) 7.2.21 Peripheral clocks enable Most peripheral bus and kernel clocks can be individually enabled per CPU.The RCC_AHBxENR and RCC_APBxENRy registers enable peripheral clocks for CPU1. RCC_C2_AHBxENR and RCC_C2_APBxENR registers enable peripheral clocks for CPU2. The peripheral clocks follow the CPUs state for which it is enabled and the system state (see the table below).
Reset and clock control (RCC) RM0453 Low-power modes AHB and APB peripheral clocks, including DMA clock, can be disabled by software. Sleep and LPSleep modes stop the CPU clock. The memory interface clocks (Flash memory and SRAM1/2 interfaces) can be stopped during Sleep mode by software using the SRAMxSMEN bits.
Reset and clock control (RCC) RM0453 RCC registers 7.4.1 RCC clock control register (RCC_CR) Address offset: 0x000 Reset value: 0x0000 0061 Access: no wait state, word, half-word and byte access HSEBY Res. Res. Res. Res. Res. Res. PLLON Res. Res. Res.
Page 299
RM0453 Reset and clock control (RCC) Bit 17 HSERDY: HSE32 clock ready flag This bit is set and cleared by hardware to indicate that the HSE32 oscillator is stable or not. 0: HSE32 oscillator not ready 1: HSE32 oscillator ready Note: Once HSEON is cleared, HSERDY goes low after six HSE32 clock cycles.
Page 300
Reset and clock control (RCC) RM0453 Bit 8 HSION: HSI16 clock enable This bit is set and cleared by software. It is also cleared by hardware to stop the HSI16 oscillator when entering Stop, Standby or Shutdown mode. This bit is set by hardware to force the HSI16 oscillator on when STOPWUCK = 1 or HSIASFS = 1 when exiting Stop modes, or in case of HSE32 crystal oscillator failure.
RM0453 Reset and clock control (RCC) Bit 0 MSION: MSI clock enable This bit is set and cleared by software. It is also cleared by hardware to stop the MSI oscillator when entering Stop, Standby or Shutdown mode. This bit is set by hardware to force the MSI oscillator on when exiting Standby or Shutdown mode.
Reset and clock control (RCC) RM0453 7.4.3 RCC clock configuration register (RCC_CFGR) Address offset: 0x008 Reset value: 0x0007 0000 (after POR reset and after wakeup from Standby) Access: 0 ≤ wait state ≤ 2, word, half-word and byte access One or two wait states inserted only if the access occurs during clock source switch. From 0 to 15 wait states inserted if the access occurs when the APB or AHB prescalers values update is ongoing.
Page 303
RM0453 Reset and clock control (RCC) Bit 18 PPRE2F: PCLK2 prescaler flag (APB2) This bit is set and reset by hardware to acknowledge PCLK2 prescaler programming. It is reset when a new prescaler value is programmed in PPRE2 and set when the programmed value is actually applied.
Page 304
Reset and clock control (RCC) RM0453 Bits 7:4 HPRE[3:0]: HCLK1 prescaler (CPU1, AHB1, and AHB2.) These bits are set and cleared by software to control the division factor of the HCLK1 clock (CPU1, AHB1, AHB2). The HPREF flag can be checked to know if the programmed HPRE prescaler value is applied.
RM0453 Reset and clock control (RCC) 7.4.4 RCC PLL configuration register (RCC_PLLCFGR) Address offset: 0x00C Reset value: 0x2204 0100 Access: no wait state, word, half-word and byte access This register is used to configure the main PLL clock outputs according to the formulas: •...
Page 306
Reset and clock control (RCC) RM0453 Bits 27:25 PLLQ[2:0]: Main PLL division factor for PLLQCLK These bits are set and cleared by software to control the frequency of the main PLL output clock PLLQCLK. This output can be selected for True RNG clock. These bits can be written only if PLL is disabled.
Page 307
RM0453 Reset and clock control (RCC) Bits 14:8 PLLN[6:0]: Main PLL multiplication factor for VCO These bits are set and cleared by software to control the multiplication factor of the VCO. They can be written only when the PLL is disabled. VCO output frequency = VCO input frequency x PLLN with 6<...
RM0453 Reset and clock control (RCC) Bit 2 MSIRDYIE: MSI ready interrupt enable This bit is set and cleared by software to enable/disable interrupt caused by the MSI oscillator stabilization. 0: MSI ready interrupt disabled 1: MSI ready interrupt enabled Bit 1 LSERDYIE: LSE ready interrupt enable This bit is set and cleared by software to enable/disable interrupt caused by the LSE oscillator stabilization.
Reset and clock control (RCC) RM0453 Bit 4 HSERDYF: HSE32 ready interrupt flag This bit is set by hardware when the HSE32 clock becomes stable and HSERDYDIE is set. It is cleared by software setting the HSERDYC bit. 0: No clock ready interrupt caused by the HSE32 oscillator 1: Clock ready interrupt caused by the HSE32 oscillator Bit 3 HSIRDYF: HSI16 ready interrupt flag This bit is set by hardware when the HSI16 clock becomes stable and HSIRDYDIE is set in...
Page 311
RM0453 Reset and clock control (RCC) Bits 31:10 Reserved, must be kept at reset value. Bit 9 LSECSSC: LSE CSS flag clear This bit is set by software to clear the LSECSSF flag. 0: No effect 1: LSECSSF flag cleared Bit 8 CSSC: HSE32 CSS flag clear This bit is set by software to clear the HSE32 CSSF flag.
RM0453 Reset and clock control (RCC) Bits 31:8 Reserved, must be kept at reset value. Bit 7 GPIOHRST: IO port H reset This bit is set and cleared by software. 0: No effect 1: IO port H reset Bits 6:3 Reserved, must be kept at reset value. Bit 2 GPIOCRST: IO port C reset This bit is set and cleared by software.
Reset and clock control (RCC) RM0453 Bit 19 HSEMRST: HSEM reset This bit is set and cleared by software. 0: No effect 1: HSEM reset Bit 18 RNGRST: True RNG reset This bit is set and cleared by software. 0: No effect 1: True RNG reset Bit 17 AESRST: AES hardware accelerator reset This bit is set and cleared by software.
RM0453 Reset and clock control (RCC) Bit 23 I2C3RST: I2C3 reset This bit is set and cleared by software. 0: No effect 1: I2C3 reset Bit 22 I2C2RST: I2C2 reset This bit is set and cleared by software. 0: No effect 1: I2C2 reset Bit 21 I2C1RST: I2C1 reset This bit is set and cleared by software.
Reset and clock control (RCC) RM0453 Bits 31:7 Reserved, must be kept at reset value. Bit 6 LPTIM3RST: Low-power timer 3 reset This bit is set and cleared by software. 0: No effect 1: LPTIM3 reset Bit 5 LPTIM2RST: Low-power timer 2 reset This bit is set and cleared by software.
RM0453 Reset and clock control (RCC) Bit 12 SPI1RST: SPI1 reset This bit is set and cleared by software. 0: No effect 1: SPI1 reset Bit 11 TIM1RST: Timer 1 reset This bit is set and cleared by software. 0: No effect 1: TIM1 reset Bit 10 Reserved, must be kept at reset value.
Reset and clock control (RCC) RM0453 7.4.15 RCC AHB1 peripheral clock enable register (RCC_AHB1ENR) Address offset: 0x048 Reset value: 0x0000 0000 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 from CPU1 is not supported.
RM0453 Reset and clock control (RCC) 7.4.16 RCC AHB2 peripheral clock enable register (RCC_AHB2ENR) Address offset: 0x04C Reset value: 0x0000 0000 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 from CPU1 is not supported.
Reset and clock control (RCC) RM0453 7.4.17 RCC AHB3 peripheral clock enable register (RCC_AHB3ENR) Address offset: 0x050 Reset value: 0x0208 0000 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 from CPU1 is not supported.
RM0453 Reset and clock control (RCC) 7.4.18 RCC APB1 peripheral clock enable register 1 (RCC_APB1ENR1) Address offset: 0x058 Reset value: 0x0000 0000 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 from CPU1 is not supported.
Reset and clock control (RCC) RM0453 Bit 14 SPI2S2EN: CPU1 SPI2S2 clock enable This bit is set and cleared by software. 0: SPI2S2 clock disabled for CPU1 1: SPI2S2 clock enabled for CPU1 Bits 13:12 Reserved, must be kept at reset value. Bit 11 WWDGEN: CPU1 Window watchdog clock enable This bit is set by software to enable the window watchdog clock.
RM0453 Reset and clock control (RCC) Bits 31:7 Reserved, must be kept at reset value. Bit 6 LPTIM3EN: CPU1 Low-power timer 3 clocks enable This bit is set and cleared by software. 0: LPTIM3 bus and kernel clocks disabled for CPU1 1: LPTIM3 bus and kernel clocks enabled for CPU1 Bit 5 LPTIM2EN: CPU1 Low-power timer 2 clocks enable Set and cleared by software.
Reset and clock control (RCC) RM0453 Bit 13 Reserved, must be kept at reset value. Bit 12 SPI1EN: CPU1 SPI1 clock enable This bit is set and cleared by software. 0: SPI1 clock disabled for CPU1 1: SPI1 clock enabled for CPU1 Bit 11 TIM1EN: CPU1 TIM1 timer clock enable This bit is set and cleared by software.
Reset and clock control (RCC) RM0453 Bit 17 AESSMEN: AES accelerator clock enable during CPU1 CSleep mode. This bit is set and cleared by software. 0: AES clock disabled by the clock gating during CPU1 CSleep and CStop modes 1: AES clock enabled by the clock gating during CPU1 CSleep mode, disabled during CPU1 CStop mode Bit 16 PKASMEN: PKA accelerator clock enable during CPU1 CSleep mode.
Page 329
RM0453 Reset and clock control (RCC) Bit 22 I2C2SMEN: I2C2 clock enable during CPU1 CSleep and CStop modes This bit is set and cleared by software. 0: I2C2 bus clock disabled by the clock gating during CPU1 CSleep and CStop modes 1: I2C2 bus clock enabled by the clock gating during CPU1 CSleep mode, disabled during CPU1 CStop mode Bit 21 I2C1SMEN: I2C1 clock enable during CPU1 CSleep and CStop modes...
Reset and clock control (RCC) RM0453 Bit 10 Reserved, must be kept at reset value. Bit 9 ADCSMEN: ADC clocks enable during CPU1 CSleep and CStop modes This bit is set and cleared by software. 0: ADC bus clock disabled by the clock gating during CPU1 CSleep and CStop modes 1: ADC bus clock enabled by the clock gating during CPU1 CSleep mode, disabled during CPU1 CStop mode Bits 8:0 Reserved, must be kept at reset value.
RM0453 Reset and clock control (RCC) 7.4.29 RCC peripherals independent clock configuration register (RCC_CCIPR) Address offset: 0x088 Reset value: 0x0000 0000 Access: no wait states, word, half-word and byte access RNGSEL[1:0] ADCSEL[1:0] Res. Res. Res. Res. LPTIM3SEL[1:0] LPTIM2SEL[1:0] LPTIM1SEL[1:0] I2C3SEL[1:0] LPUART1SEL SPI2S2SEL USART2SEL...
Page 334
Reset and clock control (RCC) RM0453 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 01: System clock (SYSCLK) selected 10: HSI16 clock selected 11: Reserved Bits 15:14 I2C2SEL[1:0]: I2C2 clock source selection These bits are set and cleared by software to select the I2C2 clock source.
RM0453 Reset and clock control (RCC) 7.4.30 RCC Backup domain control register (RCC_BDCR) Address offset: 0x090 Reset value: 0x0000 0000 Reset by Backup domain reset, except LSCOSEL, LSCOEN and BDRST that are reset only by Backup domain power-on reset but not reset by wakeup from Standby and NRST pad. Access: 0 ≤...
Page 336
Reset and clock control (RCC) RM0453 Bit 11 LSESYSRDY: LSE system clock ready This bit is set and cleared by hardware to indicate when the LSE system clock is ready after the LSESYSEN bit is set. This bit is only valid when LSEON, LSERDY and LSESYSEN are set.
RM0453 Reset and clock control (RCC) Bit 2 LSEBYP: LSE oscillator bypass This bit is set and cleared by software to bypass the LSE oscillator. It can be written only when the external 32 kHz oscillator is disabled (LSEON = 0 and LSERDY = 0). 0: LSE oscillator not bypassed 1: LSE oscillator bypassed Bit 1 LSERDY: LSE oscillator ready...
Page 338
Reset and clock control (RCC) RM0453 Bit 31 LPWRRSTF: Low-power reset flag This bit is set by hardware when a reset occurs due to illegal Stop, Standby or Shutdown mode entry. It is 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...
Page 339
RM0453 Reset and clock control (RCC) Bit 15 RFRST: Sub-GHz radio reset This bit is set and cleared by software. 0: Sub-GHz radio software reset removed 1: Sub-GHz radio software reset active Bit 14 RFRSTF: Sub-GHz radio in reset status flag This bit is set and cleared by hardware.
Reset and clock control (RCC) RM0453 7.4.32 RCC extended clock recovery register (RCC_EXTCFGR) Address offset: 0x108 Reset value: 0x0003 0000 Access: no wait state, word, half-word and byte access Res. Res. Res. Res. Res. Res. Res. Res. Res. Res. Res. Res.
Page 341
RM0453 Reset and clock control (RCC) Bits 15:8 Reserved, must be kept at reset value. Bits 7:4 C2HPRE[3:0]: HCLK2 prescaler (CPU2) These bits are set and cleared by software to control the division factor of the HCLK2 clock (CPU2). The C2HPREF flag can be checked to know if the programmed C2HPRE prescaler value is applied.
Reset and clock control (RCC) RM0453 7.4.33 RCC CPU2 AHB1 peripheral clock enable register (RCC_C2AHB1ENR) Address offset: 0x148 Reset value: 0x0000 0000 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 from CPU2 is not supported.
RM0453 Reset and clock control (RCC) 7.4.34 RCC CPU2 AHB2 peripheral clock enable register (RCC_C2AHB2ENR) Address offset: 0x14C Reset value: 0x0000 0000 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 from CPU2 is not supported.
Reset and clock control (RCC) RM0453 7.4.35 RCC CPU2 AHB3 peripheral clock enable register (RCC_C2AHB3ENR) Address offset: 0x150 Reset value: 0x0208 0000 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 from CPU2 is not supported.
RM0453 Reset and clock control (RCC) 7.4.36 RCC CPU2 APB1 peripheral clock enable register 1 (RCC_C2APB1ENR1) Address offset: 0x158 Reset value: 0x0000 0000 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 from CPU2 is not supported.
Reset and clock control (RCC) RM0453 Bits 16:15 Reserved, must be kept at reset value. Bit 14 SPI2S2EN: CPU2 SPI2S2 clock enable This bit is set and cleared by software. 0: SPI2S2 clock disabled for CPU2 1: SPI2S2 clock enabled for CPU2 Bits 13:11 Reserved, must be kept at reset value.
RM0453 Reset and clock control (RCC) Bit 5 LPTIM2EN: CPU2 low-power timer 2 clocks enable This bit is set and cleared by software. 0: LPTIM2 bus and kernel clocks disabled for CPU2 1: LPTIM2 bus and kernel clocks enabled for CPU2 Bits 4:1 Reserved, must be kept at reset value.
Reset and clock control (RCC) RM0453 Bit 12 SPI1EN: CPU2 SPI1 clock enable This bit is set and cleared by software. 0: SPI1 clock disabled for CPU2 1: SPI1 clock enabled for CPU2 Bit 11 TIM1EN: CPU2 timer 1 clock enable This bit is set and cleared by software.
Reset and clock control (RCC) RM0453 Bit 17 AESSMEN: AES accelerator clock enable during CPU2 CSleep and CStop modes This bit is set and cleared by software. 0: AES clock disabled by the clock gating during CPU2 CSleep and CStop modes 1: AES clock enabled by the clock gating during CPU2 CSleep mode, disabled during CPU2 CStop mode Bit 16 PKASMEN: PKA accelerator clock enable during CPU2 CSleep and CStop modes...
Page 353
RM0453 Reset and clock control (RCC) Bit 22 I2C2SMEN: I2C2 clock enable during CPU2 CSleep and CStop modes This bit is set and cleared by software. 0: I2C2 bus clock disabled by the clock gating during CPU2 CSleep and CStop modes 1: I2C2 bus clock enabled by the clock gating during CPU2 CSleep mode, disabled during CPU2 CStop mode Bit 21 I2C1SMEN: I2C1 clock enable during CPU2 CSleep and CStop modes...
Reset and clock control (RCC) RM0453 Bit 10 Reserved, must be kept at reset value. Bit 9 ADCSMEN: ADC clocks enable during CPU2 CSleep and CStop modes This bit is set and cleared by software. 0: ADC bus clock disabled by the clock gating during CPU2 CSleep and CStop modes 1: ADC bus clock enabled by the clock gating during CPU2 CSleep mode, disabled during CPU2 CStop mode Bits 8:0 Reserved, must be kept at reset value.
RM0453 Hardware semaphore (HSEM) Hardware semaphore (HSEM) Introduction The hardware semaphore block provides 16 (32-bit) register based semaphores. The semaphores can be used to ensure synchronization between different processes running between different cores. The HSEM provides a non blocking mechanism to lock semaphores in an atomic way.
Hardware semaphore (HSEM) RM0453 Functional description 8.3.1 HSEM block diagram As shown in Figure 33, the HSEM is based on three sub-blocks: • The semaphore block containing the semaphore status and IDs • The semaphore interface block providing AHB access to the semaphore via the HSEM_Rx and HSEM_RLRx registers •...
RM0453 Hardware semaphore (HSEM) The semaphore is free when its LOCK bit is 0. In this case, the COREID and PROCID are also 0. When the LOCK bit is 1, the semaphore is locked and the COREID indicates which AHB bus master ID has locked it. The PROCID indicates which process of that AHB bus master ID has locked the semaphore.
Hardware semaphore (HSEM) RM0453 1-step (read) lock procedure The 1-step procedure consists in a read to lock and check the semaphore in a single step, carried out from the HSEM_RLRx register. • Read lock semaphore with the AHB bus master COREID. •...
RM0453 Hardware semaphore (HSEM) 8.3.6 HSEM COREID semaphore clear All semaphores locked by a COREID can be unlocked at once by using the HSEM_CR register. Write COREID and correct KEY value in HSEM_CR. All locked semaphores with a matching COREID are unlocked, and may generate an interrupt when enabled. Note: This procedure may be used in case of an incorrect functioning AHB bus master ID, where another AHB bus master can unlock the locked semaphores by writing the COREID of the...
Hardware semaphore (HSEM) RM0453 Figure 35. Interrupt state diagram Semaphore x locked WRITE (COREID & PROCID & LOCK = 0) Interrupt Semaphore x Status = 1 Interrupt Semaphore x Enabled Interrupt Semaphore x MaskedStatus = 1 & Interrupt generated Semaphore x free MS40533V3 The procedure to get an interrupt when a semaphore becomes free is described hereafter.
RM0453 Hardware semaphore (HSEM) On semaphore x free interrupt, try to lock semaphore x • If the semaphore lock is obtained: Disable the semaphore x interrupt in HSEM_CnIER. Clear pending semaphore x interrupt status in HSEM_CnICR. • If the semaphore x lock fails: Clear pending semaphore x interrupt status in HSEM_CnICR.
Hardware semaphore (HSEM) RM0453 HSEM registers Registers must be accessed using word format. Byte and half-word accesses are ignored and have no effect on the semaphores. Byte and half-word read accesses always return 0. Byte and half-word accesses do not generate a bus error. 8.4.1 HSEM register semaphore x (HSEM_Rx) Address offset: 0x000 + 0x4 * x (x = 0 to 15)
RM0453 Hardware semaphore (HSEM) 8.4.2 HSEM read lock register semaphore x (HSEM_RLRx) Address offset: 0x080 + 0x004 * x (x = 0 to 15) Reset value: 0x0000 0000 Accesses the same physical bits as HSEM_Rx. The HSEM_RLRx must be used to perform a 1-step read lock.
RM0453 Hardware semaphore (HSEM) Bits 31:16 Reserved, must be kept at reset value. Bits 15:0 ISF[15:0]: Interrupt semaphore x status bit before enable (mask) (x = 0 to 15) This bit is set by hardware, and reset only by software. This bit is cleared by software writing the corresponding HSEM_CnICR bit.
Hardware semaphore (HSEM) RM0453 Bits 31:16 KEY[15:0]: Semaphore clear key This field can be written by software and is always read 0. If this key value does not match HSEM_KEYR.KEY, semaphores are not affected. If this key value matches HSEM_KEYR.KEY, all semaphores matching the COREID are cleared to the free state.
RM0453 Inter-processor communication controller (IPCC) Inter-processor communication controller (IPCC) IPCC introduction The inter-processor communication controller (IPCC) is used for communicating data between two processors. The IPCC block provides a non blocking signaling mechanism to post and retrieve communication data in an atomic way. It provides the signaling for twelve channels: •...
Inter-processor communication controller (IPCC) RM0453 The channel operation mode must be known to both processors. A common parameter can be used to indicate the channel transfer mode and must also be located in a known common area. This parameter is not available from the IPCC. 9.3.1 IPCC block diagram The IPCC (see...
RM0453 Inter-processor communication controller (IPCC) Table 68. Bits used for the communication Processor IPCC_C1CR.TXFIE IPCC_C2CR.RXOIE IPCC_C1MR.CHnFM IPCC_C2MR.CHnOM SEND A = 1 RECEIVE B = 2 IPCC_C1SCR.CHnS IPCC_C2SCR.CHnC IPCC_C1TOC2SR.CHnF IPCC_C2CR.TXFIE IPCC_C1CR.RXOIE IPCC_C2MR.CHnFM IPCC_C1MR.CHnOM SEND A = 2 RECEIVE B = 1 IPCC_C2SCR.CHnS IPCC_C1SCR.CHnC IPCC_C2TOC1SR.CHnF...
Inter-processor communication controller (IPCC) RM0453 Once the processor A retrieved the response from the memory, it does not change the channel status flags. The memory location access is kept by processor A for the next communication data. Figure 40. IPCC Half-duplex channel mode transfer timing Write Write Read...
RM0453 Inter-processor communication controller (IPCC) To send communication data: • The sending processor waits for its response pending software variable to get 0. – Once the response pending software variable is 0 the communication data is posted. • Once the complete communication data has been posted, the channel status flag CHnF is set to occupied with CHnS and the response pending software variable is set to 1 (this gives memory access and generates the RX occupied interrupt to the receiving processor).
Inter-processor communication controller (IPCC) RM0453 To receive the response the channel free interrupt is unmasked (CHnFM = 0): • On a TX free interrupt, the sending processor checks which channel became free, masks the associated channel free interrupt (CHnFM) and reads the response from the memory.
RM0453 Inter-processor communication controller (IPCC) Bits 31:17 Reserved, must be kept at reset value. Bit 16 TXFIE: Processor 1 transmit channel free interrupt enable Associated with IPCC_C1TOC2SR. 1: Enable an unmasked processor 1 transmit channel free to generate a TX free interrupt. 0: Processor 1 TX free interrupt disabled Bits 15:1 Reserved, must be kept at reset value.
Inter-processor communication controller (IPCC) RM0453 9.4.9 IPCC register map Table 69. IPCC register map and reset values Register name Offset Reset value IPCC_C1CR 0x0000 Reset value IPCC_C1MR 0x0004 Reset value IPCC_C1SCR 0x0008 Reset value IPCC_C1TOC2SR 0x000C Reset value IPCC_C2CR 0x0010 Reset value IPCC_C2MR 0x0014...
RM0453 General-purpose I/Os (GPIO) General-purpose I/Os (GPIO) 10.1 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 one 32-bit set/reset register (GPIOx_BSRR). All GPIOs have a 32-bit locking register (GPIOx_LCKR) and two 32-bit alternate function selection registers (GPIOx_AFRH and GPIOx_AFRL).
General-purpose I/Os (GPIO) RM0453 GPIOx_BSRR and GPIOx_BRR registers allow atomic read/modify accesses to any of the GPIOx_ODR registers. In this way, there is no risk of an IRQ occurring between the read and the modify access. Figure 43 Figure 44 show the basic structure of a standard and a 5V-tolerant I/O port bit.
General-purpose I/Os (GPIO) RM0453 Table 70. Port bit configurations (continued) MODE(i)[1:0] OTYPER(i) OSPEED(i)[1:0] PUPD(i)[1:0] I/O configuration Input Floating Input Input Reserved (input floating) Input/output Analog Reserved 1. GP = general purpose, PP = push-pull, PU = pull-up, PD = pull-down, OD = open drain, AF = alternate function. 10.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...
RM0453 General-purpose I/Os (GPIO) Specific alternate function assignments for each pin are detailed in the product datasheet. In addition to this flexible I/O multiplexing architecture, each peripheral has alternate functions mapped on different I/O pins to optimize the number of peripherals available in smaller packages.
General-purpose I/Os (GPIO) RM0453 To each bit in GPIOx_ODR correspond two control bits in GPIOx_BSRR, BS(i) and BR(i): • When written to 1, BS(i) sets the corresponding ODR(i) bit. • When written to 1, BR(i) resets the ODR(i) corresponding bit. Writing any bit to 0 in GPIOx_BSRR does not have any effect on the corresponding bit in GPIOx_ODR.
RM0453 General-purpose I/Os (GPIO) 10.3.9 Input configuration When the I/O port is programmed as input, the following occurs: • 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.
RM0453 General-purpose I/Os (GPIO) 10.3.12 Analog configuration When the I/O port is programmed as analog configuration, the following occurs: • 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). •...
General-purpose I/Os (GPIO) RM0453 10.3.15 Using PH3 as GPIO PH3 may be used as boot pin (BOOT0) or as GPIO. PH3 switches from the input mode to the analog input mode depending on the nSWBOOT0 bit in the user option byte as follows: •...
RM0453 General-purpose I/Os (GPIO) Bits 9:8 MODE4[1:0]: Port Px4 IO type configuration Bits 7:6 MODE3[1:0]: Port Px3 IO type configuration Bits 5:4 MODE2[1:0]: Port Px2 IO type configuration Bits 3:2 MODE1[1:0]: Port Px1 IO type configuration Bits 1:0 MODE0[1:0]: Port Px0 IO type configuration These bits are written by software to configure the I/O mode.
RM0453 General-purpose I/Os (GPIO) 10.4.8 GPIOx configuration lock register (GPIOx_LCKR) (x = A to B) Address offset: Block A: 0x001C Address offset: Block B: 0x041C Reset value: 0x0000 0000 This register is used to lock the configuration of the port bits when a correct write sequence is applied to bit 16 (LCKK).
RM0453 General-purpose I/Os (GPIO) Bits 19:16 AFSEL12[3:0]: Port Px12 alternate function selection Bits 15:12 AFSEL11[3:0]: Port Px11 alternate function selection Bits 11:8 AFSEL10[3:0]: Port Px10 alternate function selection Bits 7:4 AFSEL9[3:0]: Port Px9 alternate function selection Bits 3:0 AFSEL8[3:0]: Port Px8 alternate function selection These bits are written by software to configure alternate function I/Os 0x0: AF0 selected 0x1: AF1 selected...
General-purpose I/Os (GPIO) RM0453 Bits 31:30 MODE15[1:0]: Port PC15 IO type configuration Bits 29:28 MODE14[1:0]: Port PC14 IO type configuration Bits 27:26 MODE13[1:0]: Port PC13 IO type configuration Bits 25:14 Reserved, must be kept at reset value. Bits 13:12 MODE6[1:0]: Port PC6 IO type configuration Bits 11:10 MODE5[1:0]: Port PC5 IO type configuration Bits 9:8 MODE4[1:0]: Port PC4 IO type configuration Bits 7:6 MODE3[1:0]: Port PC3 IO type configuration...
RM0453 General-purpose I/Os (GPIO) Bit 2 OT2: Port PC2 output type configuration Bit 1 OT1: Port PC1 output type configuration Bit 0 OT0: Port PC0 output type configuration These bits are written by software to configure the I/O output type. 0: Output push-pull (reset state) 1: Output open-drain 10.4.14...
RM0453 General-purpose I/Os (GPIO) Bit 13 ID13: Port PC13 input data bit Bits 12:7 Reserved, must be kept at reset value. Bit 6 ID6: Port PC6 input data bit Bit 5 ID5: Port PC5 input data bit Bit 4 ID4: Port PC4 input data bit Bit 3 ID3: Port PC3 input data bit Bit 2 ID2: Port PC2 input data bit Bit 1 ID1: Port PC1 input data bit...
RM0453 General-purpose I/Os (GPIO) 10.4.19 GPIOC configuration lock register (GPIOC_LCKR) Address offset: 0x081C Reset value: 0x0000 0000 This register is used to lock the configuration of the port bits when a correct write sequence is applied to bit 16 (LCKK). The value of bits [15:0] is used to lock the configuration of the GPIO.
General-purpose I/Os (GPIO) RM0453 Bit 2 LCK2: Port PC2 lock configuration Bit 1 LCK1: Port PC1 lock configuration Bit 0 LCK0: Port PC0 lock configuration This bit is read/write but can only be written when the LCKK bit is 0. 0: Port PC0 configuration not locked 1: Port PC0 configuration locked 10.4.20...
General-purpose I/Os (GPIO) RM0453 Bit 2 BR2: Port PC2 reset output data bit [2] in GPIOC_ODR Bit 1 BR1: Port PC1 reset output data bit [1] in GPIOC_ODR Bit 0 BR0: Port PC0 reset output data bit [0] in GPIOC_ODR These bits are read clear-write 1.
RM0453 General-purpose I/Os (GPIO) Bits 31:4 Reserved, must be kept at reset value. Bit 3 OT3: Port PH3 output type configuration These bits are written by software to configure the I/O output type. 0: Output push-pull (reset state) 1: Output open-drain Bits 2:0 Reserved, must be kept at reset value.
General-purpose I/Os (GPIO) RM0453 Bits 31:8 Reserved, must be kept at reset value. Bits 7:6 PUPD3[1:0]: Port PH3 pull configuration 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 Bits 5:0 Reserved, must be kept at reset value.
General-purpose I/Os (GPIO) RM0453 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 PH configuration lock key not active 1: Port PH configuration lock key active.
System configuration controller (SYSCFG) RM0453 System configuration controller (SYSCFG) 11.1 SYSCFG main features STM32WL5x 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 •...
System configuration controller (SYSCFG) RM0453 Bits 15:9 Reserved, must be kept at reset value. Bit 8 BOOSTEN: I/O analog switch voltage booster enable 0: I/O analog switches are supplied by V voltage. This is the recommended configuration when using the ADC in high V voltage operation.
System configuration controller (SYSCFG) RM0453 Bits 10:8 EXTI6[2:0]: EXTI6 configuration bits These bits are written by software to select the source input for the EXTI6 external interrupt. 000: PA6 pin 001: PB6 pin 010: PC6 pin 011: Reserved 100: Reserved 101: Reserved 110: Reserved 111: Reserved...
Page 433
RM0453 System configuration controller (SYSCFG) Bits 31:15 Reserved, must be kept at reset value. Bits 14:12 EXTI11[2:0]: EXTI11 configuration bits These bits are written by software to select the source input for the EXTI11 external interrupt. 000: PA11 pin 001: PB11 pin 010: Reserved 011: Reserved 100: Reserved...
System configuration controller (SYSCFG) RM0453 Bits 7:2 Reserved, must be kept at reset value. Bit 1 SRAMBSY: SRAM1 or SRAM2 busy by erase operation 0: No SRAM1 or SRAM2 erase operation is ongoing. 1: SRAM1 or SRAM2 erase operation is ongoing. Section 2.4: SRAM erase for more information on SRAM erase conditions Bit 0 SRAM2ER: SRAM2 erase...
RM0453 System configuration controller (SYSCFG) Bit 2 PVDL: PVD lock enable bit This bit is set by software and cleared only by a system reset. It can be used to enable and lock the PVD connection to TIM1/16/17 break input, as well as the PVDE and PLS[2:0] in the PWR_CR2R register.
Page 441
RM0453 System configuration controller (SYSCFG) Bit 31 EXTI15IM: EXTI15 interrupt mask to CPU2 0: EXTI15 interrupt forwarded to CPU2 1. EXTI15 interrupt to CPU2 masked Bit 30 EXTI14IM: EXTI14 interrupt mask to CPU2 Bit 29 EXTI13IM: EXTI13 interrupt mask to CPU2 Bit 28 EXTI12IM: EXTI12 interrupt mask to CPU2 Bit 27 EXTI11IM: EXTI11 interrupt mask to CPU2 Bit 26 EXTI10IM: EXTI10 interrupt mask to CPU2...
System configuration controller (SYSCFG) RM0453 Bit 5 RCCIM: RCC interrupt mask to CPU2 0: RCC interrupt forwarded to CPU2 1. RCC interrupt to CPU2 masked Bit 4 Reserved, must be kept at reset value. Bit 3 RTCWKUPIM: RTCWKUP interrupt mask to CPU2 0: RTCWKUP interrupt forwarded to CPU2 1.
RM0453 System configuration controller (SYSCFG) Bit 14 DMA2CH7IM: DMA2CH7 interrupt mask to CPU2 0: DMA2CH7 interrupt forwarded to CPU2 1. DMA2CH7 interrupt to CPU2 masked Bit 13 DMA2CH6IM: DMA2CH6 interrupt mask to CPU2 Bit 12 DMA2CH5IM: DMA2CH5 interrupt mask to CPU2 Bit 11 DMA2CH4IM: DMA2CH4 interrupt mask to CPU2 Bit 10 DMA2CH3IM: DMA2CH3 interrupt mask to CPU2 Bit 9 DMA2CH2IM: DMA2CH2 interrupt mask to CPU2...
System configuration controller (SYSCFG) RM0453 11.2.16 SYSCFG register map The following table summarizes the SYSCFG register map and the reset values. Table 75. SYSCFG register map and reset values Offset Register SYSCFG_ MEMRMP 0x000 Reset value SYSCFG_CFGR1 0x004 Reset value EXTI3 EXTI2 EXTI1...
Page 445
RM0453 System configuration controller (SYSCFG) Table 75. SYSCFG register map and reset values (continued) Offset Register SYSCFG_IMR1 0x100 Reset value SYSCFG_IMR2 0x104 Reset value SYSCFG_C2IMR1 0x108 Reset value SYSCFG_C2IMR2 0x10C Reset value 0x110 to Reserved Reserved 0x204 SYSCFG_RFDCR 0x208 Reset value Refer to Section 2.6 for the register boundary addresses.
Peripherals interconnect matrix RM0453 Peripherals interconnect matrix 12.1 Introduction Several peripherals have direct connections between them, enabling autonomous communication and/or synchronization between them. This saves CPU resources and, consequently power consumption. In addition, these hardware connections remove software latency and result in more predictable system design. Depending on peripherals, these interconnections can operate in Run, Sleep, LPRun, LPSleep, Stop 0, Stop 1 and Stop 2 modes.
RM0453 Peripherals interconnect matrix (1) (2) Table 76. STM32WL5x peripherals interconnect matrix (continued) Destination Source COMP1 COMP2 SYST ERR 1. Numbers in this table are links to corresponding subsections of Section 12.3: Interconnection details. The “-” symbol in grayed cells means no interconnect. 12.3 Interconnection details 12.3.1...
Peripherals interconnect matrix RM0453 12.3.2 From timer (LPTIM1/LPTIM2) to timer (LPTIM3) Purpose Some timers are linked together internally for synchronization or chaining. When one timer is configured in Master mode, it can reset, start, stop or clock the counter of another timer configured in Slave mode.
RM0453 Peripherals interconnect matrix 12.3.4 From timer (LPTIM1/LPTIM2) to DAC Purpose Low-power timer LPTIM1/LPTIM2 can be used to generate an DAC trigger event. DAC triggering is described in Section 19.4.7: DAC trigger selection. Triggering signals The output from low-power timer is on signals LPTIMx_OUT event. The input to DAC is on signals dac_ch1_trg[15:0].
Peripherals interconnect matrix RM0453 External clock LSE can be used as input to general-purpose timers (TIM2) on TIM2_ETR pin (see TIM2 option register 1 (TIM2_OR1)). Active power modes Run, Sleep, LPRun, LPSleep 12.3.7 From RTC, TAMP, COMP1, COMP2 to low-power timers (LPTIM1/LPTIM2) Purpose RTC alarm A/B, TAMP_IN1/2/3 input detection and COMP1/2_OUT can be used as trigger...
RM0453 Peripherals interconnect matrix 12.3.9 From internal analog to ADC Purpose Internal temperature sensor (V ), Internal reference voltage (V ) and V monitoring REFINT channel are connected to ADC input channel. This is according to the following sections: • Section 18.2: ADC main features •...
Peripherals interconnect matrix RM0453 12.3.11 From system errors to timers (TIM1/TIM16/TIM17) Purpose CSS, CPU hard fault, RAM parity error, FLASH ECC double error detection and PVD can generate system errors in the form of timer break toward timers (TIM1/TIM16/TIM17). The purpose of the break function is to protect power switches driven by PWM signals generated by the timers.
RM0453 Peripherals interconnect matrix 12.3.14 From timer (LPTIM3) to sub-GHz radio SPI NSS Purpose Low-power timer LPTIM3 can be used to generate a sub-GHz radio SPI NSS event. Triggering signals The output from low-power timer is on signal LPTIM3_OUT event. The connection between timers and sub-GHz radio SPI NSS is provided in PWR sub-GHz SPI control register...
Direct memory access controller (DMA) RM0453 Direct memory access controller (DMA) 13.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.
RM0453 Direct memory access controller (DMA) The DMA controller performs direct memory transfer by sharing the AHB system bus with other system masters. The bus matrix implements round-robin scheduling. DMA requests 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).
Direct memory access controller (DMA) RM0453 The request/acknowledge protocol is used when a peripheral is either the source or the destination of the transfer. For example, in case of memory-to-peripheral transfer, the peripheral initiates the transfer by driving its single request signal to the DMA controller. The DMA controller reads then a single data in the memory and writes this data to the peripheral.
RM0453 Direct memory access controller (DMA) 13.4.5 DMA channels Each channel may handle a DMA transfer between a peripheral register located at a fixed address, and a memory address. The amount of data items to transfer is programmable. The register that contains the amount of data items to transfer is decremented after each transfer.
Page 460
Direct memory access controller (DMA) RM0453 When a channel x is configured in secure mode, the following access controls rules are applied: • A non-secure read access to a register field of this channel is forced to return 0, except for both the secure state and the privileged state of this channel x (SECM and PRIV bits of the DMA_CCRx register) which are readable by a non-secure software.
Page 461
RM0453 Direct memory access controller (DMA) When a channel is configured in a privileged (or unprivileged) mode, the AHB master transfers from the source and to the destination, are privileged (respectively unprivileged). DMA generates a privileged bus, dma_priv[7:0], reflecting the PRIV bit of the DMA_CCRx register, in order to keep the other hardware peripherals, like DMAMUX, informed of the privileged / unprivileged state of each DMA channel x.
Page 462
Direct memory access controller (DMA) RM0453 The three following use cases may happen: • Suspend and resume a channel This corresponds to the two following actions: – An active channel is disabled by software (writing DMA_CCRx.EN = 0 whereas DMA_CCRx.EN = 1). –...
Page 463
RM0453 Direct memory access controller (DMA) Memory-to-memory mode The DMA channels may operate without being triggered by a request from a peripheral. This mode is called memory-to-memory mode, and is initiated by software. If the MEM2MEM bit in the DMA_CCRx register is set, the channel, if enabled, initiates transfers.
Direct memory access controller (DMA) RM0453 13.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 Table Table 79. Programmable data width and endian behavior (when PINC = MINC = 1) Source Destinat Destination...
RM0453 Direct memory access controller (DMA) 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:...
Direct memory access controller (DMA) RM0453 13.5 DMA interrupts An interrupt can be generated on a half transfer, transfer complete or transfer error for each DMA channel x (whatever the channel is secure or non-secure). Separate interrupt enable bits are available for flexibility. Table 80.
Page 467
RM0453 Direct memory access controller (DMA) Bits 31:28 Reserved, must be kept at reset value. 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...
Page 468
Direct memory access controller (DMA) RM0453 Bit 13 TCIF4: transfer complete (TC) flag for channel 4 0: no TC event 1: a TC event occurred 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...
RM0453 Direct memory access controller (DMA) 13.6.2 DMA interrupt flag clear register (DMA_IFCR) Address offset: 0x04 Reset value: 0x0000 0000 This register may mix secure and non secure information, depending on the secure mode of each channel (SECM bit of the DMA_CCRx register). A secure software is able to set any flag clear bit of the DMA_IFCR, and order DMA hardware to clear any corresponding flag(s) in the DMA_ISR register.
Direct memory access controller (DMA) RM0453 Bit 20 CGIF6: global interrupt flag clear for channel 6 Bit 19 CTEIF5: transfer error flag clear for channel 5 Bit 18 CHTIF5: half transfer flag clear for channel 5 Bit 17 CTCIF5: transfer complete flag clear for channel 5 Bit 16 CGIF5: global interrupt flag clear for channel 5 Bit 15 CTEIF4: transfer error flag clear for channel 4 Bit 14 CHTIF4: half transfer flag clear for channel 4...
Page 471
RM0453 Direct memory access controller (DMA) Setting any of the DSEC or SSEC bits must be performed by a secure write access to this register. Except SECM and PRIV control bits, any other register field is non-readable by a non-secure software if the SECM bit is set, and non-readable by an unprivileged software if the PRIV bit is set.
Page 472
Direct memory access controller (DMA) RM0453 Bit 18 SSEC: security of the DMA transfer from the source This bit can only be accessed - read, set or cleared - by a secure software. It must be a privileged software if the channel is in privileged mode. This bit is cleared by hardware when the securely written data bit 17 is cleared (on a secure reconfiguration of the channel as non -secure).
Page 473
RM0453 Direct memory access controller (DMA) 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 474
Direct memory access controller (DMA) RM0453 Bit 6 PINC: peripheral increment mode Defines the increment mode for each DMA transfer to the identified peripheral. n memory-to-memory mode, this field identifies the memory destination if DIR = 1 and the memory source if DIR = 0. In peripheral-to-peripheral mode, this field identifies the peripheral destination if DIR = 1 and the peripheral source if DIR = 0.
RM0453 Direct memory access controller (DMA) Bit 2 HTIE: half transfer interrupt enable 0: disabled 1: enabled Note: This bit is set and cleared by software (privileged/secure software if the channel is in privileged/secure mode). It must not be written when the channel is enabled (EN = 1). It is not read-only when the channel is enabled (EN = 1).
Direct memory access controller (DMA) RM0453 13.6.5 DMA channel x peripheral address register (DMA_CPARx) Address offset: 0x10 + 0x14 * (x - 1), (x = 1 to 7) Reset value: 0x0000 0000 PA[31:16] PA[15:0] Bits 31:0 PA[31:0]: peripheral address It contains the base address of the peripheral data register from/to which the data is read/written.
RM0453 Direct memory access controller (DMA) Bits 31:0 MA[31:0]: peripheral address It contains the base address of the memory from/to which the data is read/written. When MSIZE[1:0] = 01 (16 bits), bit 0 of MA[31:0] is ignored. Access is automatically aligned to a half-word address.
Page 478
Direct memory access controller (DMA) RM0453 Table 81. DMA register map and reset values (continued) Offset Register DMA_CCR3 0x030 Reset value DMA_CNDTR3 NDT[17:0] 0x034 Reset value DMA_CPAR3 PA[31:0] 0x038 Reset value DMA_CMAR3 MA[31:0] 0x03C Reset value 0x040 Reserved Reserved. DMA_CCR4 0x044 Reset value DMA_CNDTR4...
Page 479
RM0453 Direct memory access controller (DMA) Table 81. DMA register map and reset values (continued) Offset Register DMA_CNDTR7 NDT[17:0] 0x084 Reset value DMA_CPAR7 PA[31:0] 0x088 Reset value DMA_CMAR7 MA[31:0] 0x08C Reset value Refer to Section 2.6 for the register boundary addresses. RM0453 Rev 1 479/1461...
DMA request multiplexer (DMAMUX) RM0453 DMA request multiplexer (DMAMUX) 14.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.
DMA request multiplexer (DMAMUX) RM0453 Table 82. DMAMUX instantiation (continued) Feature DMAMUX1 Number of DMAMUX synchronization inputs Number of DMAMUX peripheral request inputs DMAMUX security support 14.3.2 DMAMUX1 mapping The mapping of resources to DMAMUX1 is hardwired. DMAMUX1 is used with DMA1 and DMA2 •...
DMA request multiplexer (DMAMUX) RM0453 14.4.4 DMAMUX secure/non-secure channels The DMAMUX is a security-aware peripheral , partitioning all its resources so that they exist in one of the two worlds: the secure world and the normal/non-secure world, at any given time.
Page 487
RM0453 DMA request multiplexer (DMAMUX) A DMA request is sourced either from the peripherals or from the DMAMUX request generator. The DMAMUX request line multiplexer channel x selects the DMA request line number as configured by the DMAREQ_ID field in the DMAMUX_CxCR register. Note: The null value in the field DMAREQ_ID corresponds to no DMA request line selected.
RM0453 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) RM0453 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 491
RM0453 DMA request multiplexer (DMAMUX) Table 87. DMAMUX interrupts (continued) Interrupt signal Interrupt event Event flag Clear bit Enable bit Synchronization event overrun on a secure channel x of the SOFx CSOFx SOIE DMAMUX request line multiplexer dmamux_sec_ovr_it Trigger event overrun on a secure channel x of the COFx DMAMUX request generator...
DMA request multiplexer (DMAMUX) RM0453 14.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. 14.6.1 DMAMUX request line multiplexer channel x configuration register (DMAMUX_CxCR)
DMA request multiplexer (DMAMUX) RM0453 depending on the privileged control bit of the connected DMA controller channel y, and considering that the DMAMUX x channel output is connected to the y channel of the DMA (refer to the DMAMXUX mapping implementation section). Res.
DMA request multiplexer (DMAMUX) RM0453 14.6.6 DMAMUX request generator interrupt clear flag register (DMAMUX_RGCFR) Address offset: 0x144 Reset value: 0x0000 0000 This register shall be written at bit level by a non-secure or secure write, according to the secure mode of the considered DMAMUX request line multiplexer channel y it is assigned to, and considering that the DMAMUX request generator x channel output is selected by the y channel of the DMAMUX request line channel (refer to DMAMUX_CyCR.DMAREQ_ID[7:0] and to the DMAMXUX mapping implementation...
RM0453 DMA request multiplexer (DMAMUX) 14.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 88. DMAMUX register map and reset values Offset Register DMAREQ_ID[6:0]...
Extended interrupts and event controller (EXTI) RM0453 Extended interrupts and event controller (EXTI) The extended interrupts and event controller (EXTI) manages the individual CPU and system wakeup through configurable and direct event inputs. It provides wakeup requests to the power control and generates an interrupt request to the CPU NVIC and events to the CPU event input.
RM0453 Extended interrupts and event controller (EXTI) The masking block provides the event input distribution to the different wakeup, interrupt and event outputs, and the masking of these. Figure 54. EXTI block diagram AHB interface Registers hclk sys_wakeup c1_wakeup c2_wakeup it_exti_per(y) Wakeup Direct event(x) or...
Extended interrupts and event controller (EXTI) RM0453 16.3 EXTI connections between peripherals and CPU The peripherals able to generate wakeup or interrupt events when the system is in Stop mode, are connected to the EXTI. Peripheral wakeup signals that generate a pulse or that do not have an interrupt status bits in the peripheral, are connected to an EXTI configurable event input.
Page 509
RM0453 Extended interrupts and event controller (EXTI) Table 93. Wakeup interrupts (continued) EXTI Acronym Description EXTI type Event Wakeup EXTI[14] EXTI line 14 from SYSCFG Configurable CPU1 and CPU2 EXTI[15] EXTI line 15 from SYSCFG Configurable CPU1 and CPU2 PVD line Configurable CPU1 and CPU2 RTC_ALARM...
Extended interrupts and event controller (EXTI) RM0453 Table 93. Wakeup interrupts (continued) EXTI Acronym Description EXTI type Event Wakeup Radio Busy RFBUSY wakeup Configurable CPU1 and CPU2 CDBGPWRUPREQ Debug power-up request wakeup Direct CPU1 and CPU2 1. For correct operation, the EXTI direct event EXTI_C2IMRm.IMb bit must be set to 0 before CPU1 uses this di- rect event.
RM0453 Extended interrupts and event controller (EXTI) 1. Only for input events with configuration “rxev generation” enabled. 16.4.1 EXTI configurable event input wakeup The extended interrupt/event block diagram for configurable events is shown in Figure The configurable events allow the system and CPU wakeup from Sleep and Stop modes, and provide a pending flag in the EXTI.
Extended interrupts and event controller (EXTI) RM0453 The direct events do not have an associated EXTI interrupt. The EXTI only wakes up the system and CPU sub-system clocks and may generate a CPU wakeup event. The peripheral synchronous interrupt associated with the direct wakeup event, wake up the CPU.
RM0453 Extended interrupts and event controller (EXTI) interrupt signal is activated. The EXTI_PR pending bit must be set to 1 by software. This clears the it_exti_per(y) interrupt. For direct event inputs, when enabled in the associated peripheral, an event request is generated on the rising edge only.
Extended interrupts and event controller (EXTI) RM0453 Bits 31:23 Reserved, must be kept at reset value. Bit 22 RT22: rising trigger event configuration bit of configurable event input 22 0: Rising trigger disabled (for event and interrupt) for input line 1: Rising trigger enabled (for event and interrupt) for input line Note: The configurable event inputs are edge triggered.
RM0453 Extended interrupts and event controller (EXTI) Bits 31:23 Reserved, must be kept at reset value. Bit 22 FT22: falling trigger event configuration bit of configurable event input 22 0: falling trigger disabled (for event and interrupt) for input line 1: falling trigger enabled (for event and interrupt) for input line Note: The configurable event inputs are edge triggered.
Extended interrupts and event controller (EXTI) RM0453 Bits 31:23 Reserved, must be kept at reset value. Bit 22 SWI22: Software interrupt on line 22 A software interrupt is generated independently from the setting in EXTI_RTSR and EXTI_FTSR. This bit always returns 0 when read. 0: Writing 0 has no effect.
RM0453 Extended interrupts and event controller (EXTI) Bits 31:23 Reserved, must be kept at reset value. Bit 22 PIF22: pending bit on event input 22 These bits are set when the selected edge event or an EXTI_SWIER software trigger arrives on the configurable event line.
Extended interrupts and event controller (EXTI) RM0453 Bits 31:14 Reserved, must be kept at reset value. Bit 13 RT45: rising trigger event configuration bit of configurable event input 45 0: Rising trigger disabled (for event and interrupt) for input line 1: Rising trigger enabled (for event and interrupt) for input line Note: The configurable event inputs are edge triggered.
Extended interrupts and event controller (EXTI) RM0453 Bits 31:14 Reserved, must be kept at reset value. Bit 13 PIF45: pending bit on event input 45 These bits are set when the selected edge event or an EXTI_SWIER software trigger arrives on the configurable event line.
RM0453 Extended interrupts and event controller (EXTI) Bits 31:23 Reserved, must be kept at reset value. Bit 22 EM22: wakeup with event generation mask on event input 22 0: Event request from line 22 is masked. 1: Event request from line 22 is unmasked. Bit 21 EM21: wakeup with event generation mask on event input 21 Bit 20 EM20: wakeup with event generation mask on event input 20 Bit 19 EM19: wakeup with event generation mask on event input 19...
Extended interrupts and event controller (EXTI) RM0453 Bits 31:15 Reserved, must be kept at reset value. Bit 14 IM46: wakeup with interrupt mask on event input 46 0: Wakeup with interrupt request from line 46 is masked. 1: Wakeup with interrupt request from line 46 is unmasked. Bit 13 IM45: wakeup with interrupt mask on event input 45 Bit 12 IM44: wakeup with interrupt mask on event input 44 Bit 11 IM43: wakeup with interrupt mask on event input 43...
RM0453 Extended interrupts and event controller (EXTI) 16.6.13 EXTI register map The following table gives the EXTI register map and reset values. Table 97. EXTI register map and reset values Offset Register name EXTI_RTSR1 0x000 Reset value EXTI_FTSR1 0x004 Reset value EXTI_SWIER1 0x008 Reset value...
Page 524
Extended interrupts and event controller (EXTI) RM0453 Table 97. EXTI register map and reset values (continued) Offset Register name EXTI_C2IMR2 0x0D0 Reset value EXTI_C2EMR2 0x0D4 Reset value Refer to Section 2.6 for the register boundary addresses. 524/1461 RM0453 Rev 1...
RM0453 Cyclic redundancy check calculation unit (CRC) Cyclic redundancy check calculation unit (CRC) 17.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) RM0453 17.3 CRC functional description 17.3.1 CRC block diagram Figure 57. 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 17.3.2 CRC internal signals...
Page 527
RM0453 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: •...
Cyclic redundancy check calculation unit (CRC) RM0453 17.4 CRC registers 17.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.
Analog-to-digital converter (ADC) RM0453 Analog-to-digital converter (ADC) 18.1 Introduction The 12-bit ADC is a successive approximation analog-to-digital converter. It has up to 18 multiplexed channels allowing it to measure signals from 12 external and 4 internal sources. A/D conversion of the various channels can be performed in single, continuous, scan or discontinuous mode.
RM0453 Analog-to-digital converter (ADC) 18.2 ADC main features • High performance – 12-bit, 10-bit, 8-bit or 6-bit configurable resolution – ADC conversion time: 0.4 µs for 12-bit resolution (2.5Msps), faster conversion times can be obtained by lowering resolution. – Self-calibration –...
RM0453 Analog-to-digital converter (ADC) Table 101. ADC internal input/output signals Internal signal Signal type Description name Analog Input Connected either to internal channels or to ADC_INi channels external channels TRGx Input ADC conversion triggers Input Internal temperature sensor output voltage Input Internal voltage reference output voltage REFINT...
Analog-to-digital converter (ADC) RM0453 If the main voltage regulator enters low-power mode (such as Low-power run mode), this buffer is disabled and the ADC cannot be used. ADC Voltage regulator enable sequence To enable the ADC voltage regulator, set ADVREGEN bit to 1 in ADC_CR register. ADC voltage regulator disable sequence To disable the ADC voltage regulator, follow the sequence below: Make sure that the ADC is disabled (ADEN = 0).
RM0453 Analog-to-digital converter (ADC) Figure 59. ADC calibration t CAB ADCAL ADC State Startup CALIBRATE CALIBRATION 0x00 ADC_DR[6:0] FACTOR ADC_CALFACT[6:0] by S/W by H/W MS33703V1 Calibration factor forcing Software Procedure Ensure that ADEN = 1 and ADSTART = 0 (ADC started with no conversion ongoing) Write ADC_CALFACT with the saved calibration factor The calibration factor is used as soon as a new conversion is launched.
Analog-to-digital converter (ADC) RM0453 Follow this procedure to enable the ADC: Clear the ADRDY bit in ADC_ISR register by programming this bit to 1. Set ADEN = 1 in the ADC_CR register. Wait until ADRDY = 1 in the ADC_ISR register (ADRDY is set after the ADC startup time).
RM0453 Analog-to-digital converter (ADC) 18.3.5 ADC clock (CKMODE, PRESC[3:0]) The ADC has a dual clock-domain architecture, so that the ADC can be fed with a clock (ADC asynchronous clock) independent from the APB clock (PCLK). Figure 62. ADC clock scheme ADITF (Reset &...
Analog-to-digital converter (ADC) RM0453 Table 103. Latency between trigger and start of conversion Latency between the trigger event ADC clock source CKMODE[1:0] and the start of conversion HSI16, SYSCLK or Latency is not deterministic (jitter) PLLPCLK Latency is deterministic (no jitter) and equal to PCLK divided by 2 3.25 ADC clock cycles Latency is deterministic (no jitter) and equal to...
Analog-to-digital converter (ADC) RM0453 18.3.7 Configuring the ADC Software must write to the ADCAL and ADEN bits in the ADC_CR register if the ADC is disabled (ADEN must be 0). Software must only write to the ADSTART and ADDIS bits in the ADC_CR register only if the ADC is enabled and there is no pending request to disable the ADC (ADEN = 1 and ADDIS = 0).
RM0453 Analog-to-digital converter (ADC) – Any channel can belong to in these sequences • Sequencer fully configurable The CHSELRMOD bit is set in ADC_CFGR1 register. – Sequencer length is up to 8 channels – The order in which the channels are scanned is independent from the channel number.
Analog-to-digital converter (ADC) RM0453 18.3.10 Single conversion mode (CONT In Single conversion mode, the ADC performs a single sequence of conversions, converting all the channels once. This mode is selected when CONT = 0 in the ADC_CFGR1 register. Conversion is started by either: •...
RM0453 Analog-to-digital converter (ADC) 18.3.12 Starting conversions (ADSTART) Software starts ADC conversions by setting ADSTART = 1. When ADSTART is set, the conversion: • Starts immediately if EXTEN = 00 (software trigger) • At the next active edge of the selected hardware trigger if EXTEN ≠ 00 The ADSTART bit is also used to indicate whether an ADC operation is currently ongoing.
Analog-to-digital converter (ADC) RM0453 18.3.13 Timings 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: = [1.5 + 12.5 ] x t CONV SMPL...
RM0453 Analog-to-digital converter (ADC) 18.3.14 Stopping an ongoing conversion (ADSTP) The software can decide to stop any ongoing conversions by setting ADSTP = 1 in the ADC_CR register. This resets the ADC operation and the ADC is idle, ready for a new operation. When the ADSTP bit is set by software, any ongoing conversion is aborted and the result is discarded (ADC_DR register is not updated with the current conversion).
Analog-to-digital converter (ADC) RM0453 Refer to Table 102: External triggers Section 18.3.1: ADC pins and internal signals for the list of all the external triggers that can be used for regular conversion. The software source trigger events can be generated by setting the ADSTART bit in the ADC_CR register.
Analog-to-digital converter (ADC) RM0453 18.4.6 Low frequency trigger mode Once the ADC is enabled or the last ADC conversion is complete, the ADC is ready to start a new conversion. The ADC needs to be started at a predefined time (t ) otherwise ADC idle converted data might be corrupted due to the transistor leakage (refer to the device...
RM0453 Analog-to-digital converter (ADC) When an overrun condition occurs, the ADC keeps operating and can continue to convert unless the software decides to stop and reset the sequence by setting the ADSTP bit in the ADC_CR register. The OVR flag is cleared by software by writing 1 to it. It is possible to configure if the data is preserved or overwritten when an overrun event occurs by programming the OVRMOD bit in the ADC_CFGR1 register: •...
Analog-to-digital converter (ADC) RM0453 18.5.3 Managing a sequence of data converted without using the DMA If the conversions are slow enough, the conversion sequence can be handled by software. In this case the software must use the EOC flag and its associated interrupt to handle each data result.
RM0453 Analog-to-digital converter (ADC) When the DMA transfer is complete (all the transfers configured in the DMA controller have been done): • The content of the ADC data register is frozen. • Any ongoing conversion is aborted and its partial result discarded •...
Analog-to-digital converter (ADC) RM0453 18.7 Analog window watchdog (AWD1EN, AWD1SGL, AWD1CH, Analog voltage Higher threshold Guarded area Lower threshold MS45396V1 ADC_AWDxCR, ADC_AWDxTR) The three AWD analog watchdogs monitor whether some channels remain within a configured voltage range (window). 18.7.1 Description of analog watchdog 1 AWD1 analog watchdog is enabled by setting the AWD1EN bit in the ADC_CFGR1 register.
RM0453 Analog-to-digital converter (ADC) Figure 76. Analog watchdog guarded area Analog voltage Higher threshold Guarded area Lower threshold MS45396V1 Table 107. Analog watchdog 1 channel selection Channels guarded by the analog watchdog AWD1SGL bit AWD1EN bit None All channels Single channel 1.
Analog-to-digital converter (ADC) RM0453 ADC_AWDx_OUT is activated when the associated analog watchdog is enabled: • ADC_AWDx_OUT is set when a guarded conversion is outside the programmed thresholds. • ADC_AWDx_OUT is reset after the end of the next guarded conversion which is inside the programmed thresholds.
Analog-to-digital converter (ADC) RM0453 Figure 80. Analog watchdog threshold update ADC state Conversion Conversion Conversion Conversion Threshould updated LTx, HTx XXXX XXXY XXXZ Masked Active Active Comparison MSv45365V1 18.8 Oversampler The oversampling unit performs data preprocessing to offload the CPU. It can handle multiple conversions and average them into a single data with increased data width, up to 16-bit.
RM0453 Analog-to-digital converter (ADC) Figure 82 gives a numerical example of the processing, from a raw 20-bit accumulated data to the final 16-bit result. Figure 82. Numerical example with 5-bits shift and rounding Raw 20-bit data: Final result after 5-bits shift and rounding to nearest MS31929V1 Table 108...
Analog-to-digital converter (ADC) RM0453 18.8.1 ADC operating modes supported when oversampling In oversampling mode, most of the ADC operating modes are available: • Single or continuous mode conversions, forward or backward scanned sequences and up to 8 channels programmed sequence •...
ADC V [13] input channel. REFINT The precise voltage of V is individually measured for each part by ST during REFINT production test and stored in the system memory area. Figure 84 shows the block diagram of connections between the temperature sensor, the internal voltage reference and the ADC.
Analog-to-digital converter (ADC) RM0453 Main features • Supported temperature range: –40 to 125 °C • Linearity: ±2 °C max., precision depending on calibration Figure 84. Temperature sensor and V channel block diagram REFINT TSEN control bit Temperature sensor ADC V [12] converted data VREFEN control bit...
RM0453 Analog-to-digital converter (ADC) Calculating the actual V voltage using the internal reference voltage REF+ voltage may be subject to variation or not precisely known. The embedded internal REF+ reference voltage (V ) and its calibration data acquired by the ADC during the REFINT manufacturing process at V can be used to evaluate the actual V...
Analog-to-digital converter (ADC) RM0453 the correct operation of the ADC, the V pin is internally connected to a bridge divider. This bridge is automatically enabled when VBATEN is set, to connect V to the ADC [14] input channel. As a consequence, the converted digital value is half the V voltage.
Page 569
RM0453 Analog-to-digital converter (ADC) Table 109. ADC interrupts (continued) Interrupt event Event flag Enable control bit Analog watchdog 2 status bit is set AWD2 AWD2IE Analog watchdog 3 status bit is set AWD3 AWD3IE Channel Configuration Ready CCRDY CCRDYIE End of sampling phase EOSMP EOSMPIE Overrun...
Analog-to-digital converter (ADC) RM0453 18.12 ADC registers Refer to Section 1.2 for a list of abbreviations used in register descriptions. 18.12.1 ADC interrupt and status register (ADC_ISR) Address offset: 0x00 Reset value: 0x0000 0000 Res. Res. Res. Res. Res. Res. Res.
Page 571
RM0453 Analog-to-digital converter (ADC) Bit 7 AWD1: Analog watchdog 1 flag This bit is set by hardware when the converted voltage crosses the values programmed in ADC_TR1 and ADC_HR1 registers. It is cleared by software by programming it to 1. 0: No analog watchdog event occurred (or the flag event was already acknowledged and cleared by software) 1: Analog watchdog event occurred...
Page 573
RM0453 Analog-to-digital converter (ADC) Bit 4 OVRIE: Overrun interrupt enable This bit is set and cleared by software to enable/disable the overrun interrupt. 0: Overrun interrupt disabled 1: Overrun interrupt enabled. An interrupt is generated when the OVR bit is set. Note: The software is allowed to write this bit only when ADSTART bit is cleared to 0 (this ensures that no conversion is ongoing).
Page 575
RM0453 Analog-to-digital converter (ADC) Bit 2 ADSTART: ADC start conversion command This bit is set by software to start ADC conversion. Depending on the EXTEN [1:0] configuration bits, a conversion either starts immediately (software trigger configuration) or once a hardware trigger event occurs (hardware trigger configuration).
Page 577
RM0453 Analog-to-digital converter (ADC) Bits 20:17 Reserved, must be kept at reset value. Bit 16 DISCEN: Discontinuous mode This bit is set and cleared by software to enable/disable discontinuous mode. 0: Discontinuous mode disabled 1: Discontinuous mode enabled Note: It is not possible to have both discontinuous mode and continuous mode enabled: it is forbidden to set both bits DISCEN = 1 and CONT = 1.
Page 578
Analog-to-digital converter (ADC) RM0453 Bits 8:6 EXTSEL[2:0]: External trigger selection These bits select the external event used to trigger the start of conversion (refer to Table 102: External triggers for details): 000: TRG0 001: TRG1 010: TRG2 011: TRG3 100: TRG4 101: TRG5 110: TRG6 111: TRG7...
Page 579
RM0453 Analog-to-digital converter (ADC) Bit 2 SCANDIR: Scan sequence direction This bit is set and cleared by software to select the direction in which the channels is scanned in the sequence. It is effective only if CHSELMOD bit is cleared to 0. 0: Upward scan (from CHSEL0 to CHSEL17) 1: Backward scan (from CHSEL17 to CHSEL0) Note: The software is allowed to write this bit only when ADSTART bit is cleared to 0 (this...
RM0453 Analog-to-digital converter (ADC) Bits 8:5 OVSS[3:0]: Oversampling shift This bit is set and cleared by software. 0000: No shift 0001: Shift 1-bit 0010: Shift 2-bits 0011: Shift 3-bits 0100: Shift 4-bits 0101: Shift 5-bits 0110: Shift 6-bits 0111: Shift 7-bits 1000: Shift 8-bits Others: Reserved Note: The software is allowed to write this bit only when ADSTART = 0 (which ensures that no...
Analog-to-digital converter (ADC) RM0453 Bits 31:26 Reserved, must be kept at reset value. Bits 25:8 SMPSEL[17:0] Channel-x sampling time selection These bits are written by software to define which sampling time is used. 0: Sampling time of CHANNELx use the setting of SMP1[2:0] register. 1: Sampling time of CHANNELx use the setting of SMP2[2:0] register.
RM0453 Analog-to-digital converter (ADC) Bits 31:28 Reserved, must be kept at reset value. Bits 27:16 HT1[11:0]: Analog watchdog 1 higher threshold These bits are written by software to define the higher threshold for the analog watchdog. Refer to Section 18.7: Analog window watchdog (AWD1EN, AWD1SGL, AWD1CH, ADC_AWDxCR, ADC_AWDxTR) on page 558.
Analog-to-digital converter (ADC) RM0453 18.12.9 ADC channel selection register [alternate] (ADC_CHSELR) Address offset: 0x28 Reset value: 0x0000 0000 The same register can be used in two different modes: – Each ADC_CHSELR bit enables an input (CHSELRMOD = 0 in ADC_CFGR1). Refer to the current section.
RM0453 Analog-to-digital converter (ADC) 18.12.10 ADC channel selection register [alternate] (ADC_CHSELR) Address offset: 0x28 Reset value: 0x0000 0000 The same register can be used in two different modes: – Each ADC_CHSELR bit enables an input (CHSELRMOD = 0 in ADC_CFGR1). Refer to the current previous section.
Page 586
Analog-to-digital converter (ADC) RM0453 Bits 19:16 SQ5[3:0]: 5th conversion of the sequence These bits are programmed by software with the channel number (0...14) assigned to the 8th conversion of the sequence. 0b1111 indicates end of the sequence. When 0b1111 (end of sequence) is programmed to the lower sequence channels, these bits are ignored.
RM0453 Analog-to-digital converter (ADC) 18.12.11 ADC watchdog threshold register (ADC_AWD3TR) Address offset: 0x2C Reset value: 0x0FFF 0000 Res. Res. Res. Res. HT3[11:0] Res. Res. Res. Res. LT3[11:0] Bits 31:28 Reserved, must be kept at reset value. Bits 27:16 HT3[11:0]: Analog watchdog 3 higher threshold These bits are written by software to define the higher threshold for the analog watchdog.
Page 590
Analog-to-digital converter (ADC) RM0453 Bits 31:25 Reserved, must be kept at reset value. Bit 24 VBATEN: V enable This bit is set and cleared by software to enable/disable the V channel. 0: V channel disabled 1: V channel enabled Note: The software is allowed to write this bit only when ADSTART = 0 (which ensures that no conversion is ongoing) Bit 23 TSEN: Temperature sensor enable This bit is set and cleared by software to enable/disable the temperature sensor.
RM0453 Digital-to-analog converter (DAC) Digital-to-analog converter (DAC) 19.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) RM0453 Table 112. DAC input/output pins Pin name Signal type Remarks Input, analog reference The higher/positive reference voltage for the DAC, VREF+ positive ≤ V (refer to datasheet) REF+ DDAmax Input, analog supply Analog power supply Input, analog supply ground Ground for analog power supply DACx_OUT1 Analog output signal DACx channel1 analog output...
RM0453 Digital-to-analog converter (DAC) 19.4.4 DAC data format Depending on the selected configuration mode, the data have to be written into the specified register as described below: • Single DAC channel There are three possibilities: – 8-bit right alignment: the software has to load data into the DAC_DHR8R1[7:0] bits (stored into the DHR1[11:4] bits) –...
Digital-to-analog converter (DAC) RM0453 Figure 88. Timing diagram for conversion with trigger disabled TEN = 0 Bus clock 0x1AC Output voltage available on 0x1AC DAC_OUT pin tSETTLING MSv45319V2 19.4.6 DAC output voltage Digital inputs are converted to output voltages on a linear conversion between 0 and V REF+ The analog output voltage on the DAC channel pin is determined by the following equation: ×...
RM0453 Digital-to-analog converter (DAC) DMA underrun The DAC DMA request is not queued so that if a second external trigger arrives before the acknowledgment for the first external trigger is received (first request), then no new request is issued and the DMA channel1 underrun flag DMAUDR1 in the DAC_SR register is set, reporting the error condition.
Digital-to-analog converter (DAC) RM0453 Figure 90. DAC conversion (SW trigger enabled) with LFSR wave generation dac_pclk 0x00 0xD55 0xAAA SWTRIG MS45320V1 Note: The DAC trigger must be enabled for noise generation by setting the TEN1 bit in the DAC_CR register. 19.4.10 Triangle-wave generation It is possible to add a small-amplitude triangular waveform on a DC or slowly varying signal.
RM0453 Digital-to-analog converter (DAC) Figure 92. DAC conversion (SW trigger enabled) with triangle wave generation dac_pclk 0xABE 0xABE 0xABF 0xAC0 SWTRIG MS45321V1 Note: The DAC trigger must be enabled for triangle wave generation by setting the TEN1 bit in the DAC_CR register.
Digital-to-analog converter (DAC) RM0453 The sample/hold mode operations can be divided into 3 phases: Sample phase: the sample/hold element is charged to the desired voltage. The charging time depends on capacitor value (internal or external, selected by the user). The sampling time is configured with the TSAMPLE1[9:0] bits in DAC_SHSR1 register. During the write of the TSAMPLE1[9:0] bits, the BWST1 bit in DAC_SR register is set to 1 to synchronize between both clocks domains (APB and low speed clock) and allowing the software to change the value of sample phase during the DAC channel...
RM0453 Digital-to-analog converter (DAC) Refresh phase: = 7 μs + (2000 * 100 * 10 ) * ln(2*10) = 606.1 μs REFRESH (where N = 10 (10 LSB drop during the hold phase) Hold phase: = 0.0073 V (10 LSB of 12bit at 3 V) leak hold = 150 nA (worst case on the IO leakage on all the temperature range)
Digital-to-analog converter (DAC) RM0453 Table 116. Channel output modes summary MODE [2:0] Mode Buffer Output connections Connected to external pin Enabled Connected to external pin and to on chip-peripherals (such as comparators) Normal mode Connected to external pin Disabled Connected to on chip peripherals (such as comparators) Connected to external pin Enabled Connected to external pin and to on chip peripherals (such as...
RM0453 Digital-to-analog converter (DAC) In addition, when V is removed (example the device enters in STANDBY or VBAT modes) the calibration is required. The steps to perform a user trimming calibration are as below: If the DAC channel is active, write 0 to EN1 bit in DAC_CR to disable the channel. Select a mode where the buffer is enabled, by writing to DAC_MCR register, MODE1[2:0] = 000b or 001b or 100b or 101b.
Digital-to-analog converter (DAC) RM0453 Independent trigger with single LFSR generation To configure the DAC in this conversion mode, the following sequence is required: Set the DAC channel trigger enable bit, TEN1. Configure the trigger sources by setting different values in the TSEL1[3:0] bits. Configure the DAC channel WAVE1[1:0] bits as 01 and the same LFSR mask value in the MAMP1[3:0] bits.
RM0453 Digital-to-analog converter (DAC) Table 117. Effect of low-power modes on DAC (continued) Mode Description DAC remains active with a static value, if Sample and hold mode is Stop 0 / Stop 1 selected using LSI clock The DAC registers content is lost and must be reinitialized after exiting Stop 2 Stop 2.
Digital-to-analog converter (DAC) RM0453 19.7 DAC registers Refer to Section 1 on page 58 for a list of abbreviations used in register descriptions. The peripheral registers have to be accessed by words (32-bit). 19.7.1 DAC control register (DAC_CR) Address offset: 0x00 Reset value: 0x0000 0000 Res.
Page 609
RM0453 Digital-to-analog converter (DAC) Bits 11:8 MAMP1[3:0]: DAC channel1 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...
Digital-to-analog converter (DAC) RM0453 Res. Res. Res. Res. DACC1DHR[11:0] Bits 31:16 Reserved, must be kept at reset value. Bits 15:12 Reserved, must be kept at reset value. Bits 11:0 DACC1DHR[11:0]: DAC channel1 12-bit right-aligned data These bits are written by software which specifies 12-bit data for DAC channel1. 19.7.7 Dual DAC 12-bit left aligned data holding register (DAC_DHR12LD)
Digital-to-analog converter (DAC) RM0453 Bit 13 DMAUDR1: DAC channel1 DMA underrun flag This bit is set by hardware and cleared by software (by writing it to 1). 0: No DMA underrun error condition occurred for DAC channel1 1: DMA underrun error condition occurred for DAC channel1 (the currently selected trigger is driving DAC channel1 conversion at a frequency higher than the DMA service capability rate) Bit 12 Reserved, must be kept at reset value.
RM0453 Digital-to-analog converter (DAC) Bit 8 Reserved, must be kept at reset value. Bits 7:3 Reserved, must be kept at reset value. Bits 2:0 MODE1[2:0]: DAC channel1 mode These bits can be written only when the DAC is disabled and not in the calibration mode (when bit EN1=0 and bit CEN1 =0 in the DAC_CR register).
RM0453 Voltage reference buffer (VREFBUF) Voltage reference buffer (VREFBUF) 20.1 Introduction The devices embed a voltage reference buffer which can be used as voltage reference for ADC, DAC 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).
Comparator (COMP) RM0453 Comparator (COMP) 21.1 COMP introduction The device embeds two ultra-low-power comparators (COMP1 and COMP2). These comparators can be used for a variety of functions including the following: • wake up from low-power mode triggered by an analog signal •...
Comparator (COMP) RM0453 Table 123. COMP1 input minus assignment COMP1_INM COMP1_INMSEL[2:0] COMP1_INMESEL[1:0] 1/4 V Not affected REFINT 1/2 V Not affected REFINT 3/4 V Not affected REFINT Not affected REFINT DAC channel1 Not affected Reserved Not affected Not affected PA10 PA11 PA15 Reserved...
RM0453 Comparator (COMP) There is no clock enable control bit provided in the RCC controller. Reset and clock enable bits are common for COMP and SYSCFG. Note: Important: The polarity selection logic and the output redirection to the port works independently from the APB2 clock.
RM0453 Comparator (COMP) 21.3.7 Comparator output blanking function The purpose of the blanking function is to prevent the current regulation to trip upon short current spikes at the beginning of the PWM period (typically the recovery current in power switches anti parallel diodes). It uses a blanking window defined with a timer output compare signal.
Comparator (COMP) RM0453 21.4 COMP low-power modes Table 126. Comparator behavior in the low-power modes Mode Description No effect on the comparators Sleep Comparator interrupts cause the device to exit the Sleep mode. LPRun No effect No effect on the comparators LPSleep Comparator interrupts cause the device to exit the LPSleep mode.
RM0453 Comparator (COMP) 21.6.2 COMP2 control and status register (COMP2_CSR) Address offset: 0x04 Reset value: 0x0000 0000 SCAL LOCK VALUE Res. Res. Res. INMESEL[1:0] Res. BRGEN Res. BLANKING[2:0] HYST[1:0] POLA Res. Res. Res. Res. Res. INPSEL[1:0] INMSEL[2:0] PWRMODE[1:0] Res. RITY MODE Bit 31 LOCK: locks the whole content of the register, COMP2_CSR[31:0] This bit is set by software and cleared by a hardware system reset.
Page 632
Comparator (COMP) RM0453 Bits 20:18 BLANKING[2:0]: COMP2 blanking source selection These bits select which timer output controls the COMP2 output blanking. 000: No blanking 001: TIM1 OC5 selected as blanking source 010: TIM2 OC3 selected as blanking source Others: reserved Bits 17:16 HYST[1:0]: COMP2 hysteresis selection These bits are set and cleared by software.
RM0453 Comparator (COMP) Bits 3:2 PWRMODE[1:0]: COMP2 power mode These bits are set and cleared by software. They control the power and speed of COMP2. 00: High speed 01: Medium speed 10: Medium speed 11: Ultra low-power Bit 1 Reserved, must be kept at reset value. Bit 0 EN: COMP2 enable This bit is set and cleared by software.
True random number generator (RNG) RM0453 True random number generator (RNG) 22.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) RM0453 22.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 RNG integrates all the required NIST components depicted on Figure 99.
Page 637
RM0453 True random number generator (RNG) Post processing In NIST configuration no post-processing is applied to sampled noise source. In non-NIST configuration B (as defined in Section 22.6.2) a normalization debiasing is applied, i.e. half of the bits are taken from the sampled noise source, half of the bits are taken from inverted sampled noise source.
Page 638
True random number generator (RNG) RM0453 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 in accordance with NIST SP800- 90B.
RM0453 True random number generator (RNG) 22.3.4 RNG initialization The RNG simplified state machine is pictured on Figure 100 After enabling the RNG (RNGEN=1 in RNG_CR) the following chain of events occurs: The analog noise source is enabled, and by default the RNG waits 16 cycles of RNG clock cycles (before divider) before starting to sample analog output and filling 128-bit conditioning shift register.
True random number generator (RNG) RM0453 Figure 100 also highlights a possible software reset sequence, implemented by: Writing bits RNGEN=0 and CONDRST=1 in the RNG_CR register with the same RNG configuration and a new CLKDIV if needed. Then writing RNGEN=1 and CONDRST=0 in the RNG_CR register. Wait for random number to be ready, after initialization completes Note: When RNG peripheral is reset through RCC (hardware reset) the RNG configuration for...
RM0453 True random number generator (RNG) additional words can be read by the application (in this case the DRDY bit is still high). If one or both of above conditions are false, the RNG_DR register must not be read. If an error occurred error recovery sequence described in Section 22.3.7 must be used.
True random number generator (RNG) RM0453 CEIS is set only when CECS is set to “1” by RNG. Noise source error detection When a noise source (or seed) error occurs, the RNG stops generating random numbers and sets to “1” both SEIS and SECS bits to indicate that a seed error occurred. If a value is available in the RNG_DR register, it must not be used as it may not have enough entropy.
RM0453 True random number generator (RNG) Table 130. RNG interrupt requests Interrupt acronym Interrupt event Event flag Enable control bit Interrupt clear method Data ready flag DRDY None (automatic) Write 0 to SEIS or write Seed error flag SEIS CONDRST to 1 then to 0 Clock error flag CEIS Write 0 to CEIS...
For details on data collection and the running of statistical test suites refer to “STM32 microcontrollers random number generation validation using NIST statistical test suite” application note (AN4230) available from www.st.com. Contact STMicroelectronics if above samples need to be retrieved for your product. 644/1461...
RM0453 True random number generator (RNG) 22.7 RNG registers The RNG is associated with a control register, a data register and a status register. 22.7.1 RNG control register (RNG_CR) Address offset: 0x000 Reset value: 0x0080 0000 CONFI COND Res. Res. Res.
Page 646
True random number generator (RNG) RM0453 Bit 12 NISTC: Non NIST compliant 0: Hardware default values for NIST compliant RNG. In this configuration per 128-bit output two conditioning loops are performed and 256 bits of noise source are used. 1: Custom values for NIST compliant RNG. See Section 22.6: RNG entropy source validation proposed configuration.
True random number generator (RNG) RM0453 22.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. The content of this register is valid when DRDY=1 and value is not 0x0, even if RNGEN=0. RNDATA[31:16] RNDATA[15:0] Bits 31:0 RNDATA[31:0]: Random data...
AES hardware accelerator (AES) RM0453 AES hardware accelerator (AES) 23.1 Introduction The AES hardware accelerator (AES) encrypts or decrypts data, using an algorithm and implementation fully compliant with the advanced encryption standard (AES) defined in Federal information processing standards (FIPS) publication 197. The peripheral supports CTR, GCM, GMAC, CCM, ECB, and CBC chaining modes for key sizes of 128 or 256 bits.
RM0453 AES hardware accelerator (AES) Note: The chaining mode may be changed only when AES is disabled (bit EN of the AES_CR register cleared). Principle of each AES chaining mode is provided in the following subsections. Detailed information is in dedicated sections, starting from Section 23.4.8: AES basic chaining modes (ECB, CBC).
RM0453 AES hardware accelerator (AES) GMAC is similar to GCM, except that it is applied on a message composed only by plaintext authenticated data (that is, only header, no payload). Counter with CBC-MAC (CCM) principle Figure 107. CCM encryption and authentication principle Count 1 Count 2 Count 3...
Page 658
AES hardware accelerator (AES) RM0453 Initialization of AES To initialize AES, first disable it by clearing the EN bit of the AES_CR register. Then perform the following steps in any order: • Configure the AES mode, by programming the MODE[1:0] bitfield of the AES_CR register.
Page 659
RM0453 AES hardware accelerator (AES) Data append using interrupt The method uses interrupt from the AES peripheral to control the data append, through the following sequence: Enable interrupts from AES by setting the CCFIE bit of the AES_CR register. Enable the AES peripheral by setting the EN bit of the AES_CR register. Write first four input data words into the AES_DINR register.
AES hardware accelerator (AES) RM0453 23.4.5 AES decryption round key preparation Internal key schedule is used to generate AES round keys. In AES encryption, the round 0 key is the one stored in the key registers. AES decryption must start using the last round key.
RM0453 AES hardware accelerator (AES) 23.4.7 AES task suspend and resume A message can be suspended if another message with a higher priority must be processed. When this highest priority message is sent, the suspended message can resume in both encryption or decryption mode.
AES hardware accelerator (AES) RM0453 The second ciphertext block is processed in the same way as the first block, except that the I1 data from the first block is used in place of the initialization vector. The decryption continues in this way until the last complete ciphertext block is decrypted. If the message size is not a multiple of 128 bits, the final partial data block is decrypted in the way explained in Section 23.4.6: AES ciphertext stealing and data...
RM0453 AES hardware accelerator (AES) register to 000 or 001, respectively. Data type can also be defined, using DATATYPE[1:0] bitfield. KEYSIZE bitfield must be kept as-is. Write the AES_IVRx registers with the initialization vector (required in CBC mode only). Enable AES by setting the EN bit of the AES_CR register. Write the AES_DINR register four times to input the cipher text (MSB first), as shown in Figure 114.
AES hardware accelerator (AES) RM0453 To resume the processing of a message, proceed as follows: If DMA is used, configure the DMA controller so as to complete the rest of the FIFO IN and FIFO OUT transfers. Ensure that AES is disabled (the EN bit of the AES_CR must be 0). Restore AES_CR register (with correct KEYSIZE) then restore AES_KEYRx registers.
RM0453 AES hardware accelerator (AES) CTR encryption and decryption Figure 116 Figure 117 describe the CTR encryption and decryption process, respectively, as implemented in the AES peripheral. The CTR mode is selected by writing 010 to the CHMOD[2:0] bitfield of AES_CR register. Figure 116.
AES hardware accelerator (AES) RM0453 Unlike in CBC mode that uses the AES_IVRx registers only once when processing the first data block, in CTR mode AES_IVRx registers are used for processing each data block, and the AES peripheral increments the counter bits of the initialization vector (leaving the nonce bits unchanged).
AES hardware accelerator (AES) RM0453 GCM processing Figure 119 describes the GCM implementation in the AES peripheral. The GCM is selected by writing 011 to the CHMOD[2:0] bitfield of the AES_CR register. Figure 119. GCM authenticated encryption (3) Payload Block 1 Block n AES_IVRx ICB + (32-bit counter = 0x02)
Page 671
RM0453 AES hardware accelerator (AES) The authentication mechanism in GCM mode is based on a hash function called GF2mul that performs multiplication by a fixed parameter, called hash subkey (H), within a binary Galois field. A GCM message is processed through the following phases, further described in next subsections: •...
Page 672
AES hardware accelerator (AES) RM0453 GCM payload phase This phase, identical for encryption and decryption, is executed after the GCM header phase. During this phase, the encrypted/decrypted payload is stored in the AES_DOUTR register. The sequence to execute is: Indicate the payload phase, by setting to 10 the GCMPH[1:0] bitfield of the AES_CR register.
RM0453 AES hardware accelerator (AES) Suspend/resume operations in GCM mode To suspend the processing of a message, proceed as follows: If DMA is used, stop the AES DMA transfers to the IN FIFO by clearing the DMAINEN bit of the AES_CR register. If DMA is not used, make sure that the current computation is completed, which is indicated by the CCF flag of the AES_SR register set to 1.
AES hardware accelerator (AES) RM0453 A typical message construction for GMAC is given in Figure 120. Figure 120. Message construction in GMAC mode [Len(A)] Len(A) 16-byte boundaries Last Authenticated data block 4-byte boundaries Authentication tag (T) Initialization vector (IV) Counter Zero padding MSv42158V2 AES GMAC processing...
RM0453 AES hardware accelerator (AES) 23.4.12 AES counter with CBC-MAC (CCM) Overview The AES counter with cipher block chaining-message authentication code (CCM) algorithm allows encryption and authentication of plaintext, generating the corresponding ciphertext and tag (also known as message authentication code). To ensure confidentiality, the CCM algorithm is based on AES in counter mode.
Page 676
AES hardware accelerator (AES) RM0453 standard also states that, on MSB bits of the first message block (B1), the associated data length expressed in bytes (a) must be encoded as follows: – If 0 < a < 2 , then it is encoded as [a] , that is, on two bytes.
RM0453 AES hardware accelerator (AES) CCM processing Figure 123 describes the CCM implementation within the AES peripheral (encryption example). This mode is selected by writing 100 into the CHMOD[2:0] bitfield of the AES_CR register. Figure 123. CCM mode authenticated encryption Block 1 Block m (3) Payload...
Page 678
AES hardware accelerator (AES) RM0453 Note: In this mode, the setting 01 of the MODE[1:0] bitfield (key derivation) is forbidden. A CCM message is processed through the following phases, further described in next subsections: • Init phase: AES processes the first block and prepares the first counter block. •...
Page 679
RM0453 AES hardware accelerator (AES) CCM payload phase (encryption or decryption) This phase, identical for encryption and decryption, is executed after the CCM header phase. During this phase, the encrypted/decrypted payload is stored in the AES_DOUTR register. The sequence to execute is: Indicate the payload phase, by setting to 10 the GCMPH[1:0] bitfield of the AES_CR register.
Page 680
AES hardware accelerator (AES) RM0453 Suspend/resume operations in CCM mode To suspend the processing of a message in header or payload phase, proceed as follows: If DMA is used, stop the AES DMA transfers to the IN FIFO by clearing the DMAINEN bit of the AES_CR register.
RM0453 AES hardware accelerator (AES) 23.4.13 AES data registers and data swapping Data input and output A 128-bit data block is entered into the AES peripheral with four successive 32-bit word writes into the AES_DINR register (bitfield DIN[31:0]), the most significant word (bits [127:96]) first, the least significant word (bits [31:0]) last.
AES hardware accelerator (AES) RM0453 Figure 124. 128-bit block construction with respect to data swap increasing memory address byte 3 byte 2 byte 1 byte 0 DATATYPE[1:0] = 00: no swapping Word 3 Word 2 Word 1 Word 0 D127 D127 DATATYPE[1:0] = 01: 16-bit (half-word) swapping Word 3...
RM0453 AES hardware accelerator (AES) 23.4.14 AES key registers The AES_KEYRx write-only registers store the encryption or decryption key bitfield KEY[127:0] or KEY[255:0]. The data to write to each register is organized in the memory in little-endian order, that is, with most significant byte on the highest address (reads are not allowed for security reason).
AES hardware accelerator (AES) RM0453 DMA transfer must not include the last block. For details, refer to Section 23.4.4: AES procedure to perform a cipher operation. Figure 125. DMA transfer of a 128-bit data block during input phase Chronological order Increasing address Memory accessed through DMA Word3...
RM0453 AES hardware accelerator (AES) When the data transferring between AES and memory is managed by DMA, the CCF flag is not relevant and can be ignored (left set) by software. It must only be cleared when transiting back to data transferring managed by software. See Suspend/resume operations in ECB/CBC modes Section 23.4.8: AES basic chaining modes (ECB, CBC)
AES hardware accelerator (AES) RM0453 Table 139. AES interrupt requests Interrupt Interrupt clear AES interrupt event Event flag Enable bit acronym method computation completed flag CCFIE set CCFC read error flag RDERR ERRIE set ERRC write error flag WRERR 1. Bit of the AES_CR register. 23.6 AES processing latency The tables below summarize the latency to process a 128-bit block for each mode of...
Page 688
AES hardware accelerator (AES) RM0453 Bit 12 DMAOUTEN: DMA output enable This bit enables/disables data transferring with DMA, in the output phase: 0: Disable 1: Enable When the bit is set, DMA requests are automatically generated by AES during the output data phase.
RM0453 AES hardware accelerator (AES) Bits 4:3 MODE[1:0]: AES operating mode This bitfield selects the AES operating mode: 00: Mode 1: encryption 01: Mode 2: key derivation (or key preparation for ECB/CBC decryption) 10: Mode 3: decryption 11: reserved Attempts to write the bitfield are ignored when the EN bit of the AES_CR register is set before the write access and it is not cleared by that write access.
AES hardware accelerator (AES) RM0453 Bit 2 WRERR: Write error This flag indicates the detection of an unexpected write operation to the AES_DINR register (during computation or data output phase): 0: Not detected 1: Detected The flag is set by hardware. It is cleared by software upon setting the ERRC bit of the AES_CR register.
RM0453 AES hardware accelerator (AES) Bits 31:0 DIN[31:0]: Input data word A four-fold sequential write to this bitfield during the input phase results in writing a complete 128-bit block of input data to the AES peripheral. From the first to the fourth write, the corresponding data weights are [127:96], [95:64], [63:32], and [31:0].
AES hardware accelerator (AES) RM0453 23.7.5 AES key register 0 (AES_KEYR0) Address offset: 0x10 Reset value: 0x0000 0000 KEY[31:16] KEY[15:0] Bits 31:0 KEY[31:0]: Cryptographic key, bits [31:0] This write-only bitfield contains the bits [31:0] of the AES encryption or decryption key, depending on the operating mode: - In Mode 1 (encryption), Mode 2 (key derivation): the value to write into the bitfield is the encryption key.
AES hardware accelerator (AES) RM0453 Bits 31:0 IVI[31:0]: Initialization vector input, bits [31:0] Refer to Section 23.4.15: AES initialization vector registers on page 683 for description of the IVI[127:0] bitfield. The initialization vector is only used in chaining modes other than ECB. The AES_IVRx registers may be written only when the AES peripheral is disabled 23.7.10 AES initialization vector register 1 (AES_IVR1)
AES hardware accelerator (AES) RM0453 23.7.16 AES key register 7 (AES_KEYR7) Address offset: 0x3C Reset value: 0x0000 0000 KEY[255:240] KEY[239:224] Bits 31:0 KEY[255:224]: Cryptographic key, bits [255:224] Refer to the AES_KEYR0 register for description of the KEY[255:0] bitfield. Note: The key registers from 4 to 7 are used only when the key length of 256 bits is selected. They have no effect when the key length of 128 bits is selected (only key registers 0 to 3 are used in that case).
RM0453 Public key accelerator (PKA) Public key accelerator (PKA) 24.1 Introduction PKA (public key accelerator) is intended for the computation of cryptographic public key primitives, specifically those related to RSA, Diffie-Hellmann or ECC (elliptic curve cryptography) over GF(p) (Galois fields). To achieve high performance at a reasonable cost, these operations are executed in the Montgomery domain.
Public key accelerator (PKA) RM0453 Figure 127. PKA block diagram Banked registers (main) PKA32 PKA_CR control PKA_SR status interface PKA_CLRFR clear 894x32-bit PKA RAM pka_hclk 32-bit Control PKA core pka_it interface logic MS45419V1 24.3.2 PKA internal signals Table 143 lists internal signals available at the IP level, not necessarily available on product bonding pads.
RM0453 Public key accelerator (PKA) Each of these operating modes has an associated code that has to be written to the MODE field in the PKA_CR register. Table 144. PKA integer arithmetic functions list PKA_CR.MODE[5:0] Performed operation Reference Binary 0x01 000001 Montgomery parameter computation R2 mod n Section 24.4.2...
Public key accelerator (PKA) RM0453 24.3.5 Typical applications for PKA Introduction The PKA can be used to accelerate a number of public key cryptographic functions. In particular: • RSA encryption and decryption • RSA key finalization • CRT-RSA decryption • DSA and ECDSA signature generation and verification •...
Page 703
RM0453 Public key accelerator (PKA) Alice, to decrypt ciphertext c using her private key, follows the steps indicated below: Convert the ciphertext C to an integer ciphertext representative c. Recover plaintext m = c mod n = (m mod n. If the private key is the quintuple (p, q, dp, dq, qInv), then plaintext m is obtained by performing the operations: mod p mod q...
Public key accelerator (PKA) RM0453 ECDSA signature verification ECDSA (elliptic curve digital signature algorithm) signature verification function principle is the following: Bob, to authenticate Alice's signature, must have a copy of her public key curve point Q Bob can verify that Q is a valid curve point going through the following steps: check that Q is not equal to the identity element O...
RM0453 Public key accelerator (PKA) Using precomputed Montgomery parameters (PKA fast mode) As explained in Section 24.3.4, when computing many operations with the same modulus it can be beneficial for the application to compute only once the corresponding Montgomery parameter (see, for example, Section 24.4.5).
Public key accelerator (PKA) RM0453 Note: Fractional results for above formulas are rounded up to the nearest integer since PKA core processes 32-bit words. Note: The maximum ROS is 99 words (3136-bit max exponent size), while the maximum EOS is 21 words (640-bit max operand size).
RM0453 Public key accelerator (PKA) 24.4.3 Modular addition Modular addition operation consists in the computation of A + B mod n. Operation instructions are summarized in Table 147. Table 147. Modular addition Parameters with direction Value (Note) Storage Size MODE 0x0E PKA_CR 6 bits...
Public key accelerator (PKA) RM0453 Inward (or outward) conversion into (or from) Montgomery domain Let’s assume A is an integer in the natural domain Compute r2modn using Montgomery parameter computation Result AR= A x r2modn mod n is A in the Montgomery domain Let’s assume BR is an integer in the Montgomery domain Result B = BR x 1 mod n is B in the natural domain Similarly, above value AR computed in a) can be converted into the natural...
RM0453 Public key accelerator (PKA) Table 150. Modular exponentiation (normal mode) Parameters with direction Value (Note) Storage Size MODE 0x00 PKA_CR 6 bits Exponent length (in bits, not null) RAM@0x400 32 bits Operand length (in bits, not null) RAM@0x404 Operand A (base of IN/OUT (0 ≤...
Public key accelerator (PKA) RM0453 24.4.8 Modular reduction Modular reduction operation consists in the computation of the remainder of A divided by n. Operation instructions are summarized in Table 153. Table 153. Modular reduction Parameters with direction Value (Note) Storage Size MODE 0x0D...
RM0453 Public key accelerator (PKA) 24.4.11 Arithmetic multiplication Arithmetic multiplication operation consists in the computation of AxB. Operation instructions are summarized in Table 156. Table 156. Arithmetic multiplication Parameters with direction Value (Note) Storage Size MODE 0x0B PKA_CR 6 bits Operand length M (In bits, not null) RAM@0x404...
Public key accelerator (PKA) RM0453 These values allow the recipient to compute the exponentiation m = A (mod pq) more efficiently as follows: • mod p • mod p • h = q ) mod p, with m > m •...
RM0453 Public key accelerator (PKA) Table 159. Point on elliptic curve Fp check Parameters with direction Value (Note) Storage Size MODE 0x28 PKA_CR 6 bits (In bits, not null, Modulus length RAM@0x404 8 < value < 640) 32 bits 0x0: positive Curve coefficient a sign RAM@0x408 0x1: negative...
Public key accelerator (PKA) RM0453 Table 161. ECC Fp scalar multiplication (Fast Mode) Parameters with direction Value (Note) Storage Size MODE 0x22 PKA_CR 6 bits (In bits, not null, Scalar multiplier k length RAM@0x400 8 < value < 640) (In bits, not null, Modulus length RAM@0x404 32 bits...
RM0453 Public key accelerator (PKA) Table 162. ECDSA sign - Inputs Parameters with direction Value (Note) Storage Size MODE 0x24 PKA_CR 6 bits Curve prime order n (in bits, not null) RAM@0x400 length Curve modulus p length (in bits, 8 < value < 640) RAM@0x404 32 bits 0x0: positive...
Public key accelerator (PKA) RM0453 Table 164. Extended ECDSA sign (extra outputs) Parameters with direction Value (Note) Storage Size Curve point kG coordinate x (0 ≤ x < p) RAM@0x103C Curve point kG coordinate y (0 ≤ y < p) RAM@0x1090 24.4.17 ECDSA verification...
RM0453 Public key accelerator (PKA) 24.5 Example of configurations and processing times 24.5.1 Configuration of curves Table 167 gives the modulus values used by PKA for ECC domain calculations: • p is the prime number used as the modulus for all point arithmetic –...
RM0453 Public key accelerator (PKA) 24.5.2 Computation times The following tables summarize the PKA computation times, expressed in clock cycles. Table 168. Modular exponentiation computation times Modulus length (in bits) Exponent length Mode (in bits) 1024 2048 3072 Normal 304000 814000 1728000 Fast...
Public key accelerator (PKA) RM0453 Table 171. ECDSA verification average computation times Modulus length (in bits) 3500000 5350000 10498000 18126000 29118000 61346000 71588000 Table 172. Point on elliptic curve Fp check average computation times Modulus length (in bits) 10800 14200 20400 31000 49600...
Public key accelerator (PKA) RM0453 Bits 7:2 Reserved, must be kept at reset value. Bit 1 START: start the operation Writing 1 to this bit starts the operation which is selected by MODE[5:0], using the operands and data already written to the PKA RAM. This bit is always read as 0. Note: START is ignored if PKA is busy.
Public key accelerator (PKA) RM0453 24.7.5 PKA register map Table 175. PKA register map and reset values Register Offset name PKA_CR MODE[5:0] 0x000 Reset value PKA_SR 0x004 Reset value PKA_CLRFR 0x008 Reset value Refer to Section 2.6 on page 70 for the register boundary addresses.
RM0453 Advanced-control timer (TIM1) Advanced-control timer (TIM1) In this section, “TIMx” should be understood as “TIM1” since there is only one instance of this type of timer for the products to which this reference manual applies. 25.1 TIM1 introduction The advanced-control timer (TIM1) consists of a 16-bit auto-reload counter driven by a programmable prescaler.
Advanced-control timer (TIM1) RM0453 25.2 TIM1 main features TIM1 timer features include: • 16-bit up, down, up/down auto-reload counter. • 16-bit programmable prescaler allowing dividing (also “on the fly”) the counter clock frequency either by any factor between 1 and 65536. •...
Advanced-control timer (TIM1) RM0453 25.3 TIM1 functional description 25.3.1 Time-base unit The main block of the programmable advanced-control timer is a 16-bit counter with its related auto-reload register. The counter can count up, down or both up and down. The counter clock can be divided by a prescaler.
RM0453 Advanced-control timer (TIM1) Figure 129. Counter timing diagram with prescaler division change from 1 to 2 CK_PSC Timerclock = CK_CNT FA FB Counter register Update event (UEV) Prescaler control register Write a new value in TIMx_PSC Prescaler buffer Prescaler counter MS31076V2 Figure 130.
Advanced-control timer (TIM1) RM0453 25.3.2 Counter modes Upcounting mode In upcounting mode, the counter counts from 0 to the auto-reload value (content of the TIMx_ARR register), then restarts from 0 and generates a counter overflow event. If the repetition counter is used, the update event (UEV) is generated after upcounting is repeated for the number of times programmed in the repetition counter register (TIMx_RCR) + 1.
RM0453 Advanced-control timer (TIM1) Figure 135. Counter timing diagram, update event when ARPE=0 (TIMx_ARR not preloaded) CK_PSC Timerclock = CK_CNT Counter register Counter overflow Update event (UEV) Update interrupt flag (UIF) Auto-reload preload register Write a new value in TIMx_ARR MS31082V3 Figure 136.
Page 738
Advanced-control timer (TIM1) RM0453 Downcounting mode In downcounting mode, the counter counts from the auto-reload value (content of the TIMx_ARR register) down to 0, then restarts from the auto-reload value and generates a counter underflow event. If the repetition counter is used, the update event (UEV) is generated after downcounting is repeated for the number of times programmed in the repetition counter register (TIMx_RCR) + 1.
RM0453 Advanced-control timer (TIM1) Figure 141. Counter timing diagram, update event when repetition counter is not used CK_PSC Timerclock = CK_CNT 30 2F Counter register Counter underflow Update event (UEV) Update interrupt flag (UIF) Auto-reload preload register Write a new value in TIMx_ARR MS31188V1 Center-aligned mode (up/down counting) In center-aligned mode, the counter counts from 0 to the auto-reload value (content of the...
Advanced-control timer (TIM1) RM0453 DMA request is sent). This is to avoid generating both update and capture interrupts when clearing the counter on the capture event. When an update event occurs, all the registers are updated and the update flag (UIF bit in TIMx_SR register) is set (depending on the URS bit): •...
Advanced-control timer (TIM1) RM0453 In Center aligned mode, for odd values of RCR, the update event occurs either on the overflow or on the underflow depending on when the RCR register was written and when the counter was launched: if the RCR was written before launching the counter, the UEV occurs on the underflow.
RM0453 Advanced-control timer (TIM1) 25.3.4 External trigger input The timer features an external trigger input ETR. It can be used as: • external clock (external clock mode 2, see Section 25.3.5) • trigger for the slave mode (see Section 25.3.26) •...
Advanced-control timer (TIM1) RM0453 25.3.5 Clock selection The counter clock can be provided by the following clock sources: • Internal clock (CK_INT) • External clock mode1: external input pin • External clock mode2: external trigger input ETR • Encoder mode Internal clock source (CK_INT) If the slave mode controller is disabled (SMS=000), then the CEN, DIR (in the TIMx_CR1 register) and UG bits (in the TIMx_EGR register) are actual control bits and can be changed...
Advanced-control timer (TIM1) RM0453 Figure 153. Control circuit in external clock mode 1 CNT_EN Counter clock = CK_CNT = CK_PSC Counter register Write TIF=0 MS31087V2 External clock source mode 2 This mode is selected by writing ECE=1 in the TIMx_SMCR register. The counter can count at each rising or falling edge on the external trigger input ETR.
RM0453 Advanced-control timer (TIM1) As no filter is needed in this example, write ETF[3:0]=0000 in the TIMx_SMCR register. Set the prescaler by writing ETPS[1:0]=01 in the TIMx_SMCR register Select rising edge detection on the ETR pin by writing ETP=0 in the TIMx_SMCR register Enable external clock mode 2 by writing ECE=1 in the TIMx_SMCR register.
Advanced-control timer (TIM1) RM0453 25.3.6 Capture/compare channels Each Capture/Compare channel is built around a capture/compare register (including a shadow register), an input stage for capture (with digital filter, multiplexing, and prescaler, except for channels 5 and 6) and an output stage (with comparator and output control). Figure 156 Figure 159 give an overview of one Capture/Compare channel.
RM0453 Advanced-control timer (TIM1) detected (sampled at f frequency). Then write IC1F bits to 0011 in the TIMx_CCMR1 register. Select the edge of the active transition on the TI1 channel by writing CC1P and CC1NP bits to 0 in the TIMx_CCER register (rising edge in this case). Program the input prescaler.
Advanced-control timer (TIM1) RM0453 Select the proper TI1x source (internal or external) with the TI1SEL[3:0] bits in the TIMx_TISEL register. Select the active input for TIMx_CCR1: write the CC1S bits to 01 in the TIMx_CCMR1 register (TI1 selected). Select the active polarity for TI1FP1 (used both for capture in TIMx_CCR1 and counter clear): write the CC1P and CC1NP bits to ‘0’...
RM0453 Advanced-control timer (TIM1) 25.3.10 Output compare mode This function is used to control an output waveform or indicate when a period of time has elapsed. Channels 1 to 4 can be output, while Channel 5 and 6 are only available inside the device (for instance, for compound waveform generation or for ADC triggering).
Advanced-control timer (TIM1) RM0453 Figure 162. Output compare mode, toggle on OC1 Write B201h in the CC1R register 0039 003A 003B B200 B201 TIM1_CNT B201 003A TIM1_CCR1 OC1REF= OC1 Match detected on CCR1 Interrupt generated if enabled MS31092V1 25.3.11 PWM mode Pulse Width Modulation mode allows a signal to be generated with a frequency determined by the value of the TIMx_ARR register and a duty cycle determined by the value of the TIMx_CCRx register.
RM0453 Advanced-control timer (TIM1) PWM edge-aligned mode • Upcounting configuration Upcounting is active when the DIR bit in the TIMx_CR1 register is low. Refer to the Upcounting mode on page 734. In the following example, we consider PWM mode 1. The reference PWM signal OCxREF is high as long as TIMx_CNT <...
Advanced-control timer (TIM1) RM0453 TIMx_CR1 register is updated by hardware and must not be changed by software. Refer to Center-aligned mode (up/down counting) on page 741. Figure 164 shows some center-aligned PWM waveforms in an example where: • TIMx_ARR=8, • PWM mode is the PWM mode 1, •...
RM0453 Advanced-control timer (TIM1) in the TIMx_CR1 register. Moreover, the DIR and CMS bits must not be changed at the same time by the software. • Writing to the counter while running in center-aligned mode is not recommended as it can lead to unexpected results.
RM0453 Advanced-control timer (TIM1) Figure 166. Combined PWM mode on channel 1 and 3 OC2’ OC1’ OC1REF OC2REF OC1REF’ OC2REF’ OC1REFC OC1REFC’ OC1REFC = OC1REF AND OC2REF OC1REFC’ = OC1REF’ OR OC2REF’ MS31094V1 25.3.14 Combined 3-phase PWM mode Combined 3-phase PWM mode allows one to three center-aligned PWM signals to be generated with a single programmable signal ANDed in the middle of the pulses.
Advanced-control timer (TIM1) RM0453 Figure 167. 3-phase combined PWM signals with multiple trigger pulses per period Counter OC5ref OC1refC OC2refC OC3refC Preload Active OC4ref OC6ref TRGO2 MS33102V1 The TRGO2 waveform shows how the ADC can be synchronized on given 3-phase PWM signals.
RM0453 Advanced-control timer (TIM1) Dead-time insertion is enabled by setting both CCxE and CCxNE bits, and the MOE bit if the break circuit is present. There is one 10-bit dead-time generator for each channel. From a reference waveform OCxREF, it generates 2 outputs OCx and OCxN. If OCx and OCxN are active high: •...
Advanced-control timer (TIM1) RM0453 Figure 170. Dead-time waveforms with delay greater than the positive pulse OCxREF OCxN delay MS31097V1 The dead-time delay is the same for each of the channels and is programmable with the DTG bits in the TIMx_BDTR register. Refer to Section 25.4.20: TIM1 break and dead-time register (TIM1_BDTR) for delay calculation.
Page 767
RM0453 Advanced-control timer (TIM1) The output enable signal and output levels during break are depending on several control bits: – the MOE bit in TIMx_BDTR register allows the outputs to be enabled/disabled by software and is reset in case of break or break2 event. –...
Advanced-control timer (TIM1) RM0453 All sources are ORed before entering the timer BRK or BRK2 inputs, as per Figure 171 below. Figure 171. Break and Break2 circuitry overview Lockup LOCK Core Lockup PVD LOCK System break requests SBIF flag Parity LOCK RAM parity Error ECC LOCK Double ECC Error...
Page 769
RM0453 Advanced-control timer (TIM1) When one of the breaks occurs (selected level on one of the break inputs): • The MOE bit is cleared asynchronously, putting the outputs in inactive state, idle state or even releasing the control to the GPIO controller (selected by the OSSI bit). This feature is enabled even if the MCU oscillator is off.
RM0453 Advanced-control timer (TIM1) The two break inputs have different behaviors on timer outputs: – The BRK input can either disable (inactive state) or force the PWM outputs to a predefined safe state. – BRK2 can only disable (inactive state) the PWM outputs. The BRK has a higher priority than BRK2 input, as described in Table 176.
Advanced-control timer (TIM1) RM0453 Figure 174. PWM output state following BRK assertion (OSSI=0) I/O state defined by the GPIO controller (HI-Z) Deadtime I/O state I/O state defined by the GPIO controller (HI-Z) Active Inactive Disabled MS34107V1 25.3.17 Bidirectional break inputs The TIM1 are featuring bidirectional break I/Os, as represented on Figure 175.
Advanced-control timer (TIM1) RM0453 25.3.18 Clearing the OCxREF signal on an external event The OCxREF signal of a given channel can be cleared when a high level is applied on the ocref_clr_int input (OCxCE enable bit in the corresponding TIMx_CCMRx register set to 1). OCxREF remains low until the next update event (UEV) occurs.
RM0453 Advanced-control timer (TIM1) 25.3.19 6-step PWM generation When complementary outputs are used on a channel, preload bits are available on the OCxM, CCxE and CCxNE bits. The preload bits are transferred to the shadow bits at the COM commutation event. Thus one can program in advance the configuration for the next step and change the configuration of all the channels at the same time.
Advanced-control timer (TIM1) RM0453 25.3.20 One-pulse mode One-pulse mode (OPM) is a particular case of the previous modes. It allows the counter to be started in response to a stimulus and to generate a pulse with a programmable length after a programmable delay. Starting the counter can be controlled through the slave mode controller.
RM0453 Advanced-control timer (TIM1) The OPM waveform is defined by writing the compare registers (taking into account the clock frequency and the counter prescaler). • The t is defined by the value written in the TIMx_CCR1 register. DELAY • The t is defined by the difference between the auto-reload value and the compare PULSE value (TIMx_ARR - TIMx_CCR1).
Advanced-control timer (TIM1) RM0453 Figure 179. Retriggerable one pulse mode TRGI Counter Output MS33106V1 25.3.22 Encoder interface mode To select Encoder Interface mode write SMS=‘001’ in the TIMx_SMCR register if the counter is counting on TI2 edges only, SMS=’010’ if it is counting on TI1 edges only and SMS=’011’...
RM0453 Advanced-control timer (TIM1) Table 178. Counting direction versus encoder signals Level on TI1FP1 signal TI2FP2 signal opposite signal (TI1FP1 Active edge for TI2, Rising Falling Rising Falling TI2FP2 for TI1) High Down No Count No Count Counting on TI1 only Down No Count No Count...
Advanced-control timer (TIM1) RM0453 Figure 181 gives an example of counter behavior when TI1FP1 polarity is inverted (same configuration as above except CC1P=’1’). Figure 181. Example of encoder interface mode with TI1FP1 polarity inverted. forward jitter backward jitter forward Counter down down MS33108V1...
RM0453 Advanced-control timer (TIM1) 25.3.24 Timer input XOR function The TI1S bit in the TIMx_CR2 register, allows the input filter of channel 1 to be connected to the output of an XOR gate, combining the three input pins TIMx_CH1, TIMx_CH2 and TIMx_CH3.
Page 782
Advanced-control timer (TIM1) RM0453 Example: one wants to change the PWM configuration of the advanced-control timer TIM1 after a programmed delay each time a change occurs on the Hall inputs connected to one of the TIMx timers. • Configure 3 timer inputs ORed to the TI1 input channel by writing the TI1S bit in the TIMx_CR2 register to ‘1’, •...
Advanced-control timer (TIM1) RM0453 25.3.26 Timer synchronization The TIMx timers are linked together internally for timer synchronization or chaining. Refer to Section 26.3.19: Timer synchronization for details. They can be synchronized in several modes: Reset mode, Gated mode, and Trigger mode. Slave mode: Reset mode The counter and its prescaler can be reinitialized in response to an event on a trigger input.
RM0453 Advanced-control timer (TIM1) Slave mode: Gated mode The counter can be enabled depending on the level of a selected input. In the following example, the upcounter counts only when TI1 input is low: • Configure the channel 1 to detect low levels on TI1. Configure the input filter duration (in this example, we do not need any filter, so we keep IC1F=0000).
Advanced-control timer (TIM1) RM0453 register. Write CC2P=1 and CC2NP=0 in TIMx_CCER register to validate the polarity (and detect low level only). • Configure the timer in trigger mode by writing SMS=110 in TIMx_SMCR register. Select TI2 as the input source by writing TS=00110 in TIMx_SMCR register. When a rising edge occurs on TI2, the counter starts counting on the internal clock and the TIF flag is set.
RM0453 Advanced-control timer (TIM1) In the following example, the upcounter is incremented at each rising edge of the ETR signal as soon as a rising edge of TI1 occurs: Configure the external trigger input circuit by programming the TIMx_SMCR register as follows: –...
Advanced-control timer (TIM1) RM0453 25.3.27 ADC synchronization The timer can generate an ADC triggering event with various internal signals, such as reset, enable or compare events. It is also possible to generate a pulse issued by internal edge detectors, such as: –...
RM0453 Advanced-control timer (TIM1) This is done in the following steps: Configure the corresponding DMA channel as follows: – DMA channel peripheral address is the DMAR register address – DMA channel memory address is the address of the buffer in the RAM containing the data to be transferred by DMA into CCRx registers.
Advanced-control timer (TIM1) RM0453 25.4 TIM1 registers Refer to for a list of abbreviations used in register descriptions. The peripheral registers can be accessed by half-words (16-bit) or words (32-bit). 25.4.1 TIM1 control register 1 (TIM1_CR1) Address offset: 0x00 Reset value: 0x0000 UIFRE Res.
RM0453 Advanced-control timer (TIM1) Bit 4 DIR: Direction 0: Counter used as upcounter 1: Counter used as downcounter Note: This bit is read only when the timer is configured in Center-aligned mode or Encoder mode. Bit 3 OPM: One pulse mode 0: Counter is not stopped at update event 1: Counter stops counting at the next update event (clearing the bit CEN) Bit 2 URS: Update request source...
Page 792
Advanced-control timer (TIM1) RM0453 Bits 31:24 Reserved, must be kept at reset value. Bits 23:20 MMS2[3:0]: Master mode selection 2 These bits allow the information to be sent to ADC for synchronization (TRGO2) to be selected. The combination is as follows: 0000: Reset - the UG bit from the TIMx_EGR register is used as trigger output (TRGO2).
Page 793
RM0453 Advanced-control timer (TIM1) Bit 12 OIS3: Output Idle state 3 (OC3 output) Refer to OIS1 bit Bit 11 OIS2N: Output Idle state 2 (OC2N output) Refer to OIS1N bit Bit 10 OIS2: Output Idle state 2 (OC2 output) Refer to OIS1 bit Bit 9 OIS1N: Output Idle state 1 (OC1N output) 0: OC1N=0 after a dead-time when MOE=0 1: OC1N=1 after a dead-time when MOE=0...
Advanced-control timer (TIM1) RM0453 Bit 2 CCUS: Capture/compare control update selection 0: When capture/compare control bits are preloaded (CCPC=1), they are updated by setting the COMG bit only 1: When capture/compare control bits are preloaded (CCPC=1), they are updated by setting the COMG bit or when an rising edge occurs on TRGI Note: This bit acts only on channels that have a complementary output.
Page 795
RM0453 Advanced-control timer (TIM1) Bits 13:12 ETPS[1:0]: External trigger prescaler External trigger signal ETRP frequency must be at most 1/4 of f frequency. A CK_INT prescaler can be enabled to reduce ETRP frequency. It is useful when inputting fast external clocks.
Advanced-control timer (TIM1) RM0453 Bits 16, 2, 1, 0 SMS[3:0]: Slave mode selection When external signals are selected the active edge of the trigger signal (TRGI) is linked to the polarity selected on the external input (see Input Control register and Control Register description.
Page 797
RM0453 Advanced-control timer (TIM1) Bit 15 Reserved, must be kept at reset value. Bit 14 TDE: Trigger DMA request enable 0: Trigger DMA request disabled 1: Trigger DMA request enabled Bit 13 COMDE: COM DMA request enable 0: COM DMA request disabled 1: COM DMA request enabled Bit 12 CC4DE: Capture/Compare 4 DMA request enable 0: CC4 DMA request disabled...
Page 799
RM0453 Advanced-control timer (TIM1) Bit 9 CC1OF: Capture/Compare 1 overcapture flag This flag is set by hardware only when the corresponding channel is configured in input capture mode. It is cleared by software by writing it to ‘0’. 0: No overcapture has been detected. 1: The counter value has been captured in TIMx_CCR1 register while CC1IF flag was already set Bit 8 B2IF: Break 2 interrupt flag...
Advanced-control timer (TIM1) RM0453 Bit 0 UIF: Update interrupt flag This bit is set by hardware on an update event. It is cleared by software. 0: No update occurred. 1: Update interrupt pending. This bit is set by hardware when the registers are updated: –...
RM0453 Advanced-control timer (TIM1) Bit 2 CC2G: Capture/Compare 2 generation Refer to CC1G description Bit 1 CC1G: Capture/Compare 1 generation This bit is set by software in order to generate an event, it is automatically cleared by hardware. 0: No action 1: A capture/compare event is generated on channel 1: If channel CC1 is configured as output: CC1IF flag is set, Corresponding interrupt or DMA request is sent if enabled.
Advanced-control timer (TIM1) RM0453 Bits 9:8 CC2S[1:0]: Capture/Compare 2 selection This bit-field defines the direction of the channel (input/output) as well as the used input. 00: CC2 channel is configured as output 01: CC2 channel is configured as input, IC2 is mapped on TI2 10: CC2 channel is configured as input, IC2 is mapped on TI1 11: CC2 channel is configured as input, IC2 is mapped on TRC.
Page 803
RM0453 Advanced-control timer (TIM1) corresponding CCxS bits. All the other bits of this register have a different function for input capture and for output compare modes. It is possible to combine both modes independently (e.g. channel 1 in input capture mode and channel 2 in output compare mode). Output compare mode: Res.
Page 804
Advanced-control timer (TIM1) RM0453 Bits 16, 6:4 OC1M[3:0]: Output Compare 1 mode These bits define the behavior of the output reference signal OC1REF from which OC1 and OC1N are derived. OC1REF is active high whereas OC1 and OC1N active level depends on CC1P and CC1NP bits.
RM0453 Advanced-control timer (TIM1) Bit 3 OC1PE: Output Compare 1 preload enable 0: Preload register on TIMx_CCR1 disabled. TIMx_CCR1 can be written at anytime, the new value is taken in account immediately. 1: Preload register on TIMx_CCR1 enabled. Read/Write operations access the preload register.
Advanced-control timer (TIM1) RM0453 Bits 31:16 Reserved, must be kept at reset value. Bits 15:12 IC4F[3:0]: Input capture 4 filter Refer to IC1F[3:0] description. Bits 11:10 IC4PSC[1:0]: Input capture 4 prescaler Refer to IC1PSC[1:0] description. Bits 9:8 CC4S[1:0]: Capture/Compare 4 selection This bit-field defines the direction of the channel (input/output) as well as the used input.
Page 807
RM0453 Advanced-control timer (TIM1) Bits 31:25 Reserved, must be kept at reset value. Bits 23:17 Reserved, must be kept at reset value. Bit 15 OC4CE: Output compare 4 clear enable Refer to OC1CE description. Bits 24, 14:12 OC4M[3:0]: Output compare 4 mode Refer to OC3M[3:0] description.
Advanced-control timer (TIM1) RM0453 Bit 0 CC1E: Capture/Compare 1 output enable 0: Capture mode disabled / OC1 is not active (see below) 1: Capture mode enabled / OC1 signal is output on the corresponding output pin When CC1 channel is configured as output, the OC1 level depends on MOE, OSSI, OSSR, OIS1, OIS1N and CC1NE bits, regardless of the CC1E bits state.
RM0453 Advanced-control timer (TIM1) 25.4.12 TIM1 counter (TIM1_CNT) Address offset: 0x24 Reset value: 0x0000 0000 Res. Res. Res. Res. Res. Res. Res. Res. Res. Res. Res. Res. Res. Res. Res. CNT[15:0] Bit 31 UIFCPY: UIF copy This bit is a read-only copy of the UIF bit of the TIMx_ISR register. If the UIFREMAP bit in the TIMxCR1 is reset, bit 31 is reserved and read at 0.
Advanced-control timer (TIM1) RM0453 25.4.15 TIM1 repetition counter register (TIM1_RCR) Address offset: 0x30 Reset value: 0x0000 REP[15:0] Bits 15:0 REP[15:0]: Repetition counter value These bits allow the user to set-up the update rate of the compare registers (i.e. periodic transfers from preload to active registers) when preload registers are enable, as well as the update interrupt generation rate, if this interrupt is enable.
RM0453 Advanced-control timer (TIM1) 25.4.17 TIM1 capture/compare register 2 (TIM1_CCR2) Address offset: 0x38 Reset value: 0x0000 CCR2[15:0] Bits 15:0 CCR2[15:0]: Capture/Compare 2 value If channel CC2 is configured as output: CCR2 is the value to be loaded in the actual capture/compare 2 register (preload value).
Advanced-control timer (TIM1) RM0453 25.4.19 TIM1 capture/compare register 4 (TIM1_CCR4) Address offset: 0x40 Reset value: 0x0000 CCR4[15:0] Bits 15:0 CCR4[15:0]: Capture/Compare value If channel CC4 is configured as output: CCR4 is the value to be loaded in the actual capture/compare 4 register (preload value). It is loaded permanently if the preload feature is not selected in the TIMx_CCMR2 register (bit OC4PE).
Page 815
RM0453 Advanced-control timer (TIM1) Bit 28 BKBID: Break Bidirectional 0: Break input BRK in input mode 1: Break input BRK in bidirectional mode In the bidirectional mode (BKBID bit set to 1), the break input is configured both in input mode and in open drain output mode.
Page 816
Advanced-control timer (TIM1) RM0453 Bits 23:20 BK2F[3:0]: Break 2 filter This bit-field defines the frequency used to sample BRK2 input and the length of the digital filter applied to BRK2. The digital filter is made of an event counter in which N consecutive events are needed to validate a transition on the output: 0000: No filter, BRK2 acts asynchronously 0001: f...
Page 817
RM0453 Advanced-control timer (TIM1) Bit 15 MOE: Main output enable This bit is cleared asynchronously by hardware as soon as one of the break inputs is active (BRK or BRK2). It is set by software or automatically depending on the AOE bit. It is acting only on the channels which are configured in output.
Advanced-control timer (TIM1) RM0453 Bit 10 OSSI: Off-state selection for Idle mode This bit is used when MOE=0 due to a break event or by a software write, on channels configured as outputs. See OC/OCN enable description for more details (Section 25.4.11: TIM1 capture/compare enable register (TIM1_CCER)).
RM0453 Advanced-control timer (TIM1) Bits 12:8 DBL[4:0]: DMA burst length This 5-bit vector defines the length of DMA transfers (the timer recognizes a burst transfer when a read or a write access is done to the TIMx_DMAR address), i.e. the number of transfers.
Advanced-control timer (TIM1) RM0453 Bits 31:0 DMAB[31:0]: DMA register for burst accesses A read or write operation to the DMAR register accesses the register located at the address (TIMx_CR1 address) + (DBA + DMA index) x 4 where TIMx_CR1 address is the address of the control register 1, DBA is the DMA base address configured in TIMx_DCR register, DMA index is automatically controlled by the DMA transfer, and ranges from 0 to DBL (DBL configured in TIMx_DCR).
Advanced-control timer (TIM1) RM0453 Bit 31 GC5C3: Group Channel 5 and Channel 3 Distortion on Channel 3 output: 0: No effect of OC5REF on OC3REFC 1: OC3REFC is the logical AND of OC3REFC and OC5REF This bit can either have immediate effect or be preloaded and taken into account after an update event (if preload feature is selected in TIMxCCMR2).
Advanced-control timer (TIM1) RM0453 Bit 2 BKCMP2E: BRK COMP2 enable This bit enables the COMP2 for the timer’s BRK input. COMP2 output is ‘ORed’ with the other BRK sources. 0: COMP2 input disabled 1: COMP2 input enabled Note: This bit can not be modified as long as LOCK level 1 has been programmed (LOCK bits in TIMx_BDTR register).
Page 825
RM0453 Advanced-control timer (TIM1) Bit 10 BK2CMP1P: BRK2 COMP1 input polarity This bit selects the COMP1 input sensitivity. It must be programmed together with the BK2P polarity bit. 0: COMP1 input polarity is not inverted (active low if BK2P=0, active high if BK2P=1) 1: COMP1 input polarity is inverted (active high if BK2P=0, active low if BK2P=1) Note: This bit can not be modified as long as LOCK level 1 has been programmed (LOCK bits in TIMx_BDTR register).
RM0453 Advanced-control timer (TIM1) 25.4.30 TIM1 register map TIM1 registers are mapped as 16-bit addressable registers as described in the table below: Table 181. TIM1 register map and reset values Register Offset name TIM1_CR1 [1:0] [1:0] 0x00 Reset value TIM1_CR2 MMS2[3:0] [2:0] 0x04...
Page 828
Advanced-control timer (TIM1) RM0453 Table 181. TIM1 register map and reset values (continued) Register Offset name TIM1_CNT CNT[15:0] 0x24 Reset value TIM1_PSC PSC[15:0] 0x28 Reset value TIM1_ARR ARR[15:0] 0x2C Reset value TIM1_RCR REP[15:0] 0x30 Reset value TIM1_CCR1 CCR1[15:0] 0x34 Reset value TIM1_CCR2 CCR2[15:0] 0x38...
Page 829
RM0453 Advanced-control timer (TIM1) Table 181. TIM1 register map and reset values (continued) Register Offset name TIM1_CCMR3 OC6M OC5M Output [2:0] [2:0] 0x54 Compare mode Reset value TIM1_CCR5 CCR5[15:0] 0x58 Reset value TIM1_CCR6 CCR6[15:0] 0x5C Reset value TIM1_AF1 ETRSEL 0x60 [3:0] Reset value TIM1_AF2...
General-purpose timer (TIM2) RM0453 General-purpose timer (TIM2) 26.1 TIM2 introduction The general-purpose timer TIM2 consists of a 32-bit auto-reload counter driven by a programmable prescaler. The timer may be used for a variety of purposes, including measuring the pulse lengths of input signals (input capture) or generating output waveforms (output compare and PWM).
General-purpose timer (TIM2) RM0453 26.3 TIM2 functional description 26.3.1 Time-base unit The main block of the programmable timer is a 32-bit counter with its related auto-reload register. The counter can count up, down or both up and down but also down or both up and down.
RM0453 General-purpose timer (TIM2) Figure 189. Counter timing diagram with prescaler division change from 1 to 2 CK_PSC Timerclock = CK_CNT FA FB Counter register Update event (UEV) Prescaler control register Write a new value in TIMx_PSC Prescaler buffer Prescaler counter MS31076V2 Figure 190.
General-purpose timer (TIM2) RM0453 26.3.2 Counter modes Upcounting mode In upcounting mode, the counter counts from 0 to the auto-reload value (content of the TIMx_ARR register), then restarts from 0 and generates a counter overflow event. An Update event can be generated at each counter overflow or by setting the UG bit in the TIMx_EGR register (by software or by using the slave mode controller).
General-purpose timer (TIM2) RM0453 The following figures show some examples of the counter behavior for different clock frequencies when TIMx_ARR=0x36. Figure 197. Counter timing diagram, internal clock divided by 1 CK_PSC CNT_EN Timerclock = CK_CNT Counter register 01 00 34 33 32 Counter underflow (cnt_udf) Update event (UEV)
General-purpose timer (TIM2) RM0453 Figure 201. Counter timing diagram, Update event when repetition counter is not used CK_PSC Timerclock = CK_CNT 30 2F Counter register Counter underflow Update event (UEV) Update interrupt flag (UIF) Auto-reload preload register Write a new value in TIMx_ARR MS31188V1 Center-aligned mode (up/down counting) In center-aligned mode, the counter counts from 0 to the auto-reload value (content of the...
RM0453 General-purpose timer (TIM2) DMA request is sent). This is to avoid generating both update and capture interrupt when clearing the counter on the capture event. When an update event occurs, all the registers are updated and the update flag (UIF bit in TIMx_SR register) is set (depending on the URS bit): •...
General-purpose timer (TIM2) RM0453 Note: The capture prescaler is not used for triggering, so it does not need to be configured. Select rising edge polarity by writing CC2P=0 and CC2NP=0 and CC2NP=0 in the TIMx_CCER register. Configure the timer in external clock mode 1 by writing SMS=111 in the TIMx_SMCR register.
General-purpose timer (TIM2) RM0453 Figure 212. Control circuit in external clock mode 2 f CK_INT CNT_EN ETRP ETRF Counter clock = CK_CNT =CK_PSC Counter register MSv33111V3 26.3.4 Capture/Compare channels Each Capture/Compare channel is built around a capture/compare register (including a shadow register), a input stage for capture (with digital filter, multiplexing and prescaler) and an output stage (with comparator and output control).
General-purpose timer (TIM2) RM0453 26.3.5 Input capture mode In Input capture mode, the Capture/Compare Registers (TIMx_CCRx) are used to latch the value of the counter after a transition detected by the corresponding ICx signal. When a capture occurs, the corresponding CCXIF flag (TIMx_SR register) is set and an interrupt or a DMA request can be sent if they are enabled.
RM0453 General-purpose timer (TIM2) 26.3.6 PWM input mode This mode is a particular case of input capture mode. The procedure is the same except: • Two ICx signals are mapped on the same TIx input. • These 2 ICx signals are active on edges with opposite polarity. •...
General-purpose timer (TIM2) RM0453 26.3.7 Forced output mode In output mode (CCxS bits = 00 in the TIMx_CCMRx register), each output compare signal (OCxREF and then OCx) can be forced to active or inactive level directly by software, independently of any comparison between the output compare register and the counter. To force an output compare signal (ocxref/OCx) to its active level, one just needs to write 101 in the OCxM bits in the corresponding TIMx_CCMRx register.
RM0453 General-purpose timer (TIM2) The TIMx_CCRx register can be updated at any time by software to control the output waveform, provided that the preload register is not enabled (OCxPE=0, else TIMx_CCRx shadow register is updated only at the next update event UEV). An example is given in Figure 217.
General-purpose timer (TIM2) RM0453 cleared by an external event through the ETR signal until the next PWM period), the OCREF signal is asserted only: • When the result of the comparison or • When the output compare mode (OCxM bits in TIMx_CCMRx register) switches from the “frozen”...
Page 855
RM0453 General-purpose timer (TIM2) Downcounting configuration Downcounting is active when DIR bit in TIMx_CR1 register is high. Refer to Downcounting mode on page 837. In PWM mode 1, the reference signal ocxref is low as long as TIMx_CNT>TIMx_CCRx else it becomes high. If the compare value in TIMx_CCRx is greater than the auto-reload value in TIMx_ARR, then ocxref is held at 100%.
RM0453 General-purpose timer (TIM2) 26.3.10 Asymmetric PWM mode Asymmetric mode allows two center-aligned PWM signals to be generated with a programmable phase shift. While the frequency is determined by the value of the TIMx_ARR register, the duty cycle and the phase-shift are determined by a pair of TIMx_CCRx registers.
General-purpose timer (TIM2) RM0453 When a given channel is used as combined PWM channel, its secondary channel must be configured in the opposite PWM mode (for instance, one in Combined PWM mode 1 and the other in Combined PWM mode 2). Note: The OCxM[3:0] bit field is split into two parts for compatibility reasons, the most significant bit is not contiguous with the 3 least significant ones.
RM0453 General-purpose timer (TIM2) The OCxREF signal for a given channel can be reset by applying a high level on the ETRF input (OCxCE enable bit set to 1 in the corresponding TIMx_CCMRx register). OCxREF remains low until the next update event (UEV) occurs. This function can be used only in the output compare and PWM modes.
General-purpose timer (TIM2) RM0453 26.3.13 One-pulse mode One-pulse mode (OPM) is a particular case of the previous modes. It allows the counter to be started in response to a stimulus and to generate a pulse with a programmable length after a programmable delay. Starting the counter can be controlled through the slave mode controller.
RM0453 General-purpose timer (TIM2) The OPM waveform is defined by writing the compare registers (taking into account the clock frequency and the counter prescaler). • The t is defined by the value written in the TIMx_CCR1 register. DELAY • The t is defined by the difference between the auto-reload value and the compare PULSE value (TIMx_ARR - TIMx_CCR1).
General-purpose timer (TIM2) RM0453 Figure 224. Retriggerable one-pulse mode. TRGI Counter Output MS33106V1 26.3.15 Encoder interface mode To select Encoder Interface mode write SMS=‘001 in the TIMx_SMCR register if the counter is counting on TI2 edges only, SMS=010 if it is counting on TI1 edges only and SMS=011 if it is counting on both TI1 and TI2 edges.
RM0453 General-purpose timer (TIM2) Table 182. Counting direction versus encoder signals Level on opposite TI1FP1 signal TI2FP2 signal Active edge signal (TI1FP1 for Rising Falling Rising Falling TI2, TI2FP2 for TI1) High Down No Count No Count Counting on TI1 only Down No Count No Count...
General-purpose timer (TIM2) RM0453 Figure 226. Example of encoder interface mode with TI1FP1 polarity inverted forward jitter backward jitter forward Counter down down MS33108V1 The timer, when configured in Encoder Interface mode provides information on the sensor’s current position. Dynamic information can be obtained (speed, acceleration, deceleration) by measuring the period between two encoder events using a second timer configured in capture mode.
RM0453 General-purpose timer (TIM2) 26.3.18 Timers and external trigger synchronization The TIMx Timers can be synchronized with an external trigger in several modes: Reset mode, Gated mode and Trigger mode. Slave mode: Reset mode The counter and its prescaler can be reinitialized in response to an event on a trigger input. Moreover, if the URS bit from the TIMx_CR1 register is low, an update event UEV is generated.
General-purpose timer (TIM2) RM0453 Configure the channel 1 to detect low levels on TI1. Configure the input filter duration (in this example, we do not need any filter, so we keep IC1F=0000). The capture prescaler is not used for triggering, so it does not need to be configured. The CC1S bits select the input capture source only, CC1S=01 in TIMx_CCMR1 register.
RM0453 General-purpose timer (TIM2) CC2P=1 and CC2NP=0 in TIMx_CCER register to validate the polarity (and detect low level only). Configure the timer in trigger mode by writing SMS=110 in TIMx_SMCR register. Select TI2 as the input source by writing TS=00110 in TIMx_SMCR register. When a rising edge occurs on TI2, the counter starts counting on the internal clock and the TIF flag is set.
General-purpose timer (TIM2) RM0453 A rising edge on TI1 enables the counter and sets the TIF flag. The counter then counts on ETR rising edges. The delay between the rising edge of the ETR signal and the actual reset of the counter is due to the resynchronization circuit on ETRP input.
RM0453 General-purpose timer (TIM2) Figure 232. Master/slave connection example with 1 channel only timers TIM_mstr TIM_slv Clock Prescaler Counter Output Slave tim_oc1 tim_itr CK_PSC mode control control Compare 1 Prescaler Counter Input TIM_CH1 trigger selection MSv65225V1 Note: The timers with one channel only (see Figure 232) do not feature a master mode.
General-purpose timer (TIM2) RM0453 Configure TIM1 master mode to send its Output Compare 1 Reference (OC1REF) signal as trigger output (MMS=100 in the TIM1_CR2 register). Configure the TIM1 OC1REF waveform (TIM1_CCMR1 register). Configure TIM2 to get the input trigger from TIM1 (TS=00000 in the TIM2_SMCR register).
RM0453 General-purpose timer (TIM2) Figure 234. Gating TIM2 with Enable of TIM1 CK_INT TIM1-CEN=CNT_EN TIM1-CNT_INIT TIM1-CNT TIM2-CNT TIM2-CNT_INIT TIM2-write CNT TIM2-TIF Write TIF = 0 MS32696V1 Using one timer to start another timer In this example, we set the enable of Timer 2 with the update event of Timer 1. Refer to Figure 231 for connections.
General-purpose timer (TIM2) RM0453 As in the previous example, both counters can be initialized before starting counting. Figure 236 shows the behavior with the same configuration as in Figure 235 but in trigger mode instead of gated mode (SMS=110 in the TIM2_SMCR register). Figure 236.
RM0453 General-purpose timer (TIM2) As an example, the timer DMA burst feature is used to update the contents of the CCRx registers (x = 2, 3, 4) upon an update event, with the DMA transferring half words into the CCRx registers. This is done in the following steps: Configure the corresponding DMA channel as follows: –...
General-purpose timer (TIM2) RM0453 26.4 TIM2 registers In this section, “TIMx” should be understood as “TIM2” since there is only one instance of this type of timer for the products to which this reference manual applies. Refer to Section 1.2 for a list of abbreviations used in register descriptions.
RM0453 General-purpose timer (TIM2) Bit 4 DIR: Direction 0: Counter used as upcounter 1: Counter used as downcounter Note: This bit is read only when the timer is configured in Center-aligned mode or Encoder mode. Bit 3 OPM: One-pulse mode 0: Counter is not stopped at update event 1: Counter stops counting at the next update event (clearing the bit CEN) Bit 2 URS: Update request source...
Page 876
General-purpose timer (TIM2) RM0453 Bits 15:8 Reserved, must be kept at reset value. Bit 7 TI1S: TI1 selection 0: The TIMx_CH1 pin is connected to TI1 input 1: The TIMx_CH1, CH2 and CH3 pins are connected to the TI1 input (XOR combination) Section 25.3.25: Interfacing with Hall sensors on page 781 See also Bits 6:4 MMS[2:0]: Master mode selection...
RM0453 General-purpose timer (TIM2) 26.4.3 TIM2 slave mode control register (TIM2_SMCR) Address offset: 0x08 Reset value: 0x0000 0000 Res. Res. Res. Res. Res. Res. Res. Res. Res. Res. TS[4:3] Res. Res. Res. SMS[3] ETPS[1:0] ETF[3:0] TS[2:0] OCCS SMS[2:0] Bits 31:22 Reserved, must be kept at reset value. Bits 19:17 Reserved, must be kept at reset value.
Page 878
General-purpose timer (TIM2) RM0453 Bits 11:8 ETF[3:0]: External trigger filter This bit-field then defines the frequency used to sample ETRP signal and the length of the digital filter applied to ETRP. The digital filter is made of an event counter in which N consecutive events are needed to validate a transition on the output: 0000: No filter, sampling is done at f 0001: f...
Page 879
RM0453 General-purpose timer (TIM2) Bits 21, 20, 6, 5, 4 TS[4:0]: Trigger selection This bit-field selects the trigger input to be used to synchronize the counter. 00000: Internal Trigger 0 (ITR0) 00001: Internal Trigger 1 (ITR1) 00010: Internal Trigger 2 (ITR2) 00011: Internal Trigger 3 (ITR3) 00100: TI1 Edge Detector (TI1F_ED) 00101: Filtered Timer Input 1 (TI1FP1)
General-purpose timer (TIM2) RM0453 Bits 16, 2, 1, 0 SMS[3:0]: Slave mode selection When external signals are selected the active edge of the trigger signal (TRGI) is linked to the polarity selected on the external input (see Input Control register and Control Register description.
Page 882
General-purpose timer (TIM2) RM0453 Bit 9 CC1OF: Capture/Compare 1 overcapture flag This flag is set by hardware only when the corresponding channel is configured in input capture mode. It is cleared by software by writing it to ‘0’. 0: No overcapture has been detected. 1: The counter value has been captured in TIMx_CCR1 register while CC1IF flag was already set Bits 8:7 Reserved, must be kept at reset value.
RM0453 General-purpose timer (TIM2) 26.4.6 TIM2 event generation register (TIM2_EGR) Address offset: 0x14 Reset value: 0x0000 Res. Res. Res. Res. Res. Res. Res. Res. Res. Res. CC4G CC3G CC2G CC1G Bits 15:7 Reserved, must be kept at reset value. Bit 6 TG: Trigger generation This bit is set by software in order to generate an event, it is automatically cleared by hardware.
General-purpose timer (TIM2) RM0453 26.4.7 TIM2 capture/compare mode register 1 [alternate] (TIM2_CCMR1) Address offset: 0x18 Reset value: 0x0000 0000 The same register can be used for input capture mode (this section) or for output compare mode (next section). The direction of a channel is defined by configuring the corresponding CCxS bits.
RM0453 General-purpose timer (TIM2) Bits 7:4 IC1F[3:0]: Input capture 1 filter This bit-field defines the frequency used to sample TI1 input and the length of the digital filter applied to TI1. The digital filter is made of an event counter in which N consecutive events are needed to validate a transition on the output: 0000: No filter, sampling is done at f 0001: f...
Page 886
General-purpose timer (TIM2) RM0453 OC2CE OC2M[2:0] OC2PE OC2FE CC2S[1:0] OC1CE OC1M[2:0] OC1PE OC1FE CC1S[1:0] Bits 31:25 Reserved, must be kept at reset value. Bits 23:17 Reserved, must be kept at reset value. Bit 15 OC2CE: Output compare 2 clear enable Bits 24, 14:12 OC2M[3:0]: Output compare 2 mode refer to OC1M description on bits 6:4 Bit 11 OC2PE: Output compare 2 preload enable...
Page 887
RM0453 General-purpose timer (TIM2) Bits 16, 6:4 OC1M[3:0]: Output compare 1 mode These bits define the behavior of the output reference signal OC1REF from which OC1 and OC1N are derived. OC1REF is active high whereas OC1 and OC1N active level depends on CC1P and CC1NP bits.
General-purpose timer (TIM2) RM0453 Bit 3 OC1PE: Output compare 1 preload enable 0: Preload register on TIMx_CCR1 disabled. TIMx_CCR1 can be written at anytime, the new value is taken in account immediately. 1: Preload register on TIMx_CCR1 enabled. Read/Write operations access the preload register.
RM0453 General-purpose timer (TIM2) Bits 9:8 CC4S[1:0]: Capture/Compare 4 selection This bit-field defines the direction of the channel (input/output) as well as the used input. 00: CC4 channel is configured as output 01: CC4 channel is configured as input, IC4 is mapped on TI4 10: CC4 channel is configured as input, IC4 is mapped on TI3 11: CC4 channel is configured as input, IC4 is mapped on TRC.
General-purpose timer (TIM2) RM0453 Bits 9:8 CC4S[1:0]: Capture/Compare 4 selection This bit-field defines the direction of the channel (input/output) as well as the used input. 00: CC4 channel is configured as output 01: CC4 channel is configured as input, IC4 is mapped on TI4 10: CC4 channel is configured as input, IC4 is mapped on TI3 11: CC4 channel is configured as input, IC4 is mapped on TRC.
RM0453 General-purpose timer (TIM2) Bit 7 CC2NP: Capture/Compare 2 output Polarity. Refer to CC1NP description Bit 6 Reserved, must be kept at reset value. Bit 5 CC2P: Capture/Compare 2 output Polarity. refer to CC1P description Bit 4 CC2E: Capture/Compare 2 output enable. Refer to CC1E description Bit 3 CC1NP: Capture/Compare 1 output Polarity.
General-purpose timer (TIM2) RM0453 Address offset: 0x24 Reset value: 0x0000 0000 CNT[31:16] CNT[15:0] Bits 31:0 CNT[31:0]: counter value 26.4.13 TIM2 counter [alternate] (TIM2_CNT) Bit 31 of this register has two possible definitions depending on the value of UIFREMAP in TIMx_CR1 register: •...
RM0453 General-purpose timer (TIM2) 26.4.15 TIM2 auto-reload register (TIM2_ARR) Address offset: 0x2C Reset value: 0xFFFF FFFF ARR[31:16] ARR[15:0] Bits 31:0 ARR[31:0]: Auto-reload value ARR is the value to be loaded in the actual auto-reload register. Refer to the Section 26.3.1: Time-base unit on page 832 for more details about ARR update and behavior.
General-purpose timer (TIM2) RM0453 CCR2[31:16] CCR2[15:0] Bits 31:0 CCR2[31:0]: Capture/Compare 2 value If channel CC2 is configured as output: CCR2 is the value to be loaded in the actual capture/compare 2 register (preload value). It is loaded permanently if the preload feature is not selected in the TIMx_CCMR1 register (bit OC2PE).
Page 895
RM0453 General-purpose timer (TIM2) CCR4[31:16] CCR4[15:0] Bits 31:0 CCR4[31:0]: Capture/Compare value if CC4 channel is configured as output (CC4S bits): CCR4 is the value to be loaded in the actual capture/compare 4 register (preload value). It is loaded permanently if the preload feature is not selected in the TIMx_CCMR2 register (bit OC4PE).
General-purpose timer (TIM2) RM0453 26.4.20 TIM2 DMA control register (TIM2_DCR) Address offset: 0x48 Reset value: 0x0000 Res. Res. Res. DBL[4:0] Res. Res. Res. DBA[4:0] Bits 15:13 Reserved, must be kept at reset value. Bits 12:8 DBL[4:0]: DMA burst length This 5-bit vector defines the number of DMA transfers (the timer recognizes a burst transfer when a read or a write access is done to the TIMx_DMAR address).
RM0453 General-purpose timer (TIM2) 26.4.25 TIMx register map TIMx registers are mapped as described in the table below: Table 185. TIM2 register map and reset values Register Offset name TIMx_CR1 [1:0] [1:0] 0x00 Reset value TIMx_CR2 MMS[2:0] 0x04 Reset value ETPS TIMx_SMCR ETF[3:0]...
Page 900
General-purpose timer (TIM2) RM0453 Table 185. TIM2 register map and reset values (continued) Register Offset name TIMx_CNT CNT[30:0] 0x24 Reset value TIMx_PSC PSC[15:0] 0x28 Reset value TIMx_ARR ARR[31:0] 0x2C Reset value 0x30 Reserved TIMx_CCR1 CCR1[31:0] 0x34 Reset value TIMx_CCR2 CCR2[31:0] 0x38 Reset value TIMx_CCR3...
Page 901
RM0453 General-purpose timer (TIM2) Table 185. TIM2 register map and reset values (continued) Register Offset name TIM2_TISEL TI2SEL[3:0] TI1SEL[3:0] 0x68 Reset value Refer to Section 2.6 on page 70 for the register boundary addresses. RM0453 Rev 1 901/1461...
General-purpose timers (TIM16/TIM17) RM0453 General-purpose timers (TIM16/TIM17) 27.1 TIM16/TIM17 introduction The TIM16/TIM17 timers consist of a 16-bit auto-reload counter driven by a programmable prescaler. They may be used for a variety of purposes, including measuring the pulse lengths of input signals (input capture) or generating output waveforms (output compare, PWM, complementary PWM with dead-time insertion).
General-purpose timers (TIM16/TIM17) RM0453 27.3 TIM16/TIM17 functional description 27.3.1 Time-base unit The main block of the programmable advanced-control timer is a 16-bit upcounter with its related auto-reload register. The counter clock can be divided by a prescaler. The counter, the auto-reload register and the prescaler register can be written or read by software.
RM0453 General-purpose timers (TIM16/TIM17) Figure 238. Counter timing diagram with prescaler division change from 1 to 2 CK_PSC Timerclock = CK_CNT FA FB Counter register Update event (UEV) Prescaler control register Write a new value in TIMx_PSC Prescaler buffer Prescaler counter MS31076V2 Figure 239.
General-purpose timers (TIM16/TIM17) RM0453 27.3.2 Counter modes Upcounting mode In upcounting mode, the counter counts from 0 to the auto-reload value (content of the TIMx_ARR register), then restarts from 0 and generates a counter overflow event. If the repetition counter is used, the update event (UEV) is generated after upcounting is repeated for the number of times programmed in the repetition counter register (TIMx_RCR).
General-purpose timers (TIM16/TIM17) RM0453 27.3.3 Repetition counter Section 27.3.1: Time-base unit describes how the update event (UEV) is generated with respect to the counter overflows. It is actually generated only when the repetition counter has reached zero. This can be useful when generating PWM signals. This means that data are transferred from the preload registers to the shadow registers (TIMx_ARR auto-reload register, TIMx_PSC prescaler register, but also TIMx_CCRx capture/compare registers in compare mode) every N counter overflows, where N is the...
General-purpose timers (TIM16/TIM17) RM0453 Figure 247 shows the behavior of the control circuit and the upcounter in normal mode, without prescaler. Figure 247. Control circuit in normal mode, internal clock divided by 1 Internal clock CEN=CNT_EN CNT_INIT Counter clock = CK_CNT = CK_PSC Counter register 33 34 35 36...
RM0453 General-purpose timers (TIM16/TIM17) Select the proper TI2[x] source (internal or external) with the TI2SEL[3:0] bits in the TIMx_TISEL register. Configure channel 2 to detect rising edges on the TI2 input by writing CC2S = ‘01’ in the TIMx_CCMR1 register. Configure the input filter duration by writing the IC2F[3:0] bits in the TIMx_CCMR1 register (if no filter is needed, keep IC2F=0000).
General-purpose timers (TIM16/TIM17) RM0453 detected (sampled at f frequency). Then write IC1F bits to 0011 in the TIMx_CCMR1 register. Select the edge of the active transition on the TI1 channel by writing CC1P bit to 0 in the TIMx_CCER register (rising edge in this case). Program the input prescaler.
Page 917
RM0453 General-purpose timers (TIM16/TIM17) When a match is found between the capture/compare register and the counter, the output compare function: • Assigns the corresponding output pin to a programmable value defined by the output compare mode (OCxM bits in the TIMx_CCMRx register) and the output polarity (CCxP bit in the TIMx_CCER register).
General-purpose timers (TIM16/TIM17) RM0453 Figure 253. Output compare mode, toggle on OC1 Write B201h in the CC1R register B200 B201 TIM1_CNT 0039 003A 003B B201 003A TIM1_CCR1 OC1REF= OC1 Match detected on CCR1 Interrupt generated if enabled MS31092V1 27.3.9 PWM mode Pulse Width Modulation mode allows a signal to be generated with a frequency determined by the value of the TIMx_ARR register and a duty cycle determined by the value of the TIMx_CCRx register.
General-purpose timers (TIM16/TIM17) RM0453 If the delay is greater than the width of the active output (OCx or OCxN) then the corresponding pulse is not generated. The following figures show the relationships between the output signals of the dead-time generator and the reference signal OCxREF. (we suppose CCxP=0, CCxNP=0, MOE=1, CCxE=1 and CCxNE=1 in these examples) Figure 255.
RM0453 General-purpose timers (TIM16/TIM17) Figure 257. Dead-time waveforms with delay greater than the positive pulse. OCxREF OCxN delay MS31097V1 The dead-time delay is the same for each of the channels and is programmable with the DTG bits in the TIMx_BDTR register. Refer to Section 27.4.14: TIMx break and dead-time register (TIMx_BDTR)(x = 16 to 17) on page 943 for delay calculation.
Page 922
General-purpose timers (TIM16/TIM17) RM0453 must be inserted (dummy instruction) before reading it correctly. This is because the write acts on the asynchronous signal whereas the read reflects the synchronous signal. When a break occurs (selected level on the break input): •...
General-purpose timers (TIM16/TIM17) RM0453 27.3.12 Bidirectional break inputs The TIM16/TIM17 are featuring bidirectional break I/Os, as represented on Figure 259. They allow the following: • A board-level global break signal available for signaling faults to external MCUs or gate drivers, with a unique pin being both an input and an output status pin •...
RM0453 General-purpose timers (TIM16/TIM17) The following procedure must be followed to re-arm the protection after a break event: • The BKDSRM bit must be set to release the output control • The software must wait until the system break condition disappears (if any) and clear the SBIF status flag (or clear it systematically before re-arming) •...
General-purpose timers (TIM16/TIM17) RM0453 27.3.13 One-pulse mode One-pulse mode (OPM) is a particular case of the previous modes. It allows the counter to be started in response to a stimulus and to generate a pulse with a programmable length after a programmable delay. Starting the counter can be controlled through the slave mode controller.
RM0453 General-purpose timers (TIM16/TIM17) Figure 260. Example of one pulse mode OC1REF TIM1_ARR TIM1_CCR1 DELAY PULSE MS31099V1 For example one may want to generate a positive pulse on OC1 with a length of t PULSE after a delay of t as soon as a positive edge is detected on the TI2 input pin.
General-purpose timers (TIM16/TIM17) RM0453 Particular case: OCx fast enable In One-pulse mode, the edge detection on TIx input set the CEN bit which enables the counter. Then the comparison between the counter and the compare value makes the output toggle. But several clock cycles are needed for these operations and it limits the minimum delay t min we can get.
RM0453 General-purpose timers (TIM16/TIM17) For example, the timer DMA burst feature could be used to update the contents of the CCRx registers (x = 2, 3, 4) on an update event, with the DMA transferring half words into the CCRx registers. This is done in the following steps: Configure the corresponding DMA channel as follows: –...
General-purpose timers (TIM16/TIM17) RM0453 27.4 TIM16/TIM17 registers Refer to Section 1.2 for a list of abbreviations used in register descriptions. The peripheral registers can be accessed by half-words (16-bit) or words (32-bit). 27.4.1 TIMx control register 1 (TIMx_CR1)(x = 16 to 17) Address offset: 0x00 Reset value: 0x0000 UIFRE...
RM0453 General-purpose timers (TIM16/TIM17) Bit 1 UDIS: Update disable This bit is set and cleared by software to enable/disable UEV event generation. 0: UEV enabled. The Update (UEV) event is generated by one of the following events: – Counter overflow/underflow –...
General-purpose timers (TIM16/TIM17) RM0453 Bit 0 CCPC: Capture/compare preloaded control 0: CCxE, CCxNE and OCxM bits are not preloaded 1: CCxE, CCxNE and OCxM bits are preloaded, after having been written, they are updated only when COM bit is set. Note: This bit acts only on channels that have a complementary output.
RM0453 General-purpose timers (TIM16/TIM17) 27.4.4 TIMx status register (TIMx_SR)(x = 16 to 17) Address offset: 0x10 Reset value: 0x0000 Res. Res. Res. Res. Res. Res. CC1OF Res. Res. COMIF Res. Res. Res. CC1IF rc_w0 rc_w0 rc_w0 rc_w0 rc_w0 Bits 15:10 Reserved, must be kept at reset value. Bit 9 CC1OF: Capture/Compare 1 overcapture flag This flag is set by hardware only when the corresponding channel is configured in input capture mode.
General-purpose timers (TIM16/TIM17) RM0453 Bit 0 UIF: Update interrupt flag This bit is set by hardware on an update event. It is cleared by software. 0: No update occurred. 1: Update interrupt pending. This bit is set by hardware when the registers are updated: –...
RM0453 General-purpose timers (TIM16/TIM17) 27.4.6 TIMx capture/compare mode register 1 [alternate] (TIMx_CCMR1) (x = 16 to 17) Address offset: 0x18 Reset value: 0x0000 0000 The same register can be used for input capture mode (this section) or for output compare mode (next section).
General-purpose timers (TIM16/TIM17) RM0453 Bits 7:4 IC1F[3:0]: Input capture 1 filter This bit-field defines the frequency used to sample TI1 input and the length of the digital filter applied to TI1. The digital filter is made of an event counter in which N consecutive events are needed to validate a transition on the output: 0000: No filter, sampling is done at f 0001: f...
Page 937
RM0453 General-purpose timers (TIM16/TIM17) OC1M Res. Res. Res. Res. Res. Res. Res. Res. Res. Res. Res. Res. Res. Res. Res. Res. Res. Res. Res. Res. Res. Res. Res. Res. OC1M[2:0] OC1PE OC1FE CC1S[1:0] Bits 31:17 Reserved, must be kept at reset value. Bits 15:7 Reserved, must be kept at reset value.
General-purpose timers (TIM16/TIM17) RM0453 Bit 2 OC1FE: Output Compare 1 fast enable This bit decreases the latency between a trigger event and a transition on the timer output. It must be used in one-pulse mode (OPM bit set in TIMx_CR1 register), to have the output pulse starting as soon as possible after the starting trigger.
Page 939
RM0453 General-purpose timers (TIM16/TIM17) Bit 2 CC1NE: Capture/Compare 1 complementary output enable 0: Off - OC1N is not active. OC1N level is then function of MOE, OSSI, OSSR, OIS1, OIS1N and CC1E bits. 1: On - OC1N signal is output on the corresponding output pin depending on MOE, OSSI, OSSR, OIS1, OIS1N and CC1E bits.
General-purpose timers (TIM16/TIM17) RM0453 Table 187. Output control bits for complementary OCx and OCxN channels with break feature (TIM16/17) Control bits Output states MOE bit OSSI bit OSSR bit CCxE bit CCxNE bit OCx output state OCxN output state Output Disabled (not driven by the timer: Hi-Z) OCx=0 OCxN=0, OCxN_EN=0 Output Disabled (not driven...
RM0453 General-purpose timers (TIM16/TIM17) Bit 31 UIFCPY: UIF Copy This bit is a read-only copy of the UIF bit of the TIMx_ISR register. If the UIFREMAP bit in TIMx_CR1 is reset, bit 31 is reserved and read as 0. Bits 30:16 Reserved, must be kept at reset value. Bits 15:0 CNT[15:0]: Counter value 27.4.10 TIMx prescaler (TIMx_PSC)(x = 16 to 17)
General-purpose timers (TIM16/TIM17) RM0453 27.4.12 TIMx repetition counter register (TIMx_RCR)(x = 16 to 17) Address offset: 0x30 Reset value: 0x0000 Res. Res. Res. Res. Res. Res. Res. Res. REP[7:0] Bits 15:8 Reserved, must be kept at reset value. Bits 7:0 REP[7:0]: Repetition counter value These bits allow the user to set-up the update rate of the compare registers (i.e.
Page 944
General-purpose timers (TIM16/TIM17) RM0453 Bit 14 AOE: Automatic output enable 0: MOE can be set only by software 1: MOE can be set by software or automatically at the next update event (if the break input is not be active) Note: This bit can not be modified as long as LOCK level 1 has been programmed (LOCK bits in TIMx_BDTR register).
RM0453 General-purpose timers (TIM16/TIM17) Bit 10 OSSI: Off-state selection for Idle mode This bit is used when MOE=0 on channels configured as outputs. See OC/OCN enable description for more details (Section 27.4.8: TIMx capture/compare enable register (TIMx_CCER)(x = 16 to 17) on page 938).
General-purpose timers (TIM16/TIM17) RM0453 Bits 15:13 Reserved, must be kept at reset value. Bits 12:8 DBL[4:0]: DMA burst length This 5-bit field defines the length of DMA transfers (the timer recognizes a burst transfer when a read or a write access is done to the TIMx_DMAR address), i.e. the number of transfers.
General-purpose timers (TIM16/TIM17) RM0453 Bit 9 BKINP: BRK BKIN input polarity This bit selects the BKIN alternate function input sensitivity. It must be programmed together with the BKP polarity bit. 0: BKIN input is active low 1: BKIN input is active high Note: This bit can not be modified as long as LOCK level 1 has been programmed (LOCK bits in TIMx_BDTR register).
General-purpose timers (TIM16/TIM17) RM0453 Bit 9 BKINP: BRK BKIN input polarity This bit selects the BKIN alternate function input sensitivity. It must be programmed together with the BKP polarity bit. 0: BKIN input is active low 1: BKIN input is active high Note: This bit can not be modified as long as LOCK level 1 has been programmed (LOCK bits in TIMx_BDTR register).
RM0453 General-purpose timers (TIM16/TIM17) 27.4.23 TIM16/TIM17 register map TIM16/TIM17 registers are mapped as 16-bit addressable registers as described in the table below: Table 188. TIM16/TIM17 register map and reset values Register Offset name TIMx_CR1 [1:0] 0x00 Reset value TIMx_CR2 0x04 Reset value TIMx_DIER 0x0C...
Page 952
General-purpose timers (TIM16/TIM17) RM0453 Table 188. TIM16/TIM17 register map and reset values (continued) Register Offset name TIMx_RCR REP[7:0] 0x30 Reset value TIMx_CCR1 CCR1[15:0] 0x34 Reset value TIMx_BDTR DTG[7:0] 0x44 [1:0] Reset value TIMx_DCR DBL[4:0] DBA[4:0] 0x48 Reset value TIMx_DMAR DMAB[15:0] 0x4C Reset value TI1_...
RM0453 Low-power timer (LPTIM) Low-power timer (LPTIM) 28.1 Introduction The LPTIM is a 16-bit timer that benefits from the ultimate developments in power consumption reduction. Thanks to its diversity of clock sources, the LPTIM is able to keep running in all power modes except for Standby mode. Given its capability to run even with no internal clock source, the LPTIM can be used as a “Pulse Counter”...
Low-power timer (LPTIM) RM0453 28.3 LPTIM implementation Table 189 describes LPTIM implementation on STM32WL5x devices. The full set of features is implemented in LPTIM1. LPTIM2 and LPTIM3 support a smaller set of features, but is otherwise identical to LPTIM1. Table 189. STM32WL5x LPTIM features LPTIM modes/features LPTIM1 LPTIM2...
RM0453 Low-power timer (LPTIM) 28.4.2 LPTIM pins and internal signals The following tables provide the list of LPTIM pins and internal signals, respectively. Table 190. LPTIM input/output pins Names Signal type Description LPTIM_IN1 Digital input LPTIM Input 1 from GPIO pin LPTIM_IN2 Digital input LPTIM Input 2 from GPIO pin...
Low-power timer (LPTIM) RM0453 The digital filters are divided into two groups: • The first group of digital filters protects the LPTIM external inputs. The digital filters sensitivity is controlled by the CKFLT bits • The second group of digital filters protects the LPTIM internal trigger inputs. The digital filters sensitivity is controlled by the TRGFLT bits.
RM0453 Low-power timer (LPTIM) 28.4.7 Trigger multiplexer The LPTIM counter may be started either by software or after the detection of an active edge on one of the 8 trigger inputs. TRIGEN[1:0] is used to determine the LPTIM trigger source: •...
Low-power timer (LPTIM) RM0453 Figure 263. LPTIM output waveform, single counting mode configuration when repetition register content is different than zero (with PRELOAD = 1) LPTIM_RCR Repetition counter LPTIM_ARR Compare External trigger event Ignored external trigger event MSv47414V1 - Set-once mode activated: It should be noted that when the WAVE bit-field in the LPTIM_CFGR register is set, the Set- once mode is activated.
RM0453 Low-power timer (LPTIM) Figure 265. LPTIM output waveform, Continuous counting mode configuration Discarded triggers LPTIM_ARR Compare External trigger event MSv39229V2 SNGSTRT and CNTSTRT bits can only be set when the timer is enabled (The ENABLE bit is set to ‘1’). It is possible to change “on the fly” from One-shot mode to Continuous mode. If the Continous mode was previously selected, setting SNGSTRT switches the LPTIM to the One-shot mode.
Low-power timer (LPTIM) RM0453 The LPTIM output waveform can be configured through the WAVE bit as follow: • Resetting the WAVE bit to ‘0’ forces the LPTIM to generate either a PWM waveform or a One pulse waveform depending on which bit is set: CNTSTRT or SNGSTRT. •...
RM0453 Low-power timer (LPTIM) The LPTIM APB interface and the LPTIM kernel logic use different clocks, so there is some latency between the APB write and the moment when these values are available to the counter comparator. Within this latency period, any additional write into these registers must be avoided.
Low-power timer (LPTIM) RM0453 28.4.13 Timer enable The ENABLE bit located in the LPTIM_CR register is used to enable/disable the LPTIM kernel logic. After setting the ENABLE bit, a delay of two counter clock is needed before the LPTIM is actually enabled. The LPTIM_CFGR and LPTIM_IER registers must be modified only when the LPTIM is disabled.
RM0453 Low-power timer (LPTIM) 28.4.15 Encoder mode This mode allows handling signals from quadrature encoders used to detect angular position of rotary elements. Encoder interface mode acts simply as an external clock with direction selection. This means that the counter just counts continuously between 0 and the auto-reload value programmed into the LPTIM_ARR register (0 up to ARR or ARR down to 0 depending on the direction).
Low-power timer (LPTIM) RM0453 Figure 267. Encoder mode counting sequence Counter down MS32491V1 28.4.16 Repetition Counter The LPTIM features a repetition counter that decrements by 1 each time an LPTIM counter overflow event occurs. A repetition counter underflow event is generated when the repetition counter contains zero and the LPTIM counter overflows.
Low-power timer (LPTIM) RM0453 28.5 LPTIM low-power modes Table 201. Effect of low-power modes on the LPTIM Mode Description Sleep No effect. LPTIM interrupts cause the device to exit Sleep mode. If the LPTIM is clocked by an oscillator available in Stop mode, LPTIM is functional Stop and the interrupts cause the device to exit the Stop mode (refer to Section 28.3: LPTIM...
RM0453 Low-power timer (LPTIM) Table 202. Interrupt events (continued) Interrupt event Description Interrupt flag is raised when the repetition counter underflows (or contains Update Event zero) and the LPTIM counter overflows. Repetition register REPOK is set by hardware to inform application that the APB bus write update Ok operation to the LPTIM_RCR register has been successfully completed.
Low-power timer (LPTIM) RM0453 Bit 3 CMPOK: Compare register update OK CMPOK is set by hardware to inform application that the APB bus write operation to the LPTIM_CMP register has been successfully completed. Bit 2 EXTTRIG: External trigger edge event EXTTRIG is set by hardware to inform application that a valid edge on the selected external trigger input has occurred.
RM0453 Low-power timer (LPTIM) Bit 2 EXTTRIGCF: External trigger valid edge clear flag Writing 1 to this bit clears the EXTTRIG flag in the LPTIM_ISR register Bit 1 ARRMCF: Autoreload match clear flag Writing 1 to this bit clears the ARRM flag in the LPTIM_ISR register Bit 0 CMPMCF: Compare match clear flag Writing 1 to this bit clears the CMP flag in the LPTIM_ISR register 28.7.3...
Low-power timer (LPTIM) RM0453 Bit 2 EXTTRIGIE: External trigger valid edge Interrupt Enable EXTTRIG interrupt disabled EXTTRIG interrupt enabled Bit 1 ARRMIE: Autoreload match Interrupt Enable ARRM interrupt disabled ARRM interrupt enabled Bit 0 CMPMIE: Compare match Interrupt Enable CMPM interrupt disabled CMPM interrupt enabled Caution: The LPTIM_IER register must only be modified when the LPTIM is disabled (ENABLE bit reset to ‘0’) 28.7.4...
Page 973
RM0453 Low-power timer (LPTIM) Bit 21 WAVPOL: Waveform shape polarity The WAVEPOL bit controls the output polarity 0: The LPTIM output reflects the compare results between LPTIM_CNT and LPTIM_CCRx registers 1: The LPTIM output reflects the inverse of the compare results between LPTIM_CNT and LPTIM_CCRx registers Bit 20 WAVE: Waveform shape The WAVE bit controls the output shape...
Page 974
Low-power timer (LPTIM) RM0453 Bit 8 Reserved, must be kept at reset value. Bits 7:6 TRGFLT[1:0]: Configurable digital filter for trigger The TRGFLT value sets the number of consecutive equal samples that should be detected when a level change occurs on an internal trigger before it is considered as a valid level transition. An internal clock source must be present to use this feature 00: any trigger active level change is considered as a valid trigger 01: trigger active level change must be stable for at least 2 clock periods before it is considered as...
Low-power timer (LPTIM) RM0453 28.7.13 LPTIM register map The following table summarizes the LPTIM registers. Table 203. LPTIM register map and reset values Offset Register name LPTIM_ISR 0x000 0 0 0 0 0 0 0 0 0 Reset value LPTIM_ICR 0x004 0 0 0 0 0 0 0 0 0 Reset value...
Page 981
RM0453 Low-power timer (LPTIM) Table 203. LPTIM register map and reset values (continued) Offset Register name LPTIM3_OR 0x020 Reset value REP[7:0] LPTIM_RCR 0x028 0 0 0 0 0 0 0 0 Reset value 1. If LPTIM does not support encoder mode feature, this bit is reserved. Refer to Section 28.3: LPTIM implementation.
Infrared interface (IRTIM) RM0453 Infrared interface (IRTIM) An infrared interface (IRTIM) for remote control is available on the device. It can be used with an infrared LED to perform remote control functions. It uses internal connections with TIM16 and TIM17 as shown in Figure 269.
RM0453 Independent watchdog (IWDG) Independent watchdog (IWDG) 30.1 Introduction The devices feature an embedded watchdog peripheral that offers a combination of high safety level, timing accuracy and flexibility of use. The Independent watchdog peripheral detects and solves malfunctions due to software failure, and triggers system reset when the counter reaches a given timeout value.
Independent watchdog (IWDG) RM0453 When the independent watchdog is started by writing the value 0x0000 CCCC in the IWDG key register (IWDG_KR), the counter starts counting down from the reset value of 0xFFF. When it reaches the end of count value (0x000) a reset signal is generated (IWDG reset). Whenever the key value 0x0000 AAAA is written in the IWDG key register (IWDG_KR), the...
RM0453 Independent watchdog (IWDG) 30.3.3 Hardware watchdog If the “Hardware watchdog” feature is enabled through the device option bits, the watchdog is automatically enabled at power-on, and generates a reset unless the IWDG key register (IWDG_KR) is written by the software before the counter reaches end of count or if the downcounter is reloaded inside the window.
Independent watchdog (IWDG) RM0453 30.4 IWDG registers Refer to Section 1.2 on page 58 for a list of abbreviations used in register descriptions. The peripheral registers can be accessed by half-words (16-bit) or words (32-bit). 30.4.1 IWDG key register (IWDG_KR) Address offset: 0x00 Reset value: 0x0000 0000 (reset by Standby mode) Res.
System window watchdog (WWDG) RM0453 System window watchdog (WWDG) 31.1 Introduction The system window watchdog (WWDG) is used to detect the occurrence of a software fault, usually generated by external interference or by unforeseen logical conditions, which causes the application program to abandon its normal sequence. The watchdog circuit generates an MCU reset on expiry of a programmed time period, unless the program refreshes the contents of the down-counter before the T6 bit becomes cleared.
System window watchdog (WWDG) RM0453 Note: The T6 bit can be used to generate a software reset (the WDGA bit is set and the T6 bit is cleared). 31.3.5 How to program the watchdog timeout Use the formula in Figure 272 to calculate the WWDG timeout.
RM0453 System window watchdog (WWDG) As an example, lets assume APB frequency is equal to 48 MHz, WDGTB[2:0] is set to 3 and T[5:0] is set to 63: ⁄ × × × t WWDG 1 48000 4096 43.69ms Refer to the datasheet for the minimum and maximum values of the t WWDG 31.3.6 Debug mode...
System window watchdog (WWDG) RM0453 Bits 31:8 Reserved, must be kept at reset value. Bit 7 WDGA: Activation bit This bit is set by software and only cleared by hardware after a reset. When WDGA = 1, the watchdog can generate a reset. 0: Watchdog disabled 1: Watchdog enabled Bits 6:0 T[6:0]: 7-bit counter (MSB to LSB)
Real-time clock (RTC) RM0453 Real-time clock (RTC) 32.1 Introduction The RTC provides an automatic wakeup to manage all low-power modes. The real-time clock (RTC) is an independent BCD timer/counter. The RTC provides a time- of-day clock/calendar with programmable alarm interrupts. As long as the supply voltage remains in the operating range, the RTC never stops, regardless of the device status (Run mode, low-power mode or under reset).
Need help?
Do you have a question about the STM32WL5 Series and is the answer not in the manual?
Questions and answers