The Tool Desk
Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Use input capture to measure signal edges, PWM to generate a repeating waveform, and one-pulse mode (OPM) to stop a timer after a triggered pulse sequence. These are different timer functions: OPM controls when the counter stops; an output-compare mode such as PWM defines the output waveform. The timer features, clock routing, trigger connections, and pin assignments vary by STM32 family and timer instance, so check the exact MCU reference manual and pin alternate-function table before applying a configuration.
Choose the timer function that matches the job
| Goal | Timer function | What it does |
|---|---|---|
| Measure an incoming signal | Input capture | Latches a counter value when a selected input edge occurs; use captured timestamps to calculate period, frequency, or pulse width. |
| Generate a repeating waveform | PWM output compare | Compares the counter with ARR and CCRx to set the period and duty cycle, then repeats while the timer runs. |
| Generate a triggered, bounded waveform | OPM plus output compare/PWM | Starts in response to a configured trigger and clears the counter enable at an update event, allowing an output waveform to stop after a pulse or configured sequence. |
ST describes input capture, output compare, PWM, and one-pulse mode as distinct general-purpose timer functions in its AN4013 timer overview. OPM is not itself a substitute for PWM: combine it with an output channel when the timer must drive a pulse. The trigger and output channel must both be supported and correctly routed by the selected timer.
Calculate the timer clock before choosing register values
Timer timing follows the timer’s actual input clock, prescaler, counting mode, and counter values—not automatically the CPU core clock. Clock-tree rules differ among STM32 families, so identify the clock feeding the particular timer in the MCU’s clock documentation before calculating a period.
For a basic up-counting timer, the counter frequency is fCNT = fTIM / (PSC + 1). With edge-aligned counting from zero through ARR, one PWM period spans ARR + 1 counter ticks, so period = (ARR + 1) / fCNT and frequency = fCNT / (ARR + 1). These expressions assume that the timer is configured for that basic up-counting arrangement; center-aligned modes and timer-specific behavior need their own interpretation.
Windows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallCrashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minute#1 Best Overall
- Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
- Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
- Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
- Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
- 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.
In ordinary PWM operation, ARR sets the count range and CCRx sets the compare point that determines the active portion of the cycle. In a common edge-aligned, up-counting PWM setup, the approximate duty ratio is CCRx / (ARR + 1), subject to the selected PWM mode, output polarity, and endpoint behavior. Check the chosen timer’s reference manual for the exact behavior at boundary values.
For example, ST’s AN4776 uses a 1 MHz counter clock in an STM32F302 example. That is an example configuration, not a default STM32 timer clock or a value to copy to another MCU.
Rank #2
- 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
- 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
- Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
- 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
- What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.
Configure a continuous PWM output
A reliable setup order is to establish the clock and timing first, then configure the channel and enable the timer. ST’s AN4013 setup sequence covers the period in ARR, duty-cycle compare in CCRx, PWM mode and polarity, preload, counting mode, channel enable, and counter enable.
- Confirm the hardware route. Select a timer instance and channel supported by the target MCU, then confirm the chosen package pin has that channel’s alternate function. Check whether the desired output polarity and any complementary output are available on that timer.
- Find the timer input clock. Use the target part’s clock-tree documentation to determine
fTIM; do not assume it equals the core clock. - Choose the counter rate and prescaler. Set PSC to divide the timer input clock to a counter rate that gives sufficient timing resolution and a practical ARR range.
- Choose the counting mode and period. For basic edge-aligned up-counting, calculate ARR from the desired frequency using
ARR = fCNT / fPWM - 1, then check that the value fits the timer’s counter width. Center-aligned counting changes the relationship between the count range and waveform period. - Set duty and output behavior. Program CCRx for the desired compare point, select PWM mode and output polarity, and enable the channel. The pin’s electrical active level depends on polarity as well as the selected PWM mode.
- Consider preload before runtime updates. Preload can keep period or compare changes from taking effect partway through a cycle. Follow the reference manual’s rules for transferring buffered values at update events.
- Enable the channel and counter. Set the relevant capture-compare enable and counter-enable controls, then verify the signal at the configured pin.
The exact register sequence and HAL calls depend on the MCU, timer, and software package. ST’s STM32C5xx HAL TIM documentation, version 2.0.0, describes that HAL’s timer API and usage for the C5xx series; it should not be treated as a universal HAL reference for every STM32 family. For direct register setup or another HAL family, use documentation for the target device and package.
Free tools Windows power users keep installed
One-click scans. No signup required.
Rank #3
- Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
- Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
- Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
- Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
- What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.
Use OPM for a triggered pulse
In triggered OPM, one timer input or routed trigger starts the counter, while an output channel generates the waveform. Configure the output compare channel for PWM1 or PWM2, set the delay and pulse width through the appropriate compare and auto-reload values, and enable OPM so the counter stops when the relevant update event occurs. ST’s AN4013 gives a register-level sequence and timing expressions for its described configuration; AN4776 explains OPM behavior and update-event considerations. Treat these as configuration examples, not family-neutral register recipes.
- Select a valid trigger path. Choose an input or internal trigger supported by the timer’s slave-mode controller, and configure the trigger routing and slave trigger mode for that timer.
- Configure the output channel. Set the chosen channel to PWM1 or PWM2, configure polarity, and assign its output to the intended alternate-function pin.
- Program the timing. Use the timer’s counter clock and prescaler to convert the required delay and pulse width into counter ticks. Set the compare and auto-reload values according to the chosen PWM mode and the timer’s documented counting behavior.
- Enable one-pulse behavior and check update handling. Configure OPM and ensure update events are not masked in a way that prevents the expected stop behavior. Update-event handling affects when the counter stops and how buffered values transfer.
- Arm and test the trigger. Enable the relevant output and timer controls in the order required by the device, apply the trigger, and confirm the output timing at the pin.
For a device-specific example, ST’s STM32G4 RM0440 reference manual specifies the pre-trigger OPM condition CNT < CCRx ≤ ARR, including a nonzero CCRx. This is an STM32G4 constraint from that manual, not a universal rule for all STM32 timers. Check the corresponding section of the exact target part’s reference manual before selecting compare values.
Rank #4
- Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
- Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
- Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
- Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
- Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft
Measure a signal with input capture
Input capture records the timer counter when a configured edge arrives at a channel. To measure period, capture timestamps on successive like edges and subtract them, accounting for counter rollover. To measure high time, capture a rising edge and the following falling edge; to calculate duty cycle, compare that high time with the period measured across matching edges.
- Route the input. Verify the timer channel and pin alternate function, then configure the input polarity and any input filtering or prescaling appropriate to the signal.
- Set the timer time base. Choose the input clock and prescaler to balance resolution against the maximum interval that can be measured before rollover.
- Capture the required edges. Configure a channel for the needed edge or edges. If separate captures or channels are used for opposite edges, confirm that arrangement is supported by the timer.
- Calculate elapsed ticks. Subtract the earlier captured count from the later one. For a single rollover on an up-counter with ARR as its top value, the elapsed ticks are
(ARR + 1 - earlier) + later; if no rollover occurred, uselater - earlier. Handle multiple rollovers separately if the event interval can exceed one counter cycle. - Convert ticks to time. Divide elapsed ticks by the configured counter frequency. Frequency is the reciprocal of the measured period, and duty percentage is
high time / period × 100.
Very short or irregular signals may require input filtering, overflow accounting, or interrupt/DMA handling, depending on the required measurement rate and timer capability. Check the exact timer’s capture, filtering, and channel-routing limits in its reference manual.
Best Value
- 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
- Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
- Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
- HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
- What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.
Generate a finite train of pulses
Some STM32 timers can use a repetition counter with OPM to produce a finite pulse train. In the N-pulse method described by ST’s AN4776, the repetition count is set to N − 1; update-event handling is part of the method. Repetition counters are not present on every timer peripheral, so first confirm that the selected timer has one and follow the family-specific instructions. Do not assume that setting OPM alone will produce an arbitrary number of pulses.
Quick Recap
Check compatibility before adopting a configuration
- Timer features: Confirm counter width, channel count, repetition-counter availability, complementary outputs, and synchronization features for the exact timer instance.
- Trigger routing: Verify that the desired trigger source can reach that timer and that the selected slave mode is supported.
- Clock and range: Check the timer input clock, prescaler range, ARR/CCRx range, and whether the required timing resolution fits the counter.
- Counting and update behavior: Distinguish edge-aligned from center-aligned operation, and confirm how preload and update events affect the output and OPM stop point.
- Pin and polarity: Check the package-specific alternate-function table and configure active-high or active-low behavior as required by the connected circuit.
- Software layer: Use the reference manual and HAL documentation for the selected STM32 family; examples from another series may use different timer features, labels, or clock assumptions.
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

