 Hello, and welcome to this presentation of the STM32 Low Power Timer, or LP-TIM. It covers the features of this peripheral, which offers a set of timing features and can generate waveforms even in low power modes. The Low Power Timer peripheral, embedded in the STM32L4 microcontroller, provides a 16-bit timer that is able to run even in stop zero, stop one, and stop two low power modes. This is made possible thanks to a flexible clocking scheme. The Low Power Timer peripheral provides basic general-purpose timer functions with very low power consumption compared to other timers. One major function of the Low Power Timer is its capability to keep running even when no internal clock source is active when configured in asynchronous counting mode. The Low Power Timer's main feature is its ability to keep running even in low power modes when almost all clock sources are turned off. The Low Power Timer has a very flexible clocking scheme. It can be clocked from on-ship clock sources, LSE, LSI, HSI, or APB clock, or it can be clocked from an external clock source over the Low Power Timer's input one input. This latter feature is used for building pulse counter applications and is a key function for metering applications like gas meters, etc. The Low Power Timer features up to eight external trigger sources with configurable polarity. External trigger inputs feature digital filters to cancel out faulty triggers that could be raised in noisy operating environments. The Low Power Timer can be configured to run either in continuous or one-shot mode. One-shot mode is used for generating pulse wave forms while continuous mode is used to generate PWM wave forms. The Low Power Timer is a peripheral with two clock domains. The APB clock domain contains the peripheral's APB interface. The kernel clock domain can be clocked by the APB clock source or by other internal clock sources, including the LSE, LSI, and HSI sources. Also, the kernel clock domain can be clocked from an external clock source through the timer's input one input. The Low Power Timer peripheral embeds a 16-bit counter that is fed through a power of two pre-scaler. The Low Power Timer peripheral features a 16-bit auto-reload register and a 16-bit compare register that are used to set the period and duty cycle respectively for a PWM wave form signal output on the timer's out output. The Low Power Timer features an encoder mode function that can be used to interface with incremental quadrature encoder sensors using the peripheral's input one and input two inputs. Both inputs feature glitch filtering circuitry. The Low Power Timer can be used to output various kinds of wave forms even when the microcontroller is in stop zero, stop one, and stop two low power modes where almost all internal clock sources are turned off. The LP-TIMX-CMP and LP-TIMX-ARR registers in conjunction with the bitfield's wave from the LP-TIMX-CFGR register and SNG-STRT from the LP-TIMX-CRR register are used to control the output wave form. The output wave form is either a typical PWM signal with its period and duty cycle controlled by the LP-TIMX-ARR and LP-TIMX-CMP registers respectively, or it is a single pulse with the last output state defined by the configured wave form. If the last output state is the same as the one at the wave form's beginning, then one pulse mode is configured. If not, then set once mode is configured. The Low Power Timer's output polarity is controlled through the WavePull bitfield in the LP-TIMX-CFGR register. The Low Power Timer features an encoder mode function that can interface with the incremental quadrature encoder sensors using the peripheral's input 1 and input 2 inputs. Both inputs feature glitch filtering circuitry. The encoder function is similar to the one embedded by the general purpose timers. In order to use the encoder mode function, the Low Power Timer must be running in continuous mode. One important thing to note is that only the Low Power Timer 1 peripheral embeds the encoder mode function. The Low Power Timer 2 peripheral doesn't embed an encoder mode function. The Low Power Timer peripheral features 7 interrupt sources. The Compare Match Interrupt is raised once the content of Counter Register LP-TIMX-CNT matches, or is greater than, the Compare Register LP-TIMX-CMP content. The Auto Reload Match Interrupt is raised when the Counter Register's content matches the Auto Reload Register's content. The External Trigger event interrupt is raised when a valid external trigger is detected. The Auto Reload Register write completed and the Compare Register write completed interrupts are raised when the transfer of the content from the LP-TIMX-ARR register and LP-TIMX-CMP register, respectively, is completed from the peripheral's APB interface logic into the peripheral's core logic which are contained by two different clock domains. These two interrupts are useful in migrating the overhead of polling on the status of writing to these two registers when the peripheral core clock is too slow compared to the APB interface clock. The up and down direction change interrupts are raised when the encoder mode function is enabled and the counting direction is changed from up to down or vice versa. The counting direction of the low power timer's counter reflects the rotation direction of the quadrature's sensor. The low power timer peripheral is active in the following low power modes, Run, Sleep, Low Power Run, Low Power Sleep, Stop 0, Stop 1 and Stop 2. The low power timer is able to wake up the microcontroller from either Sleep, Low Power Sleep, Stop 0, Stop 1 or Stop 2 modes.