 Hello and welcome to this presentation on the STM32H7 High Resolution Timer. It will cover the main features for managing the complex waveforms required for digital power conversion applications. The STM32H7's HR Timer is a derivative of the STM32F334 version in terms of achievable resolution. Around 2.1 nanoseconds versus 217 picoseconds. Still, it offers the very same features and functionalities and most of the STM32F334 HR Timer ecosystem will be beneficial for better understanding how the timer works. Still, with its 480 MHz input clock, it offers twice the resolution of the STM32H7 general purpose timers. For instance, it is able to generate 14-bit accurate 20 kHz PWM signals and have a frequency resolution of 25 Hz for 100 kHz range PWMs. Even more noticeable compared with a standard timer, it offers a much higher flexibility for building up to 10 complex waveforms, either timing or event driven, given its features and number of manageable IOs. This is not only useful for digital power conversion, digital SMPS, solar converters and motor control, but also for general purpose applications. Although we talk about a single HR Timer, it is actually made up of 6 16-bit counters that can either be used independently or synchronized, each of them having an independent clock prescaler. It is equipped with a total of 24 compare and 10 capture units and can control up to 10 outputs. A large central crossbar unit allows the output pairs to be controlled not only by the related timing unit, for instance Timer A for output CHA1, but also by any external event, the other timing units and or the master timer. A total of 32 set and reset events are available per output. The crossbar is followed by a versatile output management feature able to interface with any kind of gate driver, program the output polarity, the PWM idle and save state levels, insert a dead time and or add a chopper modulation. A hardware burst mode controller facilitates the light load management with a built-in pulse skipping mechanism. It also features an ultra-fast and asynchronous fault protection feature, independent from the system clock. The HR Timer is able to handle 10 external events for dynamically modifying a waveform in addition to 5 fault signals for protecting power stages. The 10 events can be selected among external ones on inputs and internal ones, typically from comparators. The events allow performance of output set and reset to reset the PWM counters or capture external timings. The fault signals are here to protect the power stages and shut down the PWM outputs. The HR Timer is also linked with other timers as well as the DMA, ADC and DAC peripherals via internal interconnections. Let's take a closer look at one of the high resolution timers 5 identical timing units. It is made of a 16-bit up counter with a programmable overflow value to adjust the counting period. Four 16-bit compare units and two 12-bit capture units are linked to this counter, each with interrupt and DMA capability. A compare event is generated when the counter exactly matches the compare value. Several compare events can thus be generated during a single period to have the output set and reset multiple times per PWM cycle. The unit embeds all control features for a pair of outputs. It can eventually operate as an independent timer, yet these outputs can also be controlled by other timers. The up counters can operate in three modes. In continuous mode, also called free running mode, the counter rolls over to zero when it exceeds the value programmed in the period register or restarts counting if it is reset by an external event. This is the most common mode used for fixed frequency converters or for externally synchronized variable frequency converters. In single shot mode, the counter is started by a reset event and it stops when it reaches the period value set in the HR Tim P-E-R-X-R register. Two options are available here. In non-retriggerable mode, the counter reset events are discarded if they occur before the end of the counting phase. Typically, this is to make sure an externally triggered pulse will always have the same pulse width. In retriggerable mode, the counter can be reset at any time. In this case, an externally triggered pulse may have an extended pulse width if it receives multiple triggers closely enough. Each timing unit includes a repetition counter similar to the ones available in standard STM32 timers. It allows offloading of the CPU by decoupling the switching frequency and the interrupt frequency. The counter rollover interrupt can be issued every single, second, third, and up to 256th PWM period. This feature is available both for continuous and single shot modes. In this case, the repetition counter is decreased on each reset event. The crossbar combines the set and reset events to build the output waveforms, regardless of polarity programming. The events may come from the timing unit itself, from other timing units, from the master timer, or from external events. The timing unit contains two crossbar programming registers per output, one defining the set events, the other for reset events. Up to 32 events can be selected simultaneously. This allows building of periodical waveforms with multiple set and reset events per period. The programming registers are shadowed with preload registers, so that the waveforms can be modified on the fly without any risk of having abnormal transient waveforms. In parallel with the compare units, each timer also embeds two capture units. The capture triggers the transfer from the current counter value into the capture register. This is useful for determining external timings and for the auto-delayed mode discussed on the next slide. Typically, it offers the possibility to measure the effective duty cycle in a cycle by cycle current controlled converter, where the PWM pulse is terminated when the current comparator trips. The capture triggers can be selected from among 28 sources. External events, adjacent timing events, adjacent output waveforms, as well as update and software events. It is possible to simultaneously enable several trigger sources. Half mode is a feature that allows reduction of computational burden when a variable frequency 50% duty cycle PWM waveform must be generated. This is typically the case for resonant converters where the operating frequency is continuously adjusted by the control loop while the duty cycle must be maintained at 50%. The half mode operating principle is to have a right access to the period register triggering a computation and an update of the compare one register to half the value of the period. Let's consider a PWM signal set on the period event and reset on a compare one match. As soon as a new period value is written into the period register, the compare one value is also updated to the period two value, so that the output set event will still happen right in the middle of the PWM waveform. This is particularly useful for continuous mode fixed frequency operation, but it can be used in any other mode as long as the period register needs to be accessed. Auto delayed mode offers the possibility to have set and reset timings referenced to external events and not only related to the internal time base. Still a timeout mechanism can ensure a default waveform when the external event is not present or disappears. This HR timer computes a new compare value on the fly based on external event arrival time captured in a register as soon as the event arrives. The delay versus the expected event is programmed in the compare register, but the compare event is inhibited until the capture is triggered. When the timeout safety mechanism is enabled, the capture is forced when the counter equals the timeout threshold defined in the compare one or the compare three value. A new capture is possible once the auto delayed event has happened or when a new period starts. This slide gives a practical use case of auto delayed mode. The requirement is to build a waveform as follows. The output must be set on a compare one match with a fixed timing versus the counter start value. Here two clock cycles. The output must be reset five cycles after the external event falling edge. The output set occurs when the counter is equal to two and matches the HR TIM CMP1R register value. The HR TIM CMP2R register value is equal to five but is ignored until the external event falling edge occurs. The current counter value is seven. It is captured in the HR TIM CPT1R register and added to the HR TIM CMP2R preload value. This yields an effective compare two value of five plus seven equals twelve. When the counter matches this compare two value, the output reset event is finally generated. Five cycles after the external event falling edge. The uncertainty of 0.5 cycle in the figure is the normal latency due to the capture signal resynchronization. The HR TIMers push-pull mode simplifies the management of push-pull and resonant converters. The two outputs of the timing unit are alternatively enabled and put in idle state to maintain the balance between the two PWM outputs. In this figure two identical waveforms are programmed on output one and output two. The push-pull circuitry disables the outputs every two cycles out of phase so that the signals can be built using a single compare value to set the PWM duty cycle. This is also possible without using the push-pull but it would be at the expense of two other compare registers and a larger CPU burden. Finally, it must be noted that it is possible to unbalance the signals and generate asymmetrical waveforms. For instance, a PWM using compare one for output one and a PWM using compare two for output two. A dead time can be inserted after the crossbar to generate quasi-complementary signals on the two outputs of a single reference PWM. This allows safe driving of all topologies based on half bridges including full bridges and three phase inverters by inserting a dead time during which the two power switches are turned off. This avoids any problem of cross conduction and shoot through. The dead time value can be individually adjusted for both the rising and falling edges asymmetrically to handle any kind of driver or propagation delay. For very specific cases, it is even possible to program a negative dead time and have some controlled outputs overlap. The dead time registers are pre-loaded so that the timings can be adapted in real time without any risk of spurious transitions. This is typically used for adaptive control to optimize the converter efficiency. Last, for functional safety purposes, it is optionally possible to right protect the values or the signs of the dead time with specific control bits. The master timer comes with the five timing units using the same architecture. Its programming is simplified since there are no directly associated outputs nor captures auto delayed mode or external events management. The master timer primarily aims at synchronizing the five timing units for converters requiring more than two outputs. The six events from the master, period, compare one to four, and the global synchronization are available on all timing units and can be used to set or reset the outputs or reset the timers. The master timer also holds the counter-enable bits from all timing units. This allows a synchronized start of all timers with a single right access. Last, it embeds the off-chip synchronization logic programming for interfacing with other HR timer instances in case of multiple MCU systems. External events play a key role in the HR timer. They dynamically modify the waveforms typically to implement a cycle-by-cycle current control or to restart the counter following a zero current detection. A set of 10 external events, which can be chosen from among 30 on-chip or off-chip sources, are used to set, reset, or toggle the outputs, reset the counters, and trigger multiple features. Such as the burst mode controller, the capture, and auto-delayed compare, the ADC start of conversion, or some protections. The 10 external events are available for all timing units. While the conditioning, typically the edge sensitivity, is done globally, event per event, a different event filtering scheme can be applied to each timer. The external event conditioning circuitry is a preliminary signal detection stage, which is configured depending on the type of external interface or on the amount of noise and glitches present in the incoming signals. The first stage is a four-to-one multiplexer to select the source, usually an input pin or a built-in comparator. It is followed by the definition of the edge or level sensitivity. It must be noted that when the level sensitive option is chosen, the external events are continuously issued as long as the level is active. Last, a programmable digital filter stage allows removal of spurious transitions, at the cost of a higher response latency due to the filter propagation delay. This feature is available for external events 6 to 10 only. In many cases, an active event coming out of the conditioning stage is not necessarily a valid event. This is typically the case for current feedbacks. The freewheeling diode's recovery current might be a source of spurious overcurrent detection. It is therefore necessary to apply a specific filtering scheme to the external events used in a given timing unit. Three filtering options are proposed. The blanking mode consists of masking the external events during a defined time window, defined within the timing unit itself, or using the other timing units. This is typically the case for leading edge blanking. The windowing mode lets the external events go through only during a specified period of time, again defined within the timing unit itself or using the other timing units. An event postpone mode allows an event to be acknowledged and latched only if it occurs during a given time period and delayed to the end of this period. Each of the 10 HR timer outputs have three configuration bits. The output is enabled using the OEN bit and disabled using the ODIS bits. All bits are grouped in a single register to have the possibility to enable and disable multiple outputs in a single right access. A disable status bit ODS indicates if the output was disabled because of a fault detection. The bottom figure is an overview of the whole output stage for a given timing unit. Following the set-reset crossbar, output 1 and output 2 reference signals can first be altered with the push-pull and dead time insertion unit. In push-pull mode, output 1 and output 2 are alternatively in run or idle state. When dead time is inserted, the output 1 signal serves as a reference to build the quasi-complementary signals, and the output 2 signal is discarded. The burst mode controller allows both outputs to be automatically disabled and re-enabled for a limited period of time. The chopper unit can superimpose a carrier signal on top of the active PWM waveform. Finally, the fault stage can completely disable the output to protect the power switches. The polarity is programmed at the end. The entire HR timer waveform can be programmed by just reasoning in terms of active inactive switches, independently from the external gate driver and or interface sensitivity before the polarity is applied. The chopper unit superimposes a programmable carrier waveform on top of the active PWM signal. A carrier generator is started by the incoming pulse and added to the incoming signal by means of an AND gate. This allows interfacing with isolation transformer drivers without having to add external glue logic. The carrier waveform can be programmed with three parameters. The modulation frequency from 1.56 to 25 MHz, the first pulse length to adjust the settling time, and the duty cycle to set the sustained current. Burst mode operation is commonly used in power converters when operating under light loads. The burst mode controller allows the outputs alternatively in idle and run states by hardware so as to skip some switching periods with a programmable periodicity and length. The burst mode controller can act on multiple timers in parallel. The outputs are disabled simultaneously with a programmable idle state and the possibility to have a dead time inserted upon burst mode entry to avoid any dead time violations. The burst length is programmable as well as the repetition period when the burst mode is enabled in continuous mode. The burst mode can be started on 32 events and it has multiple burst clock options either coming from the timer rollover event or from independent user programmable period based on the 400 MHz clock. In this example, once the burst trigger arrives, the PWM is active for three periods every eight cycles with pulses skipped for five periods. The burst mode controller counter is clocked and incremented on each timer rollover event. The fault management unit shuts down the PWM outputs and asynchronously forces a user defined safety state. A software action is required to rearm the outputs. A total of five fault inputs are available, each with a programmable polarity, enable bit and a digital filter. It is possible to have one fault input acting on multiple timers for converters requiring multiple synchronized outputs. On the other way round, multiple fault inputs can be merged to protect a single timing unit. The faults are coming from several sources, the digital inputs, the built-in comparators for some channels only, and the system errors. The system errors are indicating a chip level abnormal behavior such as a clock security system error, an SRAM parity error, a Cortex M7 core lockup, or a potential brownout condition with the PVD detector. This helps to increase the functional safety level. Last, a global output disable register allows all the outputs to be disabled synchronously in a single right access for an emergency shutdown. The HR timer offers multiple fault protection options. Some are industry standard features. The analog fault uses a comparator. When reaching a user defined threshold, the comparator tripping causes the PWM outputs shut down. In digital fault mode, the system is put in a safe state when receiving a digital fault trigger. For the cases where one of the outputs safe state is active, a dead time can be automatically inserted right after the fault to guarantee a safe transition to the fault state without a dead time violation. The HR timer, however, offers some unique protection features. For LLC converters, the delayed idle maintains the current pulse on the output and the fault state is entered only after it is completed. For the push-pull converters, the balanced idle mode guarantees a perfect balance between the two output pulse widths when a fault is triggered before the converter is actually entering the fault state. The output pulse, which is shortened by the fault, is automatically copied on the alternate output before stopping operation. The HR timer has four ADC triggering channels with two channels per ADC for the regular and the injected sequencers. This allows up to four independent ADC processes in parallel for multiple converters. Each triggering channel has 32 sources, including 5 from the master timer, 5 from external events, and 4 or 5 for each timing unit. It is possible to simultaneously enable multiple sources for a unique trigger when the various trigger instance are clearly defined as is typical in multi-phase converters. Last, the triggering selection registers are preloaded for on-the-fly trigger source updates. The HR timer also offers DAC triggers. This allows the possibility to have the DAC values updated synchronously with the timer update events from the master and the slave timers. This is typically used for peak current mode where the DAC is used as a threshold for a comparator. It allows the new DAC value to be applied right at the beginning of the next switching period. Three DAC triggers are available, and it is possible to have multiple concurrent sources for the same trigger. All HR timer working registers are duplicated with a shadow register. This applies to the period and compare registers and numerous other configuration registers. It allows glitch-free operation when updating multiple registers. The right accesses are done to the preload registers, which are transferred in the active registers when an update event occurs, usually at the beginning of a PWM cycle. Two control bits allow handling of the preload mechanism. A preload-enable bit, preen, in each timer globally enables the register shadowing. The update disable bits, MUDIS and TXUDIS can temporarily suspend the update event for complex HR timer updates or on-the-fly HR timer reconfigurations. Numerous update trigger sources are available within the timer itself from other timers, master or timers A to E, other on-chip sources such as general-purpose timers, or following DMA burst mode. The HR timer is able to generate interrupts from a total of 85 sources. They are dispatched on seven interrupt vectors as follows. One for each timing unit and the master timer, plus one vector dedicated for fault management. The table lists all the sources and gives a brief description of each. The HR timer can also trigger DMA transfers from a total of 77 sources. They are dispatched on six DMA channels, one for each timing unit and the master timer. The table lists all the sources and gives a brief description of each. The DMA can also be used to dynamically reconfigure the HR timer during converter run times. This is done using the DMA burst mode. Once it is triggered, the content of a table in the memory is transferred into the HR timer control and configuration registers. The DMA burst control registers specify the registers to be updated one by one. Once the transfer is completed, a global register update is issued to have the new values transferred from the preload to the active registers. The HR timer peripheral can be active only in run and sleep modes. In stop and standby modes, the HR timer must be disabled. This slide gives a practical use case of the HR timer. It shows how to generate the PWM signals for a triple interleaved converter. Three step down converters are running in parallel with a 120 degree phase shift to minimize the output voltage ripple and to spread the input current demand. They must be synchronized to guarantee a constant phase shift and eventually switch off one phase adjusting the phase shift to 180 degrees. This is done using the master timer. The events generated on master's period compare one and compare two, reset timers A, B, and C respectively. The pulse width on TA1, TB1, and TC1 outputs are then programmed using the compare one register of each of the timing units as per the control loop demand. If we consider the TA1 output, it is built with the output set on master period event output reset on timer A compare one event. The output TB1 is set on master compare one event and reset on timer B compare one event. The output TC1 is set on master compare two event and reset on timer C compare one event. Note that it is very simple to have an ADC trigger issued in the middle of the pulse width using the spare compare registers in each timing unit. The peripherals listed here influence HR timer behavior. Please refer to the corresponding training for more information. Multiple application notes and user manuals are available for the HR timer for the STM32F334. They are partially valid also for the STM32H7 and can help developers better understand how to use the HR timer.