27. Low-power timer (LPTIM)

27.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” which can be useful in some applications. The LPTIM capability to wake up the system from low-power modes, makes it suitable to realize “Timeout functions” with extremely low power consumption.

The LPTIM introduces a flexible clock scheme that provides the needed functionalities and performance, while minimizing the power consumption.

27.2 LPTIM main features

27.3 LPTIM implementation

The table below describes LPTIM implementation on STM32U0 series devices. The full set of features is implemented in LPTIM1 and LPTIM3. LPTIM2 supports a smaller set of features.

Table 145. STM32U0 series LPTIM features

LPTIM modes/features (1)LPTIM1LPTIM2LPTIM3 (2)
Encoder modeXXX
PWM modeXXX
Input CaptureXXX
Number of channels424
Number of DMA requests535
Wake-up in Stop modeXXX

1. X = supported.

2. LPTIM3 is only available on STM32U073/U083 devices.

27.4 LPTIM functional description

27.4.1 LPTIM block diagram

Figure 276. LPTIM2 block diagram (1)

Figure 276. LPTIM2 block diagram. The diagram shows the internal architecture of the LPTIM2 block. It is divided into two main clock domains: the APB clock domain and the Kernel clock domain. In the APB clock domain, there is an LPTIM register interface connected to a 32-bit APB bus, an IRQ interface, and a synchronization block. The Kernel clock domain contains a 16-bit counter, a 16-bit ARR (Auto-Reload Register), a Mux trigger, an Encoder, Edge detectors, Glitch filters, a Prescaler, Capture/compare registers, and Output controls. The counter is connected to the ARR and the Mux trigger. The Mux trigger is connected to the Encoder, which is connected to the Edge detectors. The Edge detectors are connected to the Glitch filters. The Glitch filters are connected to the external pins: LPTIM_IN2, LPTIM_IN1, and LPTIM_ETR. The counter is also connected to the Capture/compare registers, which are connected to the Output controls. The Output controls are connected to the external pins: LPTIM_CH1 and LPTIM_CH2. The Prescaler is connected to the counter and the CLKPSC register. The CLKPSC register is connected to the external pin: LPTIM_KER_CK. The LPTIM register interface is connected to the external pins: LPTIM_PCLK, LPTIM_IT, and LPTIM_WAKEUP. The IRQ interface is connected to the external pins: LPTIM_IC1_DMA, LPTIM_IC2_DMA, and LPTIM_UE_DMA. The diagram also shows various internal signals and multiplexers for input and output selection.
Figure 276. LPTIM2 block diagram. The diagram shows the internal architecture of the LPTIM2 block. It is divided into two main clock domains: the APB clock domain and the Kernel clock domain. In the APB clock domain, there is an LPTIM register interface connected to a 32-bit APB bus, an IRQ interface, and a synchronization block. The Kernel clock domain contains a 16-bit counter, a 16-bit ARR (Auto-Reload Register), a Mux trigger, an Encoder, Edge detectors, Glitch filters, a Prescaler, Capture/compare registers, and Output controls. The counter is connected to the ARR and the Mux trigger. The Mux trigger is connected to the Encoder, which is connected to the Edge detectors. The Edge detectors are connected to the Glitch filters. The Glitch filters are connected to the external pins: LPTIM_IN2, LPTIM_IN1, and LPTIM_ETR. The counter is also connected to the Capture/compare registers, which are connected to the Output controls. The Output controls are connected to the external pins: LPTIM_CH1 and LPTIM_CH2. The Prescaler is connected to the counter and the CLKPSC register. The CLKPSC register is connected to the external pin: LPTIM_KER_CK. The LPTIM register interface is connected to the external pins: LPTIM_PCLK, LPTIM_IT, and LPTIM_WAKEUP. The IRQ interface is connected to the external pins: LPTIM_IC1_DMA, LPTIM_IC2_DMA, and LPTIM_UE_DMA. The diagram also shows various internal signals and multiplexers for input and output selection.

MSV50909V5

  1. Some I/Os may not be available, refer to Section 27.4.2: LPTIM pins and internal signals .

Figure 277. LPTIM1/3 block diagram (1)

Detailed block diagram of LPTIM1/3 showing internal components like the 16-bit counter, capture/compare registers, and various input/output pins (LPTIM_IN1, LPTIM_IN2, LPTIM_ETR, LPTIM_CH1-4).

The diagram illustrates the internal architecture of the LPTIM1/3. It is divided into two main clock domains: the APB clock domain and the Kernel clock domain.
In the APB clock domain, a 32-bit APB bus connects to an LPTIM register interface and an IRQ interface. Pins include lptim_pclk, lptim_it, and lptim_wakeup.
The Kernel clock domain contains a 16-bit counter, four capture/compare registers (labeled Capture/compare1 register through Capture/compare4 register), a Mux trigger, a 16-bit ARR, and a Repetition counter.
Inputs include LPTIM_IN1, LPTIM_IN2, and LPTIM_ETR, each passing through glitch filters and edge detectors.
Outputs include LPTIM_CH1, LPTIM_CH2, LPTIM_CH3, and LPTIM_CH4, generated by output controls connected to the capture/compare registers.
DMA signals (lptim_ic1_dma, lptim_ic2_dma, lptim_ic3_dma, lptim_ic4_dma, lptim_ue_dma) are also shown.
The diagram is labeled MSV74193V1 at the bottom right.

Detailed block diagram of LPTIM1/3 showing internal components like the 16-bit counter, capture/compare registers, and various input/output pins (LPTIM_IN1, LPTIM_IN2, LPTIM_ETR, LPTIM_CH1-4).

1. Some I/Os may not be available, refer to Section 27.4.2: LPTIM pins and internal signals .

27.4.2 LPTIM pins and internal signals

The following tables provide the list of LPTIM pins and internal signals, respectively.

Table 146. LPTIM1/2/3 input/output pins

Pin namePin typeDescription
LPTIM_IN1Digital inputLPTIM Input 1 from GPIO pin on mux input 0
LPTIM_IN2Digital inputLPTIM Input 2 from GPIO pin on mux input 0
LPTIM_ETRDigital inputLPTIM external trigger GPIO pin
LPTIM_CH1Digital input/outputLPTIM channel 1 input/output GPIO pin
LPTIM_CH2Digital input/outputLPTIM channel 2 input/output GPIO pin
Table 146. LPTIM1/2/3 input/output pins (continued)
Pin namePin typeDescription
LPTIM_CH3Digital input/outputLPTIM channel 3 input/output GPIO pin
LPTIM_CH4Digital input/outputLPTIM channel 4 input/output GPIO pin
Table 147. LPTIM1/2/3 internal signals
Signal nameSignal typeDescription
lptim_pclkDigital inputLPTIM APB clock domain
lptim_ker_ckDigital inputLPTIM kernel clock
lptim_in1_mux1Digital inputInternal LPTIM input 1 connected to mux input 1
lptim_in1_mux2Digital inputInternal LPTIM input 1 connected to mux input 2
lptim_in1_mux3Digital inputInternal LPTIM input 1 connected to mux input 3
lptim_in2_mux1Digital inputInternal LPTIM input 2 connected to mux input 1
lptim_in2_mux2Digital inputInternal LPTIM input 2 connected to mux input 2
lptim_in2_mux3Digital inputInternal LPTIM input 2 connected to mux input 3
lptim_ic1_mux1Digital inputInternal LPTIM input capture 1 connected to mux input 1
lptim_ic1_mux2Digital inputInternal LPTIM input capture 1 connected to mux input 2
lptim_ic1_mux3Digital inputInternal LPTIM input capture 1 connected to mux input 3
lptim_ic2_mux1Digital inputInternal LPTIM input capture 2 connected to mux input 1
lptim_ic2_mux2Digital inputInternal LPTIM input capture 2 connected to mux input 2
lptim_ic2_mux3Digital inputInternal LPTIM input capture 2 connected to mux input 3
lptim_ic3_mux1Digital inputInternal LPTIM input capture 3 connected to mux input 1
lptim_ic3_mux2Digital inputInternal LPTIM input capture 3 connected to mux input 2
lptim_ic3_mux3Digital inputInternal LPTIM input capture 3 connected to mux input 3
lptim_ic4_mux1Digital inputInternal LPTIM input capture 4 connected to mux input 1
lptim_ic4_mux2Digital inputInternal LPTIM input capture 4 connected to mux input 2
lptim_ic4_mux3Digital inputInternal LPTIM input capture 4 connected to mux input 3
lptim_ext_trigxDigital inputLPTIM external trigger input x
lptim_itDigital outputLPTIM global interrupt
lptim_wakeupDigital outputLPTIM wake-up event
lptim_ic1_dmaDigital outputLPTIM input capture 1 DMA request
lptim_ic2_dmaDigital outputLPTIM input capture 2 DMA request
lptim_ic3_dmaDigital outputLPTIM input capture 3 DMA request
lptim_ic4_dmaDigital outputLPTIM input capture 4 DMA request
lptim_ue_dmaDigital outputLPTIM update event DMA request

27.4.3 LPTIM input and trigger mapping

The LPTIM external trigger and input connections are detailed hereafter.

Table 148. LPTIM1/2/3 external trigger connections

TRIGSELExternal trigger
LPTIM1LPTIM2LPTIM3
lptim_ext_trig0GPIO
lptim_ext_trig1rtc_alra_trg
lptim_ext_trig2rtc_alrb_trg
lptim_ext_trig3tamp_trg1
lptim_ext_trig4tamp_trg2
lptim_ext_trig5Reservedtamp_trg3Reserved
lptim_ext_trig6COMP1_OUT
lptim_ext_trig7COMP2_OUT

Table 149. LPTIM1/2/3 input 1 connections

lptim_in1_muxLPTIM1 input 1 connected toLPTIM2 input 1 connected toLPTIM3 input 1 connected to
lptim_in1_mux0GPIO
lptim_in1_mux1COMP1_OUT
lptim_in1_mux2ReservedCOMP2_OUTReserved
lptim_in1_mux3ReservedCOMP1_OUT or COMP2_OUTReserved

Table 150. LPTIM1/2/3 input 2 connections

lptim_in2_muxLPTIM1 input 2 connected toLPTIM2 input 2 connected toLPTIM3 input 2 connected to
lptim_in2_mux0GPIOReservedGPIO
lptim_in2_mux1COMP2_OUTReservedCOMP2_OUT
lptim_in2_mux2ReservedReservedReserved
lptim_in2_mux3ReservedReservedReserved

Table 151. LPTIM1/2/3 input capture 1 connections

lptim_ic1_muxLPTIM1 input capture 1 connected toLPTIM2 input capture 1 connected toLPTIM3 input capture 1 connected to
lptim_ic1_mux0GPIOGPIOGPIO
lptim_ic1_mux1COMP1_OUTCOMP1_OUTCOMP1_OUT
Table 151. LPTIM1/2/3 input capture 1 connections (continued)
lptim_ic1_muxLPTIM1 input capture 1 connected toLPTIM2 input capture 1 connected toLPTIM3 input capture 1 connected to
lptim_ic1_mux2COMP2_OUTCOMP2_OUTCOMP2_OUT
lptim_ic1_mux3ReservedReservedReserved
Table 152. LPTIM1/2/3 input capture 2 connections
lptim_ic2_muxLPTIM1/2/3 input capture 2 connected to
lptim_ic2_mux0GPIO
lptim_ic2_mux1MCO1
lptim_ic2_mux2MCO2
lptim_ic2_mux3Reserved
Table 153. LPTIM1/3 input capture 2 connections
lptim_ic3_muxLPTIM1/3 input capture 2 connected to
lptim_ic3_mux0GPIO
lptim_ic3_mux1COMP1_OUT
lptim_ic3_mux2COMP2_OUT
lptim_ic3_mux3Reserved
Table 154. LPTIM1/2/3 input capture 2 connections
lptim_ic4_muxLPTIM1/2/3 input capture 2 connected to
lptim_ic4_mux0GPIO
lptim_ic4_mux1COMP1_OUT
lptim_ic4_mux2COMP2_OUT
lptim_ic4_mux3Reserved

27.4.4 LPTIM reset and clocks

The LPTIM can be clocked using several clock sources. It can be clocked using an internal clock signal which can be any configurable internal clock source selectable through the RCC (see RCC section for more details). Also, the LPTIM can be clocked using an external clock signal injected on its external Input1. When clocked with an external clock source, the LPTIM can run in one of the following configurations:

Programming the CKSEL and COUNTMODE bits allows controlling whether the LPTIM uses an external clock source or an internal one.

When configured to use an external clock source, the CKPOL bits are used to select the external clock signal active edge. If both edges are configured to be active ones, an internal clock signal must also be provided (first configuration). In this case, the internal clock signal frequency must be at least four times higher than the external clock signal frequency.

27.4.5 Glitch filter

The LPTIM inputs, either external (mapped to GPIOs) or internal (mapped on the chip-level to other embedded peripherals), are protected with digital filters that prevent any glitches and noise perturbations to propagate inside the LPTIM. This is in order to prevent spurious counts or triggers.

Before activating the digital filters, an internal clock source must first be provided to the LPTIM. This is necessary to guarantee the proper operation of the filters.

The digital filters are divided into three groups:

Note: The digital filters sensitivity is controlled by groups. It is not possible to configure each digital filter sensitivity separately inside the same group.

The filter sensitivity acts on the number of consecutive equal samples that is detected on one of the LPTIM inputs to consider a signal level change as a valid transition. Figure 278 shows an example of glitch filter behavior in case of a two consecutive samples programmed.

Figure 278. Glitch filter timing diagram

Figure 278. Glitch filter timing diagram. The diagram shows three waveforms: CLKMUX (a periodic square wave), Input (a signal with a glitch), and Filter out (the filtered signal). The Input signal has a short pulse that is filtered out. The Filter out signal is shown as a series of pulses. The diagram is labeled with '2 consecutive samples' and 'Filtered'.

The timing diagram illustrates the operation of a glitch filter. The top waveform, labeled 'CLKMUX', is a periodic square wave representing the clock signal. The middle waveform, labeled 'Input', shows a signal that transitions from a low level to a high level, then back to low, and then back to high again. A short high-level pulse (the glitch) is visible. The bottom waveform, labeled 'Filter out', shows the output of the filter. It remains at the low level during the glitch and only transitions to the high level after the glitch has persisted for a certain duration. Vertical dashed lines mark specific clock cycles. Brackets below the Input and Filter out signals indicate '2 consecutive samples' where the filter's decision is made. An arrow points to the rising edge of the Filter out signal, labeled 'Filtered'. The diagram is identified by the code 'MS32490V1' in the bottom right corner.

Figure 278. Glitch filter timing diagram. The diagram shows three waveforms: CLKMUX (a periodic square wave), Input (a signal with a glitch), and Filter out (the filtered signal). The Input signal has a short pulse that is filtered out. The Filter out signal is shown as a series of pulses. The diagram is labeled with '2 consecutive samples' and 'Filtered'.

Note: In case no internal clock signal is provided, the digital filter must be deactivated by setting the CKFLT, ICxF and TRGFLT bits to 0. In this case, an external analog filter can be used to protect the LPTIM external inputs against glitches.

27.4.6 Prescaler

The LPTIM 16-bit counter is preceded by a configurable power-of-2 prescaler. The prescaler division ratio is controlled by the PRESC[2:0] field. The table below lists all the possible division ratios:

Table 155. Prescaler division ratios

ProgrammingDividing factor
000/1
001/2
010/4
011/8
100/16
101/32
110/64
111/128

27.4.7 Trigger multiplexer

The LPTIM counter can be started either by software or after the detection of an active edge on one of the eight trigger inputs.

TRIGEN[1:0] is used to determine the LPTIM trigger source:

The external triggers are considered asynchronous signals for the LPTIM. After a trigger detection, a two-counter-clock period latency is needed before the timer starts running due to the synchronization.

If a new trigger event occurs when the timer is already started it is ignored (unless timeout function is enabled).

Note: The timer must be enabled before setting the SNGSTRT/CNTSTRT bits. Any write on these bits when the timer is disabled is discarded by hardware.

Note: When starting the counter by software (TRIGEN[1:0] = 00), there is a delay of 3 kernel clock cycles between the LPTIM_CR register update (set one of SNGSTRT or CNTSTRT bits) and the effective start of the counter.

27.4.8 Operating mode

The LPTIM features two operating modes:

One-shot mode

To enable the one-shot counting, the SNGSTRT bit must be set.

A new trigger event re-starts the timer. Any trigger event occurring after the counter starts and before the next LPTIM update event, is discarded.

In case an external trigger is selected, each external trigger event arriving after the SNGSTRT bit is set, and after the repetition counter has stopped (after the update event), and if the repetition register content is different from zero, the repetition counter gets reloaded with the value already contained by the repetition register and a new one-shot counting cycle is started as shown in Figure 279 .

Figure 279. LPTIM output waveform, single-counting mode configuration when repetition register content is different than zero (with PRELOAD = 1)

Timing diagram for LPTIM output waveform in single-counting mode. The diagram shows four horizontal signal lines: LPTIM_RCR (constant at 2), Repetition counter (counts 2, 1, 0, then reloads to 2), LPTIM_ARR Compare (sawtooth waveform), and PWM (output pulses). External trigger events are shown as yellow lightning bolts; ignored triggers are pink. The first trigger starts the first ramp. A second trigger during the first ramp is ignored. After the repetition counter reaches 0 and an update event occurs, a subsequent trigger reloads the counter and starts a new cycle.

The figure is a timing diagram illustrating the LPTIM output waveform in single-counting mode. It consists of four horizontal lines representing different signals over time:

Trigger events:

MSv47414V1

Timing diagram for LPTIM output waveform in single-counting mode. The diagram shows four horizontal signal lines: LPTIM_RCR (constant at 2), Repetition counter (counts 2, 1, 0, then reloads to 2), LPTIM_ARR Compare (sawtooth waveform), and PWM (output pulses). External trigger events are shown as yellow lightning bolts; ignored triggers are pink. The first trigger starts the first ramp. A second trigger during the first ramp is ignored. After the repetition counter reaches 0 and an update event occurs, a subsequent trigger reloads the counter and starts a new cycle.

- Set-once mode activated:

Note that when the WAVE bitfield in the LPTIM_CFGR register is set, the Set-once mode is activated. In this case, the counter is only started once following the first trigger, and any subsequent trigger event is discarded as shown in Figure 280.

Figure 280. LPTIM output waveform, single-counting mode configuration and Set-once mode activated (WAVE bit is set)

Figure 280: LPTIM output waveform in single-counting mode. The top graph shows the counter value (LPTIM_ARR) increasing linearly from 0 to a Compare value, then resetting to 0. The bottom graph shows the PWM output, which is high when the counter is below the Compare value and low otherwise. An external trigger event (lightning bolt) occurs after the counter has already reached the Compare value and is labeled 'Discarded trigger'. A legend indicates that a lightning bolt represents an 'External trigger event'. The reference MSv39231V2 is shown in the bottom right corner.
Figure 280: LPTIM output waveform in single-counting mode. The top graph shows the counter value (LPTIM_ARR) increasing linearly from 0 to a Compare value, then resetting to 0. The bottom graph shows the PWM output, which is high when the counter is below the Compare value and low otherwise. An external trigger event (lightning bolt) occurs after the counter has already reached the Compare value and is labeled 'Discarded trigger'. A legend indicates that a lightning bolt represents an 'External trigger event'. The reference MSv39231V2 is shown in the bottom right corner.

In case of software start (TRIGEN[1:0] = 00), the SNGSTRT setting starts the counter for one-shot counting.

Continuous mode

To enable the continuous counting, the CNTSTRT bit must be set.

In case an external trigger is selected, an external trigger event arriving after CNTSTRT is set, starts the counter for continuous counting. Any subsequent external trigger event is discarded as shown in Figure 281 .

In case of software start (TRIGEN[1:0] = 00), setting CNTSTRT starts the counter for continuous counting.

Figure 281. LPTIM output waveform, Continuous counting mode configuration

Figure 281: LPTIM output waveform in continuous counting mode. The top graph shows the counter value (LPTIM_ARR) cycling continuously between 0 and a Compare value. The bottom graph shows the PWM output, which toggles between high and low states as the counter cycles. Multiple external trigger events (lightning bolts) are shown, with the first one starting the counter and subsequent ones occurring while the counter is still running, labeled as 'Discarded triggers'. A legend indicates that a lightning bolt represents an 'External trigger event'. The reference MSv39229V2 is shown in the bottom right corner.
Figure 281: LPTIM output waveform in continuous counting mode. The top graph shows the counter value (LPTIM_ARR) cycling continuously between 0 and a Compare value. The bottom graph shows the PWM output, which toggles between high and low states as the counter cycles. Multiple external trigger events (lightning bolts) are shown, with the first one starting the counter and subsequent ones occurring while the counter is still running, labeled as 'Discarded triggers'. A legend indicates that a lightning bolt represents an 'External trigger event'. The reference MSv39229V2 is shown in the bottom right corner.

SNGSTRT and CNTSTRT bits can only be set when the timer is enabled (ENABLE bit set to 1). It is possible to change “on the fly” from One-shot mode to Continuous mode.

If the Continuous mode was previously selected, setting SNGSTRT switches the LPTIM to the One-shot mode. The counter (if active) stops as soon as an LPTIM update event is generated.

If the One-shot mode was previously selected, setting CNTSTRT switches the LPTIM to the Continuous mode. The counter (if active) restarts as soon as it reaches ARR.

27.4.9 Timeout function

The detection of an active edge on one selected trigger input can be used to reset the LPTIM counter. This feature is controlled through the TIMEOUT bit.

The first trigger event starts the timer, any successive trigger event resets the LPTIM counter and the repetition counter and the timer restarts.

A low-power timeout function can be realized. The timeout value corresponds to the compare value; if no trigger occurs within the expected time frame, the MCU is waked-up by the compare match event.

27.4.10 Waveform generation

Two 16-bit registers, the LPTIM_ARR (autoreload register) and LPTIM_CCRx (capture/compare register), are used to generate several different waveforms on LPTIM output

The timer can generate the following waveforms:

The above described modes require the LPTIM_ARR register value to be strictly greater than the LPTIM_CCRx register value.

The LPTIM output waveform can be configured through the WAVE bit as follow:

The CCxP bit controls the LPTIM output polarity. The change takes effect immediately, so the output default value changes immediately after the polarity is re-configured, even before the timer is enabled.

Signals with frequencies up to the LPTIM clock frequency divided by two can be generated. Figure 282 below shows the three possible waveforms that can be generated on the LPTIM output. Also, it shows the effect of the polarity change using the CCxP bit.

Figure 282. Waveform generation

Timing diagram showing waveform generation for LPTIM. The top signal is LPTIM_ARR Compare, showing a sawtooth wave. Below it, the PWM signal is shown for two polarities: Pol = 0 and Pol = 1. For Pol = 0, the PWM signal is high when the counter is below the compare value. For Pol = 1, the PWM signal is low when the counter is below the compare value. The 'One shot' and 'Set once' signals are also shown for both polarities. The diagram is labeled MS32467V2.

The figure is a timing diagram illustrating waveform generation using an LPTIM. The top signal, labeled 'LPTIM_ARR Compare', shows a sawtooth waveform representing the counter value. Below this, the PWM signal is shown for two polarities: Pol = 0 and Pol = 1 . For Pol = 0 , the PWM signal is high when the counter is below the compare value and low otherwise. For Pol = 1 , the PWM signal is low when the counter is below the compare value and high otherwise. The 'One shot' and 'Set once' signals are also shown for both polarities, indicating their respective states during the PWM generation. The diagram is labeled MS32467V2.

Timing diagram showing waveform generation for LPTIM. The top signal is LPTIM_ARR Compare, showing a sawtooth wave. Below it, the PWM signal is shown for two polarities: Pol = 0 and Pol = 1. For Pol = 0, the PWM signal is high when the counter is below the compare value. For Pol = 1, the PWM signal is low when the counter is below the compare value. The 'One shot' and 'Set once' signals are also shown for both polarities. The diagram is labeled MS32467V2.

27.4.11 Register update

The LPTIM_ARR register, the LPTIM_RCR register and the LPTIM_CCRx register are updated immediately after the APB bus write operation or in synchronization with the next LPTIM update event if the timer is already started.

The PRELOAD bit controls how the LPTIM_ARR, the LPTIM_RCR and the LPTIM_CCRx registers are updated:

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.

The ARROK flag, the REPOK flag and the CMPxOK flag in the LPTIM_ISR register indicate when the write operation is completed to respectively the LPTIM_ARR register, the LPTIM_RCR register and the LPTIM_CCRx register.

After a write to the LPTIM_ARR, the LPTIM_RCR or the LPTIM_CCRx register, a new write operation to the same register can only be performed when the previous write operation is completed. Any successive write before respectively the ARROK flag, the REPOK flag or the CMPxOK flag be set, leads to unpredictable results.

27.4.12 Counter mode

The LPTIM counter can be used to count external events on the LPTIM input1 or it can be used to count internal clock cycles. The CKSEL and COUNTMODE bits control which source is used for updating the counter.

In case the LPTIM is configured to count external events on Input1, the counter can be updated following a rising edge, falling edge or both edges depending on the value written to the CKPOL[1:0] bits.

The count modes below can be selected, depending on CKSEL and COUNTMODE values:

27.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 cycles is needed before the LPTIM is actually enabled.

The LPTIM_CFGR register must be modified only when the LPTIM is disabled.

27.4.14 Timer counter reset

In order to reset the content of LPTIM_CNT register, two reset mechanisms are implemented:

Note: The software should ensure that COUNRST bit is '0' before generating every synchronous reset.

To read reliably the content of the LPTIM_CNT register two successive read accesses must be performed and compared. A read access can be considered reliable when the value of the two read accesses is equal. Unfortunately when asynchronous reset is enabled there is no possibility to read twice the LPTIM_CNT register.


Warning: There is no mechanism inside the LPTIM that prevents the two reset mechanisms from being used simultaneously. The developer must make sure that these two mechanisms are used exclusively.


27.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). Therefore LPTIM_ARR must be configured before starting the counter. From the two external input signals, Input1 and Input2, a clock signal is generated to clock the LPTIM counter. The phase between those two signals determines the counting direction.

The Encoder mode is only available when the LPTIM is clocked by an internal clock source. The signals frequency on both Input1 and Input2 inputs must not exceed the LPTIM internal clock frequency divided by 4. This is mandatory in order to guarantee a proper operation of the LPTIM.

Direction change is signaled by the two down and up flags in the LPTIM_ISR register. An interrupt can be generated for both direction change events if enabled through the DOWNIE bit.

To activate the Encoder mode the ENC bit has to be set to 1. The LPTIM must first be configured in Continuous mode.

When Encoder mode is active, the LPTIM counter is modified automatically following the speed and the direction of the incremental encoder. Therefore, its content always represents the encoder's position. The count direction, signaled by the Up and Down flags, correspond to the rotation direction of the encoder rotor.

According to the edge sensitivity configured using the CKPOL[1:0] bits, different counting scenarios are possible. The following table summarizes the possible combinations, assuming that Input1 and Input2 do not switch at the same time.

Table 156. Encoder counting scenarios

Active edgeLevel on opposite signal (Input1 for Input2, Input2 for Input1)Input1 signalInput2 signal
RisingFallingRisingFalling
Rising EdgeHighDownNo countUpNo count
LowUpNo countDownNo count
Falling EdgeHighNo countUpNo countDown
LowNo countDownNo countUp
Both EdgesHighDownUpUpDown
LowUpDownDownUp

The following figure shows a counting sequence for Encoder mode where both-edge sensitivity is configured.

Caution: In this mode the LPTIM must be clocked by an internal clock source, so the CKSEL bit must be maintained to its reset value which is equal to 0. Also, the prescaler division ratio must be equal to its reset value which is 1 (PRESC[2:0] bits must be 000).

Figure 283. Encoder mode counting sequence

Timing diagram showing encoder mode counting sequence. It displays three waveforms: T1, T2, and Counter. T1 and T2 are square waves. The Counter is a staircase waveform that increments (up) when T1 is high and T2 has a rising edge, and decrements (down) when T1 is high and T2 has a falling edge. The sequence is divided into three segments labeled 'up', 'down', and 'up'. The diagram is labeled MS32491V1.

The figure shows a timing diagram for encoder mode counting. At the top, a high-frequency square wave is shown. Below it are two input signals, T1 and T2. The Counter waveform below them shows the counting sequence. The sequence is divided into three segments: 'up', 'down', and 'up'. In the 'up' segments, the counter increments by 1 for each rising edge of T2 while T1 is high. In the 'down' segment, the counter decrements by 1 for each falling edge of T2 while T1 is high. The diagram is labeled MS32491V1.

Timing diagram showing encoder mode counting sequence. It displays three waveforms: T1, T2, and Counter. T1 and T2 are square waves. The Counter is a staircase waveform that increments (up) when T1 is high and T2 has a rising edge, and decrements (down) when T1 is high and T2 has a falling edge. The sequence is divided into three segments labeled 'up', 'down', and 'up'. The diagram is labeled MS32491V1.

27.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. Next to each repetition counter underflow event, the repetition counter gets loaded with the content of the REP[7:0] bitfield which belongs to the repetition register LPTIM_RCR.

A repetition underflow event is generated on each and every LPTIM counter overflow when the REP[7:0] register is set to 0.

When PRELOAD = 1, writing to the REP[7:0] bitfield has no effect on the content of the repetition counter until the next repetition underflow event occurs. The repetition counter continues to decrement each LPTIM counter overflow event and only when a repetition underflow event is generated, the new value written into REP[7:0] is loaded into the repetition counter. This behavior is depicted in Figure 284 .

Figure 284. Continuous counting mode when repetition register LPTIM_RCR different from zero (with PRELOAD = 1)

Timing diagram for continuous counting mode with PRELOAD = 1. The diagram shows four signals over time: LPTIM_RCR, Repetition counter, LPTIM_ARR Compare, and PWM. A vertical pink line marks a 'Repetition counter underflow event'. At this event, the Repetition counter reaches 0, and the LPTIM_RCR register is updated from 4 to 9. The LPTIM_ARR Compare signal is a sawtooth wave that resets to 0 at each underflow. The PWM signal is a square wave that toggles when the LPTIM_ARR Compare signal reaches a certain threshold. The text 'Preloaded registers updated' points to the update of LPTIM_RCR.
Timing diagram for continuous counting mode with PRELOAD = 1. The diagram shows four signals over time: LPTIM_RCR, Repetition counter, LPTIM_ARR Compare, and PWM. A vertical pink line marks a 'Repetition counter underflow event'. At this event, the Repetition counter reaches 0, and the LPTIM_RCR register is updated from 4 to 9. The LPTIM_ARR Compare signal is a sawtooth wave that resets to 0 at each underflow. The PWM signal is a square wave that toggles when the LPTIM_ARR Compare signal reaches a certain threshold. The text 'Preloaded registers updated' points to the update of LPTIM_RCR.

A repetition counter underflow event is systematically associated with LPTIM preloaded registers update (refer to Section 27.4.11: Register update for more information).

Repetition counter underflow event is signaled to the software through the update event (UE) flag mapped into the LPTIM_ISR register. When set, the UE flag can trigger an LPTIM interrupt if its respective update event interrupt enable (UEIE) control bit, mapped to the LPTIM_DIER register, is set.

The repetition register LPTIM_RCR is located in the APB bus interface clock domain where the repetition counter itself is located in the LPTIM kernel clock domain. Each time a new value is written to the LPTIM_RCR register, this new content is propagated from the APB bus interface clock domain to the LPTIM kernel clock domain. The new written value is then loaded to the repetition counter immediately after a repetition counter underflow event. The synchronization delay for the new written content is four APB clock cycles plus three LPTIM kernel clock cycles and it is signaled by the REPOK flag located in the LPTIM_ISR register when it is elapsed. When the LPTIM kernel clock cycle is relatively slow, for instance when the LPTIM kernel is being clocked by the LSI clock source, it can be lengthy to keep polling on the REPOK flag by software to detect that the synchronization of the LPTIM_RCR register content is finished. For that reason, the REPOK flag, when set, can generate an interrupt if its associated REPOKIE control bit in the LPTIM_DIER register is set.

Note: After a write to the LPTIM_RCR register, a new write operation to the same register can only be performed when the previous write operation is completed. Any successive writes before the REPOK flag is set, lead to unpredictable results.

Caution: When using repetition counter with PRELOAD = 0, LPTIM_RCR register must be changed at least five counter cycles before the autoreload match event, otherwise an unpredictable behavior may occur.

27.4.17 Capture/compare channels

Each capture/compare channel is built around a capture/compare register, an input stage for capture (with digital filter, multiplexing and prescaler) and an output stage (with comparator and output control) for PWM.

Input stage

The input stage samples the corresponding LPTIx input to generate a filtered signal LPTIxF. Then, an edge detector with polarity selection generates ICx signal used as the capture command. It is prescaled to generate the capture command signal (ICxPS).

Figure 285. Capture/compare input stage (channel 1)

Figure 285: Capture/compare input stage (channel 1) block diagram. The diagram shows the signal flow from LPTI1 input through a Glitch filter (controlled by IC1F[3:0] in LPTIM_CCMR1) to produce LPTI1F. This signal then passes through an Edge detector (controlled by CC1P[1:0] in LPTIM_CCMR1) to produce IC1. Finally, IC1 is divided by a Divider (/1, /2, /4, /8) controlled by IC1PSC[1:0] and CC1E in LPTIM_CCMR1 to produce the output IC1PS. Reference MSV50905V1 is shown at the bottom right.
Figure 285: Capture/compare input stage (channel 1) block diagram. The diagram shows the signal flow from LPTI1 input through a Glitch filter (controlled by IC1F[3:0] in LPTIM_CCMR1) to produce LPTI1F. This signal then passes through an Edge detector (controlled by CC1P[1:0] in LPTIM_CCMR1) to produce IC1. Finally, IC1 is divided by a Divider (/1, /2, /4, /8) controlled by IC1PSC[1:0] and CC1E in LPTIM_CCMR1 to produce the output IC1PS. Reference MSV50905V1 is shown at the bottom right.

Output stage

The output stage generates an intermediate waveform which is then used for reference: OCxREF (active high). The polarity acts at the end of the chain.

Figure 286. Capture/compare output stage (channel 1)

Figure 286: Capture/compare output stage (channel 1) block diagram. The diagram shows the signal flow from CNT > CCRx to an Output mode controller, which produces OC1REF. This signal then passes through a polarity selection stage (controlled by CC1P in LPTIM_CCMR1) and an Output enable circuit (controlled by CC1E in LPTIM_CCMR1) to produce the final output OC1. Reference MSV50906V2 is shown at the bottom right.
Figure 286: Capture/compare output stage (channel 1) block diagram. The diagram shows the signal flow from CNT > CCRx to an Output mode controller, which produces OC1REF. This signal then passes through a polarity selection stage (controlled by CC1P in LPTIM_CCMR1) and an Output enable circuit (controlled by CC1E in LPTIM_CCMR1) to produce the final output OC1. Reference MSV50906V2 is shown at the bottom right.

27.4.18 Input capture mode

In Input capture mode, the capture/compare registers (LPTIM_CCRx) are used to latch the value of the counter after a transition detected by the corresponding ICx signal. Assuming input capture is enabled on a channel x (CCxE set) and when a capture occurs, the corresponding CCxIF flag (LPTIM_ISR register) is set and an interrupt or a DMA request can be sent if they are enabled. If a capture occurs while the CCxIF flag was already high, then the over-capture flag CCxOF (LPTIM_ISR register) is set. CCxIF can be cleared by software by writing the CCxICF to 1 or by reading the captured data stored in the LPTIM_CCRx register. CCxOF is cleared by writing CCxOCF to 1.

Note: In DMA mode, the input capture channel have to be enabled (set CCxE bit) the last, after enabling the DMA request and after starting the counter. This is in order to prevent generating an input capture DMA request when the counter is not started yet.

Input capture Glitch filter latency

When a trigger event arrives on channel x input (LPTIx) and depending on the configured glitch filter (ICxF[1:0] field in CCMRx register) and on the kernel clock prescaler value (PRESC[2:0] field in CFGR register), there is a variable latency that leads to a systematic offset (see Table 157 ) between the captured value stored in the CCRx register and the real value corresponding to the capture trigger.

This offset has no impact on pulse width measurement as it is systematic and compensated between two captures.

The real capture value corresponding to the input capture trigger can be calculated using the below formula:

Real capture value = captured(LPTIM_CCRx) - offset

The relevant offset must be used depending on the glitch filter and on the kernel clock prescaler value (PRESC field in CFGR register)

Example: determining the real capture value when PRESC[2:0] = 0x2 and ICxF = 0x3. For this configuration (PRESC[2:0] = 0x2 and ICxF = 0x3) and according to the Table 157 , the offset is 5.

Assuming that the captured value in CCRx is 9 (LPTIM_CNT = 9), this means that the capture trigger occurred when the LPTIM_CNT was equal to 9 - 5 = 4.

Table 157. Input capture Glitch filter latency (in counter step unit)

Prescaler PRESC[2:0]ICxF[1:0]Offset
002
17
29
313
103
15
26
38
202
13
24
35
302
12
23
33
402
12
22
32
502
12
22
32

Table 157. Input capture Glitch filter latency (in counter step unit) (continued)

Prescaler PRESC[2:0]ICxF[1:0]Offset
602
12
22
32
702
12
22
32

27.4.19 PWM mode

The PWM mode enables to generate a signal with a frequency determined by the value of the LPTIM_ARR register and a duty cycle determined by the value of the LPTIM_CCRx register. The LPTIM is able to generate PWM in edge-aligned mode.

OCx polarity is software programmable using the CCxP bit in the LPTIM_CCMRx register. It can be programmed as active high or active low. OCx output is enabled by the CCxE bit in the LPTIM_CCMRx register. Refer to the LPTIM_CCMRx register description for more details.

Figure 287 gives an example where the LPTIM channel 1 is configured in PWM mode with LPTIM_CCR1 = 6 then 1 and LPTIM_ARR=10.

Figure 287. Edge-aligned PWM mode (PRELOAD = 1)

Timing diagram for edge-aligned PWM mode. It shows four horizontal timelines: LPTIM_ARR (constant value 10), LPTIM_CCR1 (alternating values 6 and 1), LPTIM_CNT (counting from 5 to 10, then 0 to 2), and OC1REF = OC1 (PWM signal). The PWM signal is low from the start until the first 'Compare match' at LPTIM_CNT = 6. It then goes high and stays high until the 'Auto reload match' at LPTIM_CNT = 10. At that point, it goes low again and stays low until the next 'Compare match' at LPTIM_CNT = 1. The signal then goes high again. The diagram is labeled MSv50907V1.
Timing diagram for edge-aligned PWM mode. It shows four horizontal timelines: LPTIM_ARR (constant value 10), LPTIM_CCR1 (alternating values 6 and 1), LPTIM_CNT (counting from 5 to 10, then 0 to 2), and OC1REF = OC1 (PWM signal). The PWM signal is low from the start until the first 'Compare match' at LPTIM_CNT = 6. It then goes high and stays high until the 'Auto reload match' at LPTIM_CNT = 10. At that point, it goes low again and stays low until the next 'Compare match' at LPTIM_CNT = 1. The signal then goes high again. The diagram is labeled MSv50907V1.

In the following example the reference PWM signal OCxREF is low as long as LPTIM_CNT ≤ LPTIM_CCRx else it becomes high.

Figure 288 shows some edge-aligned PWM waveforms in an example where LPTIM_ARR = 8.

Figure 288. Edge-aligned PWM waveforms (ARR=8 and CCxP = 0)

Timing diagram showing edge-aligned PWM waveforms for three compare registers (CCRx=3, CCRx=6, CCRx=0) with ARR=8 and CCxP=0. The counter register (CNT) counts from 0 to 8, then overflows to 0. The OCxREF signal for CCRx=3 is high from counter value 3 to 8. The OCxREF signal for CCRx=6 is high from counter value 6 to 8. The OCxREF signal for CCRx=0 is high from counter value 0 to 8. The CCxIF flag is set when the counter value matches the compare value.

The figure shows the relationship between the LPTIM counter register (CNT) and the output reference signal (OCxREF) for three different compare values (CCRx=3, 6, and 0). The counter counts from 0 to 8, then overflows to 0. The OCxREF signal is high when the counter value is less than or equal to the compare value (CCRx) and low otherwise. The CCxIF flag is set when the counter value matches the compare value.

Counter register01234567801
OCxREF (CCRx=3)LowLowLowHighHighHighHighHighHighLowLow
CCxIF (CCRx=3)Set
OCxREF (CCRx=6)LowLowLowLowLowLowHighHighHighLowLow
CCxIF (CCRx=6)Set
OCxREF (CCRx=0)HighHighHighHighHighHighHighHighHighHighHigh
CCxIF (CCRx=0)SetSet
Timing diagram showing edge-aligned PWM waveforms for three compare registers (CCRx=3, CCRx=6, CCRx=0) with ARR=8 and CCxP=0. The counter register (CNT) counts from 0 to 8, then overflows to 0. The OCxREF signal for CCRx=3 is high from counter value 3 to 8. The OCxREF signal for CCRx=6 is high from counter value 6 to 8. The OCxREF signal for CCRx=0 is high from counter value 0 to 8. The CCxIF flag is set when the counter value matches the compare value.

PWM mode with immediate update PRELOAD = 0

The PWM mode with PRELOAD = 0 enables the early change of the output level within the current PWM cycle. Based on the immediate update (PRELOAD = 0) of the LPTIM_CCRx register and on the continuous comparison of LPTIM_CNT and LPTIM_CCRx registers, it permits to have a new duty cycle value applied as soon as possible within the current PWM cycle, without having to wait for the completion of the current PWM period.

When the (PRELOAD = 0), the OCxREF signal level can be changed on-the-fly by software (or DMA) by updating the compare value in the LPTIM_CCRx register.

Depending on the written compare value and on the current counter and compare values, the OCxREF level is re-assigned as illustrated below:

The output reference signal OCxREF level is left unchanged when none of the new compare value and the current compare value exceed the counter. Figure 289 illustrates the behavior of the OCxREF signal level when PRELOAD = 0 and PRELOAD = 1.

Figure 289. PWM mode with immediate update versus preloaded update

Timing diagram showing PWM mode with immediate update versus preloaded update. The diagram illustrates the relationship between the LPTIM counter (LPTIM_CNT), the compare register (LPTIM_CCRx), and the output signal (OCx) for two PWM modes: immediate update (PRELOAD = 0) and preloaded update (PRELOAD = 1).

The figure shows four waveforms over time. The top waveform is LPTIM_CNT , a sawtooth counter that increases linearly and resets to zero upon reaching the auto-reload value. The second waveform is LPTIM_CCRx , a dashed line representing the compare value. Three vertical arrows labeled Write to CCRx indicate updates to this register at different points in the counter's cycle. The third waveform, OCx for PWM mode with immediate update (PRELOAD = 0) , shows that the output level changes immediately in response to the new CCRx value. The bottom waveform, OCx for PWM mode with preloaded update (PRELOAD = 1) , shows that the output level only changes after the counter reaches the reload value, at which point the preloaded CCRx value is latched into the active compare register.

Timing diagram showing PWM mode with immediate update versus preloaded update. The diagram illustrates the relationship between the LPTIM counter (LPTIM_CNT), the compare register (LPTIM_CCRx), and the output signal (OCx) for two PWM modes: immediate update (PRELOAD = 0) and preloaded update (PRELOAD = 1).

Note: For both PWM modes, the compare match, auto-reload match, and the update event flags are set one LPTIM counter cycle later after the corresponding event, the OCxREF level is also changed one LPTIM counter cycle later after the corresponding event. For instance when the LPTIM_CCRx is set to 3 the CCxIF is set when the LPTIM_CNT = 4. Figure 287 illustrates this behavior.

27.4.20 DMA requests

The LPTIM can generate two categories of DMA requests:

Input capture DMA request

Each LPTIM channel has its dedicated input capture DMA request. A DMA request is generated (if CCxDE bit is set in LPTIM_DIER) and CCxIF is set each time a capture is ready in the LPTIM_CCRx register. The captured values in LPTIM_CCRx can then be transferred regularly by DMA to the desired memory destination. The CCxIF is automatically cleared by hardware when the captured value in LPTIM_CCRx register is read.

Note: The ICx DMA request signal lptim_icx_dma is reset in the following conditions:

Update event DMA request

A DMA request is generated (if UEDE is set in LPTIM_DIER) and the UE flag is set at each update event. DMA request can be used to regularly update the LPTIM_ARR, the LPTIM_RCR or the LPTIM_CCRx registers permitting to generate custom PWM waveforms.

The UE is automatically cleared by hardware upon any bus master (like CPU or DMA) write access to the LPTIM_ARR register.

Note: The UE DMA request signal lptim_ue_dma is reset in the following conditions:

27.4.21 Debug mode

When the microcontroller enters debug mode (core halted), the LPTIM counter either continues to work normally or stops, depending on the timer dedicated bit configuration in the debug support (DBG) peripheral.

For further details, refer to section debug support (DBG).

27.5 LPTIM low-power modes

Table 158. Effect of low-power modes on the LPTIM

ModeDescription
SleepNo effect. LPTIM interrupts cause the device to exit Sleep mode.
StopIf the LPTIM is clocked by an oscillator available in Stop mode, LPTIM is functional and the interrupts cause the device to exit the Stop mode.
StandbyThe LPTIM peripheral is powered down and must be reinitialized after exiting Standby mode.

Note: All DMA requests must be disabled (reset UEDE and CCxDE bits) before entering Sleep, Stop and Standby modes.

27.6 LPTIM interrupts

The following events generate an interrupt/wake-up event, if they are enabled through the LPTIM_DIER register:

Note: If any bit in the LPTIM_DIER register is set after that its corresponding flag in the LPTIM_ISR register (status register) is set, the interrupt is not asserted.

Table 159. Interrupt events

Interrupt vectorInterrupt eventEvent flagEnable control bitInterrupt clear methodExit from Sleep modeExit from Stop mode (1)
LPTIMxCompare matchCCxIFCCxIEWrite 1 to CCxCFYesYes
Input captureCCxIFCCxIEWrite 1 to CCxCFYesYes
Over-captureCCxOFCCxOEWrite 1 to CCxOCFYesYes
Auto-reload matchARRMARRMIEWrite 1 to ARRMCYesYes
External trigger eventEXTTRIGEXTTRIGIEWrite 1 to EXTTRIGCFYesYes
Auto-reload register update OKARROKARROKIEWrite 1 to ARROKCFYesYes
Capture/compare register update OKCMPxOKCMPxOKIEWrite 1 to CMPxOKCFYesYes
Direction change to up (2)UPUPIEWrite 1 to UPCFYesYes
Direction change to down (2)DOWNDOWNIEWrite 1 to DOWNCFYesYes
Update eventUEUEIEWrite 1 to UECFYesYes
Repetition register update OKREPOKREPOKIEWrite 1 to REPOKCFYesYes
  1. 1. Each LPTIM event can wake up the device from Stop mode only if the LPTIM instance supports the wake-up from Stop mode feature. Refer to Section 27.3: LPTIM implementation .
  2. 2. If LPTIM does not support encoder mode feature, this event does not exist. Refer to Section 27.3: LPTIM implementation .

27.7 LPTIM registers

Refer to Section 1.2: List of abbreviations for registers for a list of abbreviations used in register descriptions.

The peripheral registers can only be accessed by words (32-bit).

27.7.1 LPTIMx interrupt and status register [alternate] (LPTIMx_ISR) (x = 1 to 3)

This description of the register can only be used for output compare mode. See next section for input capture mode.

Address offset: 0x000

Reset value: 0x0000 0000

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.DIEROKRes.Res.CMP4OKCMP3OKCMP2OKRes.Res.Res.
rrrr
1514131211109876543210
Res.Res.Res.Res.CC4IFCC3IFCC2IFREP OKUEDOWNUPARR OKCMP1OKEXT TRIGARRMCC1IF
rrrrrrrrrrrr

Bits 31:25 Reserved, must be kept at reset value.

Bit 24 DIEROK : Interrupt enable register update OK

DIEROK is set by hardware to inform application that the APB bus write operation to the LPTIM_DIER register has been successfully completed. DIEROK flag can be cleared by writing 1 to the DIEROKCF bit in the LPTIM_ICR register.

Bits 23:22 Reserved, must be kept at reset value.

Bit 21 CMP4OK : Compare register 4 update OK

CMP4OK is set by hardware to inform application that the APB bus write operation to the LPTIM_CCR4 register has been successfully completed. CMP4OK flag can be cleared by writing 1 to the CMP4OKCF bit in the LPTIM_ICR register.

Note: If LPTIM does not implement at least 4 channels this bit is reserved. Refer to Section 27.3.

Bit 20 CMP3OK : Compare register 3 update OK

CMP3OK is set by hardware to inform application that the APB bus write operation to the LPTIM_CCR3 register has been successfully completed. CMP3OK flag can be cleared by writing 1 to the CMP3OKCF bit in the LPTIM_ICR register.

Note: If LPTIM does not implement at least 3 channels this bit is reserved. Refer to Section 27.3.

Bit 19 CMP2OK : Compare register 2 update OK

CMP2OK is set by hardware to inform application that the APB bus write operation to the LPTIM_CCR2 register has been successfully completed. CMP2OK flag can be cleared by writing 1 to the CMP2OKCF bit in the LPTIM_ICR register.

Note: If LPTIM does not implement at least 2 channels this bit is reserved. Refer to Section 27.3.

Bits 18:12 Reserved, must be kept at reset value.

Bit 11 CC4IF : Compare 4 interrupt flag

If channel CC4 is configured as output:

The CC4IF flag is set by hardware to inform application that LPTIM_CNT register value matches the compare register's value. CC4IF flag can be cleared by writing 1 to the CC4CF bit in the LPTIM_ICR register.

0:No match

1:The content of the counter LPTIM_CNT register value has matched the LPTIM_CCR4 register's value

Note: If LPTIM does not implement at least 4 channels this bit is reserved. Refer to Section 27.3.

Bit 10 CC3IF : Compare 3 interrupt flag

If channel CC3 is configured as output:

The CC3IF flag is set by hardware to inform application that LPTIM_CNT register value matches the compare register's value. CC3IF flag can be cleared by writing 1 to the CC3CF bit in the LPTIM_ICR register.

0:No match

1:The content of the counter LPTIM_CNT register value has matched the LPTIM_CCR3 register's value.

Note: If LPTIM does not implement at least 3 channels this bit is reserved. Refer to Section 27.3 .

Bit 9 CC2IF : Compare 2 interrupt flag

If channel CC2 is configured as output:

The CC2IF flag is set by hardware to inform application that LPTIM_CNT register value matches the compare register's value. CC2IF flag can be cleared by writing 1 to the CC2CF bit in the LPTIM_ICR register.

0: No match

1:The content of the counter LPTIM_CNT register value has matched the LPTIM_CCR2 register's value

Note: If LPTIM does not implement at least 2 channels this bit is reserved. Refer to Section 27.3 .

Bit 8 REPOK : Repetition register update OK

REPOK is set by hardware to inform application that the APB bus write operation to the LPTIM_RCR register has been successfully completed. REPOK flag can be cleared by writing 1 to the REPOKCF bit in the LPTIM_ICR register.

Bit 7 UE : LPTIM update event occurred

UE is set by hardware to inform application that an update event was generated. The corresponding interrupt or DMA request is generated if enabled. UE flag can be cleared by writing 1 to the UECF bit in the LPTIM_ICR register. The UE flag is automatically cleared by hardware once the LPTIM_ARR register is written by any bus master like CPU or DMA.

Bit 6 DOWN : Counter direction change up to down

In Encoder mode, DOWN bit is set by hardware to inform application that the counter direction has changed from up to down. DOWN flag can be cleared by writing 1 to the DOWNCF bit in the LPTIM_ICR register.

Note: If the LPTIM does not support encoder mode feature, this bit is reserved. Refer to Section 27.3 .

Bit 5 UP : Counter direction change down to up

In Encoder mode, UP bit is set by hardware to inform application that the counter direction has changed from down to up. UP flag can be cleared by writing 1 to the UPCF bit in the LPTIM_ICR register.

Note: If the LPTIM does not support encoder mode feature, this bit is reserved. Refer to Section 27.3 .

Bit 4 ARROK : Autoreload register update OK

ARROK is set by hardware to inform application that the APB bus write operation to the LPTIM_ARR register has been successfully completed. ARROK flag can be cleared by writing 1 to the ARROKCF bit in the LPTIM_ICR register.

Bit 3 CMP1OK : Compare register 1 update OK

CMP1OK is set by hardware to inform application that the APB bus write operation to the LPTIM_CCR1 register has been successfully completed. CMP1OK flag can be cleared by writing 1 to the CMP1OKCF bit in the LPTIM_ICR register.

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. If the trigger is ignored because the timer has already started, then this flag is not set. EXTTRIG flag can be cleared by writing 1 to the EXTTRIGCF bit in the LPTIM_ICR register.

Bit 1 ARRM : Autoreload match

ARRM is set by hardware to inform application that LPTIM_CNT register's value reached the LPTIM_ARR register's value. ARRM flag can be cleared by writing 1 to the ARRMCF bit in the LPTIM_ICR register.

Bit 0 CC1IF : Compare 1 interrupt flag

If channel CC1 is configured as output:

The CC1IF flag is set by hardware to inform application that LPTIM_CNT register value matches the compare register's value. CC1IF flag can be cleared by writing 1 to the CC1CF bit in the LPTIM_ICR register.

0: No match

1: The content of the counter LPTIM_CNT register value has matched the LPTIM_CCR1 register's value

27.7.2 LPTIMx interrupt and status register [alternate] (LPTIMx_ISR) (x = 1 to 3)

This description of the register can only be used for input capture mode. See previous section for output compare mode.

Address offset: 0x000

Reset value: 0x0000 0000

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.DIER OKRes.Res.Res.Res.Res.Res.Res.Res.
r
1514131211109876543210
CC4 OFCC3 OFCC2 OFCC1 OFCC4IFCC3IFCC2IFREP OKUEDOWNUPARR OKRes.EXT TRIGARRMCC1IF
rrrrrrrrrrrrrrr

Bits 31:25 Reserved, must be kept at reset value.

Bit 24 DIEROK : Interrupt enable register update OK

DIEROK is set by hardware to inform application that the APB bus write operation to the LPTIM_DIER register has been successfully completed. DIEROK flag can be cleared by writing 1 to the DIEROKCF bit in the LPTIM_ICR register.

Bits 23:16 Reserved, must be kept at reset value.

Bit 15 CC4OF : Capture 4 over-capture 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 1 to the CC4OCF bit in the LPTIM_ICR register.

0: No over-capture has been detected.

1: The counter value has been captured in LPTIM_CCR4 register while CC4IF flag was already set

Note: If LPTIM does not implement at least 4 channels this bit is reserved. Refer to Section 27.3.

Bit 14 CC3OF : Capture 3 over-capture 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 1 to the CC3OCF bit in the LPTIM_ICR register.

0: No over-capture has been detected.

1: The counter value has been captured in LPTIM_CCR3 register while CC3IF flag was already set.

Note: If LPTIM does not implement at least 3 channels this bit is reserved. Refer to Section 27.3 .

Bit 13 CC2OF : Capture 2 over-capture 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 1 to the CC2OCF bit in the LPTIM_ICR register.

0: No over-capture has been detected.

1: The counter value has been captured in LPTIM_CCR2 register while CC2IF flag was already set.

Note: If LPTIM does not implement at least 2 channels this bit is reserved. Refer to Section 27.3 .

Bit 12 CC1OF : Capture 1 over-capture 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 1 to the CC1OCF bit in the LPTIM_ICR register.

0: No over-capture has been detected.

1: The counter value has been captured in LPTIM_CCR1 register while CC1IF flag was already set.

Note: If LPTIM does not implement at least 1 channel this bit is reserved. Refer to Section 27.3 .

Bit 11 CC4IF : Capture 4 interrupt flag If channel CC4 is configured as input:

CC4IF is set by hardware to inform application that the current value of the counter is captured in LPTIM_CCR4 register. The corresponding interrupt or DMA request is generated if enabled. The CC4OF flag is set if the CC4IF flag was already high.

0: No input capture occurred

1: The counter value has been captured in the LPTIM_CCR4 register. (An edge has been detected on IC4 which matches the selected polarity). The CC4IF flag is automatically cleared by hardware once the captured value is read (CPU or DMA). The CC4IF flag can be cleared by writing 1 to the CC4CF bit in the LPTIM_ICR register.

Note: If LPTIM does not implement at least 4 channels this bit is reserved. Refer to Section 27.3 .

Bit 10 CC3IF : Capture 3 interrupt flag If channel CC3 is configured as input:

CC3IF is set by hardware to inform application that the current value of the counter is captured in LPTIM_CCR3 register. The corresponding interrupt or DMA request is generated if enabled. The CC3OF flag is set if the CC3IF flag was already high.

0: No input capture occurred

1: The counter value has been captured in the LPTIM_CCR3 register. (An edge has been detected on IC3 which matches the selected polarity). The CC3IF flag is automatically cleared by hardware once the captured value is read (CPU or DMA). The CC3IF flag can be cleared by writing 1 to the CC3CF bit in the LPTIM_ICR register.

Note: If LPTIM does not implement at least 3 channels this bit is reserved. Refer to Section 27.3 .

Bit 9 CC2IF : Capture 2 interrupt flag

If channel CC2 is configured as input:

CC2IF is set by hardware to inform application that the current value of the counter is captured in LPTIM_CCR2 register. The corresponding interrupt or DMA request is generated if enabled. The CC2OF flag is set if the CC2IF flag was already high.

0: No input capture occurred

1: The counter value has been captured in the LPTIM_CCR2 register. (An edge has been detected on IC2 which matches the selected polarity). The CC2IF flag is automatically cleared by hardware once the captured value is read (CPU or DMA). The CC2IF flag can be cleared by writing 1 to the CC2CF bit in the LPTIM_ICR register.

Note: If LPTIM does not implement at least 2 channels this bit is reserved. Refer to Section 27.3.

Bit 8 REPOK : Repetition register update OK

REPOK is set by hardware to inform application that the APB bus write operation to the LPTIM_RCR register has been successfully completed. REPOK flag can be cleared by writing 1 to the REPOKCF bit in the LPTIM_ICR register.

Bit 7 UE : LPTIM update event occurred

UE is set by hardware to inform application that an update event was generated. The corresponding interrupt or DMA request is generated if enabled. The UE flag can be cleared by writing 1 to the UECF bit in the LPTIM_ICR register. The UE flag is automatically cleared by hardware once the LPTIM_ARR register is written by any bus master like CPU or DMA.

Bit 6 DOWN : Counter direction change up to down

In Encoder mode, DOWN bit is set by hardware to inform application that the counter direction has changed from up to down. DOWN flag can be cleared by writing 1 to the DOWNCF bit in the LPTIM_ICR register.

Note: If the LPTIM does not support encoder mode feature, this bit is reserved. Refer to Section 27.3.

Bit 5 UP : Counter direction change down to up

In Encoder mode, UP bit is set by hardware to inform application that the counter direction has changed from down to up. UP flag can be cleared by writing 1 to the UPCF bit in the LPTIM_ICR register.

Note: If the LPTIM does not support encoder mode feature, this bit is reserved. Refer to Section 27.3.

Bit 4 ARROK : Autoreload register update OK

ARROK is set by hardware to inform application that the APB bus write operation to the LPTIM_ARR register has been successfully completed. ARROK flag can be cleared by writing 1 to the ARROKCF bit in the LPTIM_ICR register.

Bit 3 Reserved, must be kept at reset value.

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. If the trigger is ignored because the timer has already started, then this flag is not set. EXTTRIG flag can be cleared by writing 1 to the EXTTRIGCF bit in the LPTIM_ICR register.

Bit 1 ARRM : Autoreload match

ARRM is set by hardware to inform application that LPTIM_CNT register's value reached the LPTIM_ARR register's value. ARRM flag can be cleared by writing 1 to the ARRMCF bit in the LPTIM_ICR register.

Bit 0 CC1IF : capture 1 interrupt flag

If channel CC1 is configured as input:

CC1IF is set by hardware to inform application that the current value of the counter is captured in LPTIM_CCR1 register. The corresponding interrupt or DMA request is generated if enabled. The CC1OF flag is set if the CC1IF flag was already high.

0: No input capture occurred

1: The counter value has been captured in the LPTIM_CCR1 register. (An edge has been detected on IC1 which matches the selected polarity). The CC1IF flag is automatically cleared by hardware once the captured value is read (CPU or DMA). CC1IF flag can be cleared by writing 1 to the CC1CF bit in the LPTIM_ICR register.

27.7.3 LPTIMx interrupt clear register [alternate] (LPTIMx_ICR)
(x = 1 to 3)

This description of the register can only be used for output compare mode. See next section for input capture compare mode.

Address offset: 0x004

Reset value: 0x0000 0000

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.DIER
OKCF
Res.Res.CMP4
OKCF
CMP3
OKCF
CMP2
OKCF
Res.Res.Res.
wwww
1514131211109876543210
Res.Res.Res.Res.CC4CFCC3CFCC2CFREPOK
CF
UECFDOWN
CF
UPCFARR
OKCF
CMP1
OKCF
EXT
TRIG
CF
ARRM
CF
CC1CF
wwwwwwwwwwww

Bits 31:25 Reserved, must be kept at reset value.

Bit 24 DIEROKCF : Interrupt enable register update OK clear flag

Writing 1 to this bit clears the DIEROK flag in the LPTIM_ISR register.

Bits 23:22 Reserved, must be kept at reset value.

Bit 21 CMP4OKCF : Compare register 4 update OK clear flag

Writing 1 to this bit clears the CMP4OK flag in the LPTIM_ISR register.

Note: If LPTIM does not implement at least 4 channels this bit is reserved. Refer to Section 27.3.

Bit 20 CMP3OKCF : Compare register 3 update OK clear flag

Writing 1 to this bit clears the CMP3OK flag in the LPTIM_ISR register.

Note: If LPTIM does not implement at least 3 channels this bit is reserved. Refer to Section 27.3.

Bit 19 CMP2OKCF : Compare register 2 update OK clear flag

Writing 1 to this bit clears the CMP2OK flag in the LPTIM_ISR register.

Note: If LPTIM does not implement at least 2 channels this bit is reserved. Refer to Section 27.3.

Bits 18:12 Reserved, must be kept at reset value.

Bit 11 CC4CF : Capture/compare 4 clear flag

Writing 1 to this bit clears the CC4IF flag in the LPTIM_ISR register.

Note: If LPTIM does not implement at least 4 channels this bit is reserved. Refer to Section 27.3.

Bit 10 CC3CF : Capture/compare 3 clear flag

Writing 1 to this bit clears the CC3IF flag in the LPTIM_ISR register.

Note: If LPTIM does not implement at least 3 channels this bit is reserved. Refer to Section 27.3.

Bit 9 CC2CF : Capture/compare 2 clear flag

Writing 1 to this bit clears the CC2IF flag in the LPTIM_ISR register.

Note: If LPTIM does not implement at least 2 channels this bit is reserved. Refer to Section 27.3.

Bit 8 REPOKCF : Repetition register update OK clear flag

Writing 1 to this bit clears the REPOK flag in the LPTIM_ISR register.

Bit 7 UECF : Update event clear flag

Writing 1 to this bit clear the UE flag in the LPTIM_ISR register.

Bit 6 DOWNCF : Direction change to down clear flag

Writing 1 to this bit clear the DOWN flag in the LPTIM_ISR register.

Note: If the LPTIM does not support encoder mode feature, this bit is reserved. Refer to Section 27.3.

Bit 5 UPCF : Direction change to UP clear flag

Writing 1 to this bit clear the UP flag in the LPTIM_ISR register.

Note: If the LPTIM does not support encoder mode feature, this bit is reserved. Refer to Section 27.3.

Bit 4 ARROKCF : Autoreload register update OK clear flag

Writing 1 to this bit clears the ARROK flag in the LPTIM_ISR register

Bit 3 CMP1OKCF : Compare register 1 update OK clear flag

Writing 1 to this bit clears the CMP1OK flag in the LPTIM_ISR register.

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 CC1CF : Capture/compare 1 clear flag

Writing 1 to this bit clears the CC1IF flag in the LPTIM_ISR register.

27.7.4 LPTIMx interrupt clear register [alternate] (LPTIMx_ICR)
(x = 1 to 3)

This description of the register can only be used for input capture mode. See previous section for output compare mode.

Address offset: 0x004

Reset value: 0x0000 0000

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.DIER
OKCF
Res.Res.Res.Res.Res.Res.Res.Res.
w
1514131211109876543210
CC4
OCF
CC3
OCF
CC2
OCF
CC1
OCF
CC4CFCC3CFCC2CFREPOK
CF
UECFDOWN
CF
UPCFARRO
KCF
Res.EXTTR
IGCF
ARRM
CF
CC1CF
wwwwwwwwwwwwwww

Bits 31:25 Reserved, must be kept at reset value.

Bit 24 DIEROKCF : Interrupt enable register update OK clear flag

Writing 1 to this bit clears the DIEROK flag in the LPTIM_ISR register.

Bits 23:16 Reserved, must be kept at reset value.

Bit 15 CC4OCF : Capture/compare 4 over-capture clear flag

Writing 1 to this bit clears the CC4OF flag in the LPTIM_ISR register.

Note: If LPTIM does not implement at least 4 channels this bit is reserved. Refer to Section 27.3.

Bit 14 CC3OCF : Capture/compare 3 over-capture clear flag

Writing 1 to this bit clears the CC3OF flag in the LPTIM_ISR register.

Note: If LPTIM does not implement at least 3 channels this bit is reserved. Refer to Section 27.3.

Bit 13 CC2OCF : Capture/compare 2 over-capture clear flag

Writing 1 to this bit clears the CC2OF flag in the LPTIM_ISR register.

Note: If LPTIM does not implement at least 2 channels this bit is reserved. Refer to Section 27.3.

Bit 12 CC1OCF : Capture/compare 1 over-capture clear flag

Writing 1 to this bit clears the CC1OF flag in the LPTIM_ISR register.

Note: If LPTIM does not implement at least 1 channel this bit is reserved. Refer to Section 27.3.

Bit 11 CC4CF : Capture/compare 4 clear flag

Writing 1 to this bit clears the CC4IF flag in the LPTIM_ISR register.

Note: If LPTIM does not implement at least 4 channels this bit is reserved. Refer to Section 27.3.

Bit 10 CC3CF : Capture/compare 3 clear flag

Writing 1 to this bit clears the CC3IF flag in the LPTIM_ISR register.

Note: If LPTIM does not implement at least 3 channels this bit is reserved. Refer to Section 27.3.

Bit 9 CC2CF : Capture/compare 2 clear flag

Writing 1 to this bit clears the CC2IF flag in the LPTIM_ISR register.

Note: If LPTIM does not implement at least 2 channels this bit is reserved. Refer to Section 27.3.

Bit 8 REPOKCF : Repetition register update OK clear flag

Writing 1 to this bit clears the REPOK flag in the LPTIM_ISR register.

Bit 7 UECF : Update event clear flag

Writing 1 to this bit clear the UE flag in the LPTIM_ISR register.

Bit 6 DOWNCF : Direction change to down clear flag

Writing 1 to this bit clear the DOWN flag in the LPTIM_ISR register.

Note: If the LPTIM does not support encoder mode feature, this bit is reserved. Refer to Section 27.3.

Bit 5 UPCF : Direction change to UP clear flag

Writing 1 to this bit clear the UP flag in the LPTIM_ISR register.

Note: If the LPTIM does not support encoder mode feature, this bit is reserved. Refer to Section 27.3.

Bit 4 ARROKCF : Autoreload register update OK clear flag

Writing 1 to this bit clears the ARROK flag in the LPTIM_ISR register

Bit 3 Reserved, must be kept at reset value.

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 CC1CF : Capture/compare 1 clear flag

Writing 1 to this bit clears the CC1IF flag in the LPTIM_ISR register.

27.7.5 LPTIMx interrupt enable register [alternate] (LPTIMx_DIER) (x = 1 to 3)

This description of the register can only be used for output compare mode. See next section for input capture compare mode.

Address offset: 0x008

Reset value: 0x0000 0000

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.UEDERes.CMP4OKIECMP3OKIECMP2OKIERes.Res.Res.
rwrwrwrw
1514131211109876543210
Res.Res.Res.Res.CC4IECC3IECC2IEREPOKIEUEIEDOWNIEUPIEARROKIECMP1OKIEEXTTRIGIEARRMIECC1IE
rwrwrwrwrwrwrwrwrwrwrwrw

Bits 31:24 Reserved, must be kept at reset value.

Bit 23 UEDE : Update event DMA request enable

0: UE DMA request disabled. Writing '0' to the UEDE bit resets the associated ue_dma_req signal.

1: UE DMA request enabled

Note: If LPTIM does not implement at least 1 channel this bit is reserved. Refer to Section 27.3.

Bit 22 Reserved, must be kept at reset value.

Bit 21 CMP4OKIE : Compare register 4 update OK interrupt enable

0: CMPOK register 4 interrupt disabled

1: CMPOK register 4 interrupt enabled

Note: If LPTIM does not implement at least 4 channels this bit is reserved. Refer to Section 27.3.

Bit 20 CMP3OKIE : Compare register 3 update OK interrupt enable

Note: If LPTIM does not implement at least 3 channels this bit is reserved. Refer to Section 27.3.

Bit 19 CMP2OKIE : Compare register 2 update OK interrupt enable

Note: If LPTIM does not implement at least 2 channels this bit is reserved. Refer to Section 27.3.

Bits 18:12 Reserved, must be kept at reset value.

Bit 11 CC4IE : Capture/compare 4 interrupt enable

Note: If LPTIM does not implement at least 4 channels this bit is reserved. Refer to Section 27.3.

Bit 10 CC3IE : Capture/compare 3 interrupt enable

Note: If LPTIM does not implement at least 3 channels this bit is reserved. Refer to Section 27.3.

Bit 9 CC2IE : Capture/compare 2 interrupt enable

Note: If LPTIM does not implement at least 2 channels this bit is reserved. Refer to Section 27.3.

Bit 8 REPOKIE : Repetition register update OK interrupt Enable

Bit 7 UEIE : Update event interrupt enable

Bit 6 DOWNIE : Direction change to down Interrupt Enable

Note: If the LPTIM does not support encoder mode feature, this bit is reserved. Refer to Section 27.3.

Bit 5 UPIE : Direction change to UP Interrupt Enable

Note: If the LPTIM does not support encoder mode feature, this bit is reserved. Refer to Section 27.3.

Bit 4 ARROKIE : Autoreload register update OK Interrupt Enable

Bit 3 CMP1OKIE : Compare register 1 update OK interrupt enable

Bit 2 EXTTRIGIE : External trigger valid edge Interrupt Enable

Bit 1 ARRMIE : Autoreload match Interrupt Enable

Bit 0 CC1IE : Capture/compare 1 interrupt enable

27.7.6 LPTIMx interrupt enable register [alternate] (LPTIMx_DIER) (x = 1 to 3)

This description of the register can only be used for input capture mode. See previous section for output compare mode.

Address offset: 0x008

Reset value: 0x0000 0000

31302928272625242322212019181716
Res.Res.Res.Res.CC4DECC3DECC2DERes.UEDERes.Res.Res.Res.Res.Res.CC1DE
rwrwrwrwrw
1514131211109876543210
CC4OIECC3OIECC2OIECC1OIECC4IECC3IECC2IEREPOKIEUEIEDOWNIEUPIEARROKIERes.EXTTRIGIEARRMIECC1IE
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrw

Bits 31:28 Reserved, must be kept at reset value.

Bit 27 CC4DE : Capture/compare 4 DMA request enable

Note: If LPTIM does not implement at least 4 channels this bit is reserved. Refer to Section 27.3.

Bit 26 CC3DE : Capture/compare 3 DMA request enable

Note: If LPTIM does not implement at least 3 channels this bit is reserved. Refer to Section 27.3.

Bit 25 CC2DE : Capture/compare 2 DMA request enable

Note: If LPTIM does not implement at least 2 channels this bit is reserved. Refer to Section 27.3.

Bit 24 Reserved, must be kept at reset value.

Bit 23 UDEDE : Update event DMA request enable

0: UE DMA request disabled. Writing '0' to the UDEDE bit resets the associated ue_dma_req signal.

1: UE DMA request enabled

Note: If LPTIM does not implement at least 1 channel this bit is reserved. Refer to Section 27.3.

Bits 22:17 Reserved, must be kept at reset value.

Bit 16 CC1DE : Capture/compare 1 DMA request enable

0: CC1 DMA request disabled. Writing '0' to the CC1DE bit resets the associated ic1_dma_req signal.

1: CC1 DMA request enabled

Note: If LPTIM does not implement at least 1 channel this bit is reserved. Refer to Section 27.3.

Bit 15 CC4OIE : Capture/compare 4 over-capture interrupt enable

0: CC4 over-capture interrupt disabled

1: CC4 over-capture interrupt enabled

Note: If LPTIM does not implement at least 4 channels this bit is reserved. Refer to Section 27.3.

Bit 14 CC3OIE : Capture/compare 3 over-capture interrupt enable

0: CC3 over-capture interrupt disabled

1: CC3 over-capture interrupt enabled

Note: If LPTIM does not implement at least 3 channels this bit is reserved. Refer to Section 27.3.

Bit 13 CC2OIE : Capture/compare 2 over-capture interrupt enable

0: CC2 over-capture interrupt disabled

1: CC2 over-capture interrupt enabled

Note: If LPTIM does not implement at least 2 channels this bit is reserved. Refer to Section 27.3.

Bit 12 CC1OIE : Capture/compare 1 over-capture interrupt enable

0: CC1 over-capture interrupt disabled

1: CC1 over-capture interrupt enabled

Note: If LPTIM does not implement at least 1 channel this bit is reserved. Refer to Section 27.3.

Bit 11 CC4IE : Capture/compare 4 interrupt enable

0: Capture/compare 4 interrupt disabled

1: Capture/compare 4 interrupt enabled

Note: If LPTIM does not implement at least 4 channels this bit is reserved. Refer to Section 27.3.

Bit 10 CC3IE : Capture/compare 3 interrupt enable

0: Capture/compare 3 interrupt disabled

1: Capture/compare 3 interrupt enabled

Note: If LPTIM does not implement at least 3 channels this bit is reserved. Refer to Section 27.3.

Bit 9 CC2IE : Capture/compare 2 interrupt enable

0: Capture/compare 2 interrupt disabled

1: Capture/compare 2 interrupt enabled

Note: If LPTIM does not implement at least 2 channels this bit is reserved. Refer to Section 27.3.

Bit 8 REPOKIE : Repetition register update OK interrupt Enable

0: Repetition register update OK interrupt disabled

1: Repetition register update OK interrupt enabled

Bit 7 UEIE : Update event interrupt enable

0: Update event interrupt disabled

1: Update event interrupt enabled

Bit 6 DOWNIE : Direction change to down Interrupt Enable

Note: If the LPTIM does not support encoder mode feature, this bit is reserved. Refer to Section 27.3.

Bit 5 UPIE : Direction change to UP Interrupt Enable

Note: If the LPTIM does not support encoder mode feature, this bit is reserved. Refer to Section 27.3.

Bit 4 ARROKIE : Autoreload register update OK Interrupt Enable

Bit 3 Reserved, must be kept at reset value.

Bit 2 EXTTRIGIE : External trigger valid edge Interrupt Enable

Bit 1 ARRMIE : Autoreload match Interrupt Enable

Bit 0 CC1IE : Capture/compare 1 interrupt enable

27.7.7 LPTIM configuration register (LPTIM_CFGR)

Address offset: 0x00C

Reset value: 0x0000 0000

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.ENCCOUNT
MODE
PRE
LOAD
Res.WAVETIMOUTTRIGEN[1:0]Res.
rwrwrwrwrwrwrw
1514131211109876543210
TRIGSEL[2:0]Res.Res.Res.PRESC[2:0]Res.Res.TRGFLT[1:0]Res.CKFLT[1:0]CKPOL[1:0]CKSEL
rwrwrwrwrwrwrwrwrwrwrwrwrw

Bits 31:30 Reserved, must be kept at reset value.

Bit 29 Reserved, must be kept at reset value.

Bits 28:25 Reserved, must be kept at reset value.

Bit 24 ENC : Encoder mode enable

The ENC bit controls the Encoder mode

Note: If the LPTIM does not support encoder mode feature, this bit is reserved. Refer to Section 27.3.

Bit 23 COUNTMODE : counter mode enabled

The COUNTMODE bit selects which clock source is used by the LPTIM to clock the counter:

0: the counter is incremented following each internal clock pulse

1: the counter is incremented following each valid clock pulse on the LPTIM external Input1

Bit 22 PRELOAD : Registers update mode

The PRELOAD bit controls the LPTIM_ARR, LPTIM_RCR and the LPTIM_CCRx registers update modality

0: Registers are updated after each APB bus write access

1: Registers are updated at the end of the current LPTIM period

Bit 21 Reserved, must be kept at reset value.

Bit 20 WAVE : Waveform shape

The WAVE bit controls the output shape

0: Deactivate Set-once mode

1: Activate the Set-once mode

Bit 19 TIMOUT : Timeout enable

The TIMOUT bit controls the Timeout feature

0: A trigger event arriving when the timer is already started is ignored

1: A trigger event arriving when the timer is already started resets and restarts the LPTIM counter and the repetition counter

Bits 18:17 TRIGEN[1:0] : Trigger enable and polarity

The TRIGEN bits controls whether the LPTIM counter is started by an external trigger or not. If the external trigger option is selected, three configurations are possible for the trigger active edge:

00: software trigger (counting start is initiated by software)

01: rising edge is the active edge

10: falling edge is the active edge

11: both edges are active edges

Bit 16 Reserved, must be kept at reset value.

Bits 15:13 TRIGSEL[2:0] : Trigger selector

The TRIGSEL bits select the trigger source that serves as a trigger event for the LPTIM among the below 8 available sources:

000: lptim_ext_trig0

001: lptim_ext_trig1

010: lptim_ext_trig2

011: lptim_ext_trig3

100: lptim_ext_trig4

101: lptim_ext_trig5

110: lptim_ext_trig6

111: lptim_ext_trig7

See Section 27.4.3: LPTIM input and trigger mapping for details.

Bit 12 Reserved, must be kept at reset value.

Bits 11:9 PRESC[2:0] : Clock prescaler

The PRESC bits configure the prescaler division factor. It can be one among the following division factors:

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 are 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

Bit 5 Reserved, must be kept at reset value.

Bits 4:3 CKFLT[1:0] : Configurable digital filter for external clock

The CKFLT value sets the number of consecutive equal samples that are detected when a level change occurs on an external clock signal before it is considered as a valid level transition. An internal clock source must be present to use this feature

Bits 2:1 CKPOL[1:0] : Clock Polarity

When the LPTIM is clocked by an external clock source, CKPOL bits is used to configure the active edge or edges used by the counter:

If the LPTIM is configured in Encoder mode (ENC bit is set), the encoder sub-mode 1 is active.

If the LPTIM is configured in Encoder mode (ENC bit is set), the encoder sub-mode 2 is active.

If the LPTIM is configured in Encoder mode (ENC bit is set), the encoder sub-mode 3 is active.

Refer to Section 27.4.15: Encoder mode for more details about Encoder mode sub-modes.

Bit 0 CKSEL : Clock selector

The CKSEL bit selects which clock source the LPTIM uses:

Caution: The LPTIM_CFGR register must only be modified when the LPTIM is disabled (ENABLE bit reset to 0).

27.7.8 LPTIM control register (LPTIM_CR)

Address offset: 0x010

Reset value: 0x0000 0000

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.
1514131211109876543210
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.RSTARECOUNTRSTCNTSTARTSNGSTARTENABLE
rwrsrwrwrw

Bits 31:5 Reserved, must be kept at reset value.

Bit 4 RSTARE : Reset after read enable

This bit is set and cleared by software. When RSTARE is set to '1', any read access to LPTIM_CNT register asynchronously resets LPTIM_CNT register content.

This bit can be set only when the LPTIM is enabled.

Bit 3 COUNTRST : Counter reset

This bit is set by software and cleared by hardware. When set to '1' this bit triggers a synchronous reset of the LPTIM_CNT counter register. Due to the synchronous nature of this reset, it only takes place after a synchronization delay of 3 LPTimer core clock cycles (LPTimer core clock can be different from APB clock).

This bit can be set only when the LPTIM is enabled. It is automatically reset by hardware.

Caution: COUNTRST must never be set to '1' by software before it is already cleared to '0' by hardware. Software must consequently check that COUNTRST bit is already cleared to '0' before attempting to set it to '1'.

Bit 2 CNTSTRT: Timer start in Continuous mode

This bit is set by software and cleared by hardware.

In case of software start (TRIGEN[1:0] = 00), setting this bit starts the LPTIM in Continuous mode.

If the software start is disabled (TRIGEN[1:0] different than 00), setting this bit starts the timer in Continuous mode as soon as an external trigger is detected.

If this bit is set when a single pulse mode counting is ongoing, then the timer does not stop at the next match between the LPTIM_ARR and LPTIM_CNT registers and the LPTIM counter keeps counting in Continuous mode.

This bit can be set only when the LPTIM is enabled. It is automatically reset by hardware.

Bit 1 SNGSTRT: LPTIM start in Single mode

This bit is set by software and cleared by hardware.

In case of software start (TRIGEN[1:0] = 00), setting this bit starts the LPTIM in single pulse mode.

If the software start is disabled (TRIGEN[1:0] different than 00), setting this bit starts the LPTIM in single pulse mode as soon as an external trigger is detected.

If this bit is set when the LPTIM is in continuous counting mode, then the LPTIM stops at the following match between LPTIM_ARR and LPTIM_CNT registers.

This bit can only be set when the LPTIM is enabled. It is automatically reset by hardware.

Bit 0 ENABLE: LPTIM enable

The ENABLE bit is set and cleared by software.

0: LPTIM is disabled. Writing '0' to the ENABLE bit resets all the DMA request signals (input capture and update event DMA requests).

1: LPTIM is enabled

27.7.9 LPTIM compare register 1 (LPTIM_CCR1)

Address offset: 0x014

Reset value: 0x0000 0000

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.
1514131211109876543210
CCR1[15:0]
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrw

Bits 31:16 Reserved, must be kept at reset value.

Bits 15:0 CCR1[15:0]: Capture/compare 1 value

If channel CC1 is configured as output:

CCR1 is the value to be loaded in the capture/compare 1 register.

Depending on the PRELOAD option, the CCR1 register is immediately updated if the PRELOAD bit is reset and updated at next LPTIM update event if PRELOAD bit is reset.

The capture/compare register 1 contains the value to be compared to the counter LPTIM_CNT and signaled on OC1 output.

If channel CC1 is configured as input:

CCR1 becomes read-only, it contains the counter value transferred by the last input capture 1 event.

The LPTIM_CCR1 register is read-only and cannot be programmed.

Caution: The LPTIM_CCR1 register must only be modified when the LPTIM is enabled (ENABLE bit set to 1).

27.7.10 LPTIM autoreload register (LPTIM_ARR)

Address offset: 0x018

Reset value: 0x0000 0001

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.
1514131211109876543210
ARR[15:0]
r/wr/wr/wr/wr/wr/wr/wr/wr/wr/wr/wr/wr/wr/wr/wr/w

Bits 31:16 Reserved, must be kept at reset value.

Bits 15:0 ARR[15:0] : Auto reload value

ARR is the autoreload value for the LPTIM.

This value must be strictly greater than the CCRx[15:0] value.

Caution: The LPTIM_ARR register must only be modified when the LPTIM is enabled (ENABLE bit set to 1).

27.7.11 LPTIM counter register (LPTIM_CNT)

Address offset: 0x01C

Reset value: 0x0000 0000

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.
1514131211109876543210
CNT[15:0]
rrrrrrrrrrrrrrrr

Bits 31:16 Reserved, must be kept at reset value.

Bits 15:0 CNT[15:0] : Counter value

When the LPTIM is running, reading the LPTIM_CNT register may return unreliable values. In this case it is necessary to perform consecutive reads until two returned values are identical.

27.7.12 LPTIM configuration register 2 (LPTIM_CFGR2)

Address offset: 0x024

Reset value: 0x0000 0000

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.IC2SEL[1:0]Res.Res.Res.IC1SEL[1:0]Res.
r/wr/wr/wr/w
1514131211109876543210
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.IN2SEL[1:0]Res.Res.Res.IN1SEL[1:0]Res.
r/wr/wr/wr/w

Bits 31:22 Reserved, must be kept at reset value.

Bits 21:20 IC2SEL[1:0] : LPTIM input capture 2 selection

The IC2SEL bits control the LPTIM Input capture 2 multiplexer, which connects LPTIM Input capture 2 to one of the available inputs.

00: lptim_ic2_mux0

01: lptim_ic2_mux1

10: lptim_ic2_mux2

11: lptim_ic2_mux3

For connection details refer to Section 27.4.3: LPTIM input and trigger mapping .

Bits 19:18 Reserved, must be kept at reset value.

Bits 17:16 IC1SEL[1:0] : LPTIM input capture 1 selection

The IC1SEL bits control the LPTIM Input capture 1 multiplexer, which connects LPTIM Input capture 1 to one of the available inputs.

00: lptim_ic1_mux0

01: lptim_ic1_mux1

10: lptim_ic1_mux2

11: lptim_ic1_mux3

For connection details refer to Section 27.4.3: LPTIM input and trigger mapping .

Bits 15:6 Reserved, must be kept at reset value.

Bits 5:4 IN2SEL[1:0] : LPTIM input 2 selection

The IN2SEL bits control the LPTIM input 2 multiplexer, which connects LPTIM input 2 to one of the available inputs.

00: lptim_in2_mux0

01: lptim_in2_mux1

10: lptim_in2_mux2

11: lptim_in2_mux3

For connection details refer to Section 27.4.3: LPTIM input and trigger mapping .

Bits 3:2 Reserved, must be kept at reset value.

Bits 1:0 IN1SEL[1:0] : LPTIM input 1 selection

The IN1SEL bits control the LPTIM input 1 multiplexer, which connects LPTIM input 1 to one of the available inputs.

00: lptim_in1_mux0

01: lptim_in1_mux1

10: lptim_in1_mux2

11: lptim_in1_mux3

For connection details refer to Section 27.4.3: LPTIM input and trigger mapping .

27.7.13 LPTIM repetition register (LPTIM_RCR)

Address offset: 0x028

Reset value: 0x0000 0000

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.
1514131211109876543210
Res.Res.Res.Res.Res.Res.Res.Res.REP[7:0]
rwrwrwrwrwrwrwrw

Bits 31:8 Reserved, must be kept at reset value.

Bits 7:0 REP[7:0] : Repetition register value

REP is the repetition value for the LPTIM.

Caution: The LPTIM_RCR register must only be modified when the LPTIM is enabled (ENABLE bit set to 1). When using repetition counter with PRELOAD = 0, LPTIM_RCR register must be changed at least five counter cycles before the auto reload match event, otherwise an unpredictable behavior may occur.

27.7.14 LPTIM capture/compare mode register 1 (LPTIM_CCMR1)

Address offset: 0x02C

Reset value: 0x0000 0000

The channels can be used in input (capture mode) or in output (PWM mode). The direction of a channel is defined by configuring the corresponding CCxSEL bits.

31302928272625242322212019181716
Res.Res.IC2F[1:0]Res.Res.IC2PSC[1:0]Res.Res.Res.Res.CC2P[1:0]CC2ECC2
SEL
rwrwrwrwrwrwrwrwrwrw
1514131211109876543210
Res.Res.IC1F[1:0]Res.Res.IC1PSC[1:0]Res.Res.Res.Res.CC1P[1:0]CC1ECC1
SEL
rwrwrwrwrwrwrwrwrwrw

Bits 31:30 Reserved, must be kept at reset value.

Bits 29:28 IC2F[1:0] : Input capture 2 filter

This bitfield defines the number of consecutive equal samples that are detected when a level change occurs on an external input capture signal before it is considered as a valid level transition. An internal clock source must be present to use this feature.

00: any external input capture signal level change is considered as a valid transition

01: external input capture signal level change must be stable for at least 2 clock periods before it is considered as valid transition.

10: external input capture signal level change must be stable for at least 4 clock periods before it is considered as valid transition.

11: external input capture signal level change must be stable for at least 8 clock periods before it is considered as valid transition.

Bits 27:26 Reserved, must be kept at reset value.

Bits 25:24 IC2PSC[1:0] : Input capture 2 prescaler

This bitfield defines the ratio of the prescaler acting on the CC2 input (IC2).

00: no prescaler, capture is done each time an edge is detected on the capture input

01: capture is done once every 2 events

10: capture is done once every 4 events

11: capture is done once every 8 events

Bits 23:20 Reserved, must be kept at reset value.

Bits 19:18 CC2P[1:0] : Capture/compare 2 output polarity.

Condition: CC2 as output

Only bit2 is used to set polarity when output mode is enabled, bit3 is don't care.

0: OC2 active high

1: OC2 active low

Condition: CC2 as input

This field is used to select the IC2 polarity for capture operations.

00: rising edge, circuit is sensitive to IC2 rising edge

01: falling edge, circuit is sensitive to IC2 falling edge

10: reserved, do not use this configuration.

11: both edges, circuit is sensitive to both IC2 rising and falling edges.

Bit 17 CC2E : Capture/compare 2 output enable.

Condition: CC2 as output

0: Off - OC2 is not active. Writing '0' to the CC2E bit resets the ue_dma_req signal only if all the other LPTIM channels are disabled.

1: On - OC2 signal is output on the corresponding output pin

Condition: CC2 as input

This bit determines if a capture of the counter value can actually be done into the input capture/compare register 2 (LPTIM_CCR2) or not.

0: Capture disabled. Writing '0' to the CC2E bit resets the associated ic2_dma_req signal.

1: Capture enabled.

Bit 16 CC2SEL : Capture/compare 2 selection

This bitfield defines the direction of the channel, input (capture) or output mode.

0: CC2 channel is configured in output PWM mode

1: CC2 channel is configured in input capture mode

Bits 15:14 Reserved, must be kept at reset value.

Bits 13:12 IC1F[1:0] : Input capture 1 filter

This bitfield defines the number of consecutive equal samples that are detected when a level change occurs on an external input capture signal before it is considered as a valid level transition. An internal clock source must be present to use this feature.

00: any external input capture signal level change is considered as a valid transition

01: external input capture signal level change must be stable for at least 2 clock periods before it is considered as valid transition.

10: external input capture signal level change must be stable for at least 4 clock periods before it is considered as valid transition.

11: external input capture signal level change must be stable for at least 8 clock periods before it is considered as valid transition.

Bits 11:10 Reserved, must be kept at reset value.

Bits 9:8 IC1PSC[1:0] : Input capture 1 prescaler

This bitfield defines the ratio of the prescaler acting on the CC1 input (IC1).

00: no prescaler, capture is done each time an edge is detected on the capture input

01: capture is done once every 2 events

10: capture is done once every 4 events

11: capture is done once every 8 events

Bits 7:4 Reserved, must be kept at reset value.

Bits 3:2 CC1P[1:0] : Capture/compare 1 output polarity.

Condition: CC1 as output

Only bit2 is used to set polarity when output mode is enabled, bit3 is don't care.

0: OC1 active high, the LPTIM output reflects the compare results between LPTIM_ARR and LPTIM_CCRx registers

1: OC1 active low, the LPTIM output reflects the inverse of the compare results between LPTIM_ARR and LPTIM_CCRx registers

Condition: CC1 as input

This field is used to select the IC1 polarity for capture operations.

00: rising edge, circuit is sensitive to IC1 rising edge

01: falling edge, circuit is sensitive to IC1 falling edge

10: reserved, do not use this configuration.

11: both edges, circuit is sensitive to both IC1 rising and falling edges.

Bit 1 CC1E : Capture/compare 1 output enable.

Condition: CC1 as output

0: Off - OC1 is not active. Writing '0' to the CC1E bit resets the ue_dma_req signal only if all the other LPTIM channels are disabled.

1: On - OC1 signal is output on the corresponding output pin

Condition: CC1 as input

This bit determines if a capture of the counter value can actually be done into the input capture/compare register 1 (LPTIM_CCR1) or not.

0: Capture disabled. Writing '0' to the CC1E bit resets the associated ic1_dma_req signal.

1: Capture enabled.

Bit 0 CC1SEL : Capture/compare 1 selection

This bitfield defines the direction of the channel input (capture) or output mode.

0: CC1 channel is configured in output PWM mode

1: CC1 channel is configured in input capture mode

Caution: After a write to the LPTIM_CCMRx register, a new write operation to the same register can only be performed after a delay that must be equal or greater than the value of (PRESC × 3)

kernel clock cycles, PRESC[2:0] being the clock decimal division factor (1, 2, 4,..128). Any successive write violating this delay, leads to unpredictable results.

Caution: The CCxSEL, ICxF[1:0], CCxP[1:0] and ICxPSC[1:0] fields must only be modified when the channel x is disabled (CCxE bit reset to 0).

27.7.15 LPTIM capture/compare mode register 2 (LPTIM_CCMR2)

Address offset: 0x030

Reset value: 0x0000 0000

The channels can be used in input (capture mode) or in output (PWM mode). The direction of a channel is defined by configuring the corresponding CCxSEL bits.

31302928272625242322212019181716
Res.Res.IC4F[1:0]Res.Res.IC4PSC[1:0]Res.Res.Res.Res.CC4P[1:0]CC4ECC4 SEL
rwrwrwrwrwrwrwrw

1514131211109876543210
Res.Res.IC3F[1:0]Res.Res.IC3PSC[1:0]Res.Res.Res.Res.CC3P[1:0]CC3ECC3 SEL
rwrwrwrwrwrwrwrw

Bits 31:30 Reserved, must be kept at reset value.

Bits 29:28 IC4F[1:0] : Input capture 4 filter

This bitfield defines the number of consecutive equal samples that should be detected when a level change occurs on an external input capture signal before it is considered as a valid level transition. An internal clock source must be present to use this feature.

00: any external input capture signal level change is considered as a valid transition

01: external input capture signal level change must be stable for at least 2 clock periods before it is considered as valid transition.

10: external input capture signal level change must be stable for at least 4 clock periods before it is considered as valid transition.

11: external input capture signal level change must be stable for at least 8 clock periods before it is considered as valid transition.

Bits 27:26 Reserved, must be kept at reset value.

Bits 25:24 IC4PSC[1:0] : Input capture 4 prescaler

This bitfield defines the ratio of the prescaler acting on the CC4 input (IC4).

00: no prescaler, capture is done each time an edge is detected on the capture input

01: capture is done once every 2 events

10: capture is done once every 4 events

11: capture is done once every 8 events

Bits 23:20 Reserved, must be kept at reset value.

Bits 19:18 CC4P[1:0] : Capture/compare 4 output polarity.

Condition: CC4 as output:

Only bit2 is used to set polarity when output mode is enabled, bit3 is don't care.

0: OC4 active high

1: OC4 active low

Condition: CC4 as input:

This field is used to select the IC4 polarity for capture operations.

00: rising edge, circuit is sensitive to IC4 rising edge

01: falling edge, circuit is sensitive to IC4 falling edge

10: reserved, do not use this configuration.

11: both edges, circuit is sensitive to both IC4 rising and falling edges.

Bit 17 CC4E : Capture/compare 4 output enable.

Condition: CC4 as output:

0: Off - OC4 is not active. Writing '0' to the CC4E bit resets the ue_dma_req signal only if all the other LPTIM channels are disabled.

1: On - OC4 signal is output on the corresponding output pin

Condition: CC4 as input:

This bit determines if a capture of the counter value can actually be done into the input capture/compare register 4 (LPTIM_CCR4) or not.

0: Capture disabled. Writing '0' to the CC4E bit resets the associated ic4_dma_req signal.

1: Capture enabled.

Bit 16 CC4SEL : Capture/compare 4 selection

This bitfield defines the direction of the channel, input (capture) or output mode.

0: CC4 channel is configured in output PWM mode

1: CC4 channel is configured in input capture mode

Bits 15:14 Reserved, must be kept at reset value.

Bits 13:12 IC3F[1:0] : Input capture 3 filter

This bitfield defines the number of consecutive equal samples that should be detected when a level change occurs on an external input capture signal before it is considered as a valid level transition. An internal clock source must be present to use this feature.

00: any external input capture signal level change is considered as a valid transition

01: external input capture signal level change must be stable for at least 2 clock periods before it is considered as valid transition.

10: external input capture signal level change must be stable for at least 4 clock periods before it is considered as valid transition.

11: external input capture signal level change must be stable for at least 8 clock periods before it is considered as valid transition.

Bits 11:10 Reserved, must be kept at reset value.

Bits 9:8 IC3PSC[1:0] : Input capture 3 prescaler

This bitfield defines the ratio of the prescaler acting on the CC3 input (IC3).

00: no prescaler, capture is done each time an edge is detected on the capture input

01: capture is done once every 2 events

10: capture is done once every 4 events

11: capture is done once every 8 events

Bits 7:4 Reserved, must be kept at reset value.

Bits 3:2 CC3P[1:0] : Capture/compare 3 output polarity.

Condition: CC3 as output:

Only bit2 is used to set polarity when output mode is enabled, bit3 is don't care.

0: OC3 active high, the LPTIM output reflects the compare results between LPTIM_ARR and LPTIM_CCRx registers

1: OC3 active low, the LPTIM output reflects the inverse of the compare results between LPTIM_ARR and LPTIM_CCRx registers

Condition: CC3 as input:

This field is used to select the IC3 polarity for capture operations.

00: rising edge, circuit is sensitive to IC3 rising edge

01: falling edge, circuit is sensitive to IC3 falling edge

10: reserved, do not use this configuration.

11: both edges, circuit is sensitive to both IC3 rising and falling edges.

Bit 1 CC3E : Capture/compare 3 output enable.

Condition: CC3 as output:

0: Off - OC3 is not active. Writing '0' to the CC3E bit resets the ue_dma_req signal only if all the other LPTIM channels are disabled.

1: On - OC3 signal is output on the corresponding output pin

Condition: CC3 as input:

This bit determines if a capture of the counter value can actually be done into the input capture/compare register 3 (LPTIM_CCR3) or not.

0: Capture disabled. Writing '0' to the CC3E bit resets the associated ic3_dma_req signal.

1: Capture enabled.

Bit 0 CC3SEL : Capture/compare 3 selection

This bitfield defines the direction of the channel input (capture) or output mode.

0: CC3 channel is configured in output PWM mode

1: CC3 channel is configured in input capture mode

Caution: After a write to the LPTIM_CCMRx register, a new write operation to the same register can only be performed after a delay that must be equal or greater than the value of \( (\text{PRESC} \times 3) \) kernel clock cycles, PRESC[2:0] being the clock decimal division factor (1, 2, 4,..128). Any successive write violating this delay, leads to unpredictable results.

Caution: The CCxSEL, ICxF[1:0], CCxP[1:0] and ICxPSC[1:0] fields must only be modified when the channel x is disabled (CCxE bit reset to 0).

27.7.16 LPTIM compare register 2 (LPTIM_CCR2)

Address offset: 0x034

Reset value: 0x0000 0000

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.
1514131211109876543210
CCR2[15:0]
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrw

Bits 31:16 Reserved, must be kept at reset value.

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 capture/compare 2 register.

Depending on the PRELOAD option, the CCR2 register is immediately updated if the PRELOAD bit is reset and updated at next LPTIM update event if PRELOAD bit is reset.

The capture/compare register 2 contains the value to be compared to the counter LPTIM_CNT and signaled on OC2 output.

If channel CC2 is configured as input:

CCR2 becomes read-only, it contains the counter value transferred by the last input capture 2 event. The LPTIM_CCR2 register is read-only and cannot be programmed.

Caution: The LPTIM_CCR2 register must only be modified when the LPTIM is enabled (ENABLE bit set to 1).

Note: If the LPTIM implements less than 2 channels this register is reserved. Refer to Section 27.3: LPTIM implementation .

27.7.17 LPTIM compare register 3 (LPTIM_CCR3)

Address offset: 0x038

Reset value: 0x0000 0000

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.
1514131211109876543210
CCR3[15:0]
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrw

Bits 31:16 Reserved, must be kept at reset value.

Bits 15:0 CCR3[15:0] : Capture/compare 3 value

If channel CC3 is configured as output:

CCR3 is the value to be loaded in the capture/compare 3 register.

Depending on the PRELOAD option, the CCR3 register is immediately updated if the PRELOAD bit is reset and updated at next LPTIM update event if PRELOAD bit is reset.

The capture/compare register 3 contains the value to be compared to the counter LPTIM_CNT and signaled on OC3 output.

If channel CC3 is configured as input:

CCR3 becomes read-only, it contains the counter value transferred by the last input capture 3 event. The LPTIM_CCR3 register is read-only and cannot be programmed.

Caution: The LPTIM_CCR3 register must only be modified when the LPTIM is enabled (ENABLE bit set to 1).

Note: If the LPTIM implements less than 3 channels this register is reserved. Refer to Section 27.3: LPTIM implementation .

27.7.18 LPTIM compare register 4 (LPTIM_CCR4)

Address offset: 0x03C

Reset value: 0x0000 0000

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.
1514131211109876543210
CCR4[15:0]
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrw

Bits 31:16 Reserved, must be kept at reset value.

Bits 15:0 CCR4[15:0] : Capture/compare 4 value
If channel CC4 is configured as output:
CCR4 is the value to be loaded in the capture/compare 4 register.
Depending on the PRELOAD option, the CCR4 register is immediately updated if the PRELOAD bit is reset and updated at next LPTIM update event if PRELOAD bit is reset.
The capture/compare register 4 contains the value to be compared to the counter LPTIM_CNT and signaled on OC4 output.
If channel CC4 is configured as input:
CCR4 becomes read-only, it contains the counter value transferred by the last input capture 4 event.
The LPTIM_CCR4 register is read-only and cannot be programmed.

Caution: The LPTIM_CCR4 register must only be modified when the LPTIM is enabled (ENABLE bit set to 1).

Note: If the LPTIM implements less than 4 channels this register is reserved. Refer to Section 27.3: LPTIM implementation .

27.7.19 LPTIM register map

The following table summarizes the LPTIM registers.

Table 160. LPTIM register map and reset values

OffsetRegister name313029282726252423222120191817161514131211109876543210
0x000LPTIMx_ISR (x = 1 to 3) Output compare modeRes.Res.Res.Res.Res.Res.Res.DIEROKRes.Res.CMP4OK (1)CMP3OK (2)CMP2OK (3)Res.Res.Res.Res.Res.Res.Res.CC4IF (1)CC3IF (2)CC2IF (3)REPOKUEDOWN (4)UP (4)ARROKCMP1OKEXTRIGARRMCC1IF
Reset value0000000000000000
LPTIMx_ISR (x = 1 to 3) Input capture modeRes.Res.Res.Res.Res.Res.Res.DIEROKRes.Res.Res.Res.Res.Res.Res.Res.CC4OF (1)CC3OF (2)CC2OF (3)CC1OFCC4IF (1)CC3IF (2)CC2IF (3)REPOKUEDOWN (4)UP (4)ARROKRes.EXTRIGARRMCC1IF
Reset value0000000000000000

Table 160. LPTIM register map and reset values (continued)

OffsetRegister name313029282726252423222120191817161514131211109876543210
0x004LPTIMx_ICR
(x = 1 to 3)
Output compare mode
Res.Res.Res.Res.Res.Res.Res.DIEROKCFRes.Res.CMP4OKCF (1)CMP3OKCF (2)CMP2OKCF (3)Res.Res.Res.Res.Res.Res.Res.CC4CF (1)CC3CF (2)CC2CF (3)REPOKCFUECFDOWNCF (4)UPCF (4)ARROKCFCMP1OKCFEXTRIGCFARRMCFCC1CF
Reset value0000000000000000
LPTIMx_ICR
(x = 1 to 3)
Input capture mode
Res.Res.Res.Res.Res.Res.Res.DIEROKCFRes.Res.Res.Res.Res.Res.Res.Res.CC4OCF (1)CC3OCF (2)CC2OCF (3)CC1OCFCC4CF (1)CC3CF (2)CC2CF (3)REPOKCFUECFDOWNCF (4)UPCF (4)ARROKCFRes.EXTRIGCFARRMCFCC1CF
Reset value0000000000000000
0x008LPTIMx_DIER
(x = 1 to 3)
Output compare mode
Res.Res.Res.Res.Res.Res.Res.Res.UEDERes.CMP4OKIE (1)CMP3OKIE (2)CMP2OKIE (3)Res.Res.Res.Res.Res.Res.Res.CC4IE (1)CC3IE (2)CC2IE (3)REPOKIEUEIEDOWNIE (4)UPIE (4)ARROKIECMP1OKIEEXTRIGIEARRMIECC1IE
Reset value0000000000000000
LPTIMx_DIER
(x = 1 to 3)
Input capture mode
Res.Res.Res.Res.CC4DE (1)CC3DE (2)CC2DE (3)Res.UEDERes.Res.Res.Res.Res.Res.CC1DECC4OE (1)CC3OE (2)CC2OE (3)CC1OECC4IE (1)CC3IE (2)CC2IE (3)REPOKIEUEIEDOWNIE (4)UPIE (4)ARROKIERes.EXTRIGIEARRMIECC1IE
Reset value00000000000000000000
0x00CLPTIM_CFGRRes.Res.Res.Res.Res.Res.Res.ENC (4)COUNTMODEPRELOADRes.WAVETIMEOUTTRIGENRes.Res.TRIGSEL[2:0]Res.PRESCRes.TRGFLTRes.CKFLTCKPOLCKSEL
Reset value0000000000000000000
0x010LPTIM_CRRes.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.RSTARTCOUNTSTRCNTSTRSNGSTRENABLE
Reset value00000
0x014LPTIM_CCR1Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.CCR1[15:0]
Reset value000000000000000
0x018LPTIM_ARRRes.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.ARR[15:0]
Reset value000000000000001
0x01CLPTIM_CNTRes.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.CNT[15:0]
Reset value000000000000000
0x024LPTIM_CFGR2Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.IC2SEL[1:0]Res.Res.IC1SEL[1:0]Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.IN2SEL[1:0]Res.Res.Res.Res.IN1SEL[1:0]
Reset value000000
0x028LPTIM_RCRRes.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.REP[7:0]
Reset value000000000000000
0x02CLPTIM_CCMR1Res.Res.IC2F[1:0]Res.Res.Res.IC2PSC[1:0]Res.Res.Res.Res.CC2P[1:0]CC2ECC2SELRes.Res.IC1F[1:0]Res.Res.Res.Res.IC1PSC[1:0]Res.Res.Res.Res.Res.Res.Res.CC1P[1:0]CC1ECC1SEL
Reset value00000000000000

Table 160. LPTIM register map and reset values (continued)

OffsetRegister name313029282726252423222120191817161514131211109876543210
0x030LPTIM_CCMR2Res.Res.IC4F[1:0]Res.Res.IC4PSC[1:0]Res.Res.Res.Res.Res.Res.CC4P[1:0]CC4ECC4SELRes.Res.IC3F[1:0]Res.Res.IC3PSC[1:0]Res.Res.Res.Res.Res.Res.CC3P[1:0]CC3ECC3SEL
Reset value0 00 00 0000 00 00 000
0x034LPTIM_CCR2 (5)Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.CCR2[15:0]
Reset value0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0x03CLPTIM_CCR4 (6)Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.CCR4[15:0]
Reset value0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
  1. 1. If LPTIM does not implement at least 4 channels this bit is reserved. Refer to Section 27.3: LPTIM implementation .
  2. 2. If LPTIM does not implement at least 3 channels this bit is reserved. Refer to Section 27.3: LPTIM implementation .
  3. 3. If LPTIM does not implement at least 2 channels this bit is reserved. Refer to Section 27.3: LPTIM implementation .
  4. 4. If LPTIM does not support encoder mode feature, this bit is reserved. Refer to Section 27.3: LPTIM implementation .
  5. 5. If the LPTIM implements less than 2 channels this register is reserved. Refer to Section 27.3: LPTIM implementation .
  6. 6. If the LPTIM implements less than 4 channels this register is reserved. Refer to Section 27.3: LPTIM implementation .

Refer to Section 2.2: Memory organization for the register boundary addresses.