{"id":4245,"date":"2026-02-28T09:45:54","date_gmt":"2026-02-28T09:45:54","guid":{"rendered":"https:\/\/blog.embeddedexpert.io\/?p=4245"},"modified":"2026-02-28T09:45:56","modified_gmt":"2026-02-28T09:45:56","slug":"stm32-timers-applications-one-pulse-mode","status":"publish","type":"post","link":"https:\/\/blog.embeddedexpert.io\/?p=4245","title":{"rendered":"STM32 Timers Applications: One Pulse Mode"},"content":{"rendered":"\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"683\" src=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/02\/ChatGPT-Image-Feb-28-2026-at-12_19_24-PM-1024x683.png\" alt=\"\" class=\"wp-image-4246\" srcset=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/02\/ChatGPT-Image-Feb-28-2026-at-12_19_24-PM-1024x683.png 1024w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/02\/ChatGPT-Image-Feb-28-2026-at-12_19_24-PM-300x200.png 300w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/02\/ChatGPT-Image-Feb-28-2026-at-12_19_24-PM-768x512.png 768w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/02\/ChatGPT-Image-Feb-28-2026-at-12_19_24-PM-1150x767.png 1150w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/02\/ChatGPT-Image-Feb-28-2026-at-12_19_24-PM-750x500.png 750w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/02\/ChatGPT-Image-Feb-28-2026-at-12_19_24-PM-400x267.png 400w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/02\/ChatGPT-Image-Feb-28-2026-at-12_19_24-PM-250x167.png 250w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/02\/ChatGPT-Image-Feb-28-2026-at-12_19_24-PM.png 1536w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>One Pulse Mode (OPM) in STM32 timers allows the generation of a single, precisely timed pulse in response to a trigger event, after which the timer automatically stops. This feature is ideal for applications requiring accurate one-shot signal generation, such as pulse triggering, time-of-flight measurement, ultrasonic bursts, and controlled actuator activation.<\/p>\n\n\n\n<p>In this guide, we shall cover the following:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Introduction.<\/li>\n\n\n\n<li>STM32CubeMX configuration.<\/li>\n\n\n\n<li>Firmware development.<\/li>\n\n\n\n<li>Connection.<\/li>\n\n\n\n<li>Results.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">1. Introduction:<\/h2>\n\n\n\n<p>One Pulse Mode (OPM) in STM32 timers is a specialized operating configuration in which the timer generates a single output pulse in response to a defined trigger event and then automatically halts its counter operation. Unlike continuous PWM or periodic output modes, OPM is designed for deterministic, single-shot timing sequences where exactly one pulse\u2014with precisely controlled delay and duration\u2014is required. Once the pulse is completed, the timer disables itself (CEN bit cleared automatically in hardware), ensuring no unintended repetition occurs unless it is explicitly rearmed by software or retriggered via hardware.<\/p>\n\n\n\n<p>At the architectural level, OPM leverages the STM32 timer\u2019s slave mode controller, trigger controller, and output compare units. A trigger source\u2014internal (e.g., another timer\u2019s TRGO) or external (e.g., TIx input pin)\u2014initiates the counter. The timer then progresses from zero (or a preset value) toward the auto-reload register (ARR), while the capture\/compare register (CCR) defines the pulse transition timing. This allows independent control of:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Pulse delay<\/strong>\u00a0(from trigger event to rising edge)<\/li>\n\n\n\n<li><strong>Pulse width<\/strong>\u00a0(duration between active and inactive transitions)<\/li>\n\n\n\n<li><strong>Polarity<\/strong>\u00a0(active-high or active-low)<\/li>\n<\/ul>\n\n\n\n<p>In advanced-control timers such as TIM1 and TIM8 (STM32F4 family), OPM can also operate with complementary outputs, dead-time insertion, and break functionality, making it suitable for power electronics, gate drive control, and safety-critical pulse generation.<\/p>\n\n\n\n<p>One Pulse Mode is particularly important in systems where timing determinism and resource efficiency are critical. It eliminates the need for software-managed delays or polling loops, thereby reducing CPU overhead and jitter. Because the entire pulse sequence is executed in hardware once triggered, timing accuracy is bounded only by the timer clock resolution. This makes OPM highly suitable for:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Ultrasonic transducer excitation bursts<\/li>\n\n\n\n<li>Laser or strobe triggering<\/li>\n\n\n\n<li>Time-of-flight measurements<\/li>\n\n\n\n<li>Precise actuator control<\/li>\n\n\n\n<li>ADC sampling synchronization<\/li>\n\n\n\n<li>Communication framing pulses<\/li>\n<\/ul>\n\n\n\n<p>From a system design perspective\u2014especially in embedded platforms like STM32F4 where you are already working extensively with timer synchronization and advanced PWM features\u2014OPM becomes a foundational building block for event-driven architectures. It enables clean hardware-based timing chains where one timer event deterministically triggers another, without firmware latency.<\/p>\n\n\n\n<p>In summary, One Pulse Mode transforms the STM32 timer from a periodic waveform generator into a precision event-driven pulse engine. Its hardware-driven execution ensures minimal jitter, high temporal accuracy, and clean synchronization with other peripherals, making it indispensable in advanced embedded control systems.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">2. STM32CubeMX Configuration:<\/h2>\n\n\n\n<p>Open STM32CubeMX as start a new project as follows:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"662\" src=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/11\/2025-11-26_11-04-37-1024x662.jpg\" alt=\"\" class=\"wp-image-3990\" srcset=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/11\/2025-11-26_11-04-37-1024x662.jpg 1024w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/11\/2025-11-26_11-04-37-300x194.jpg 300w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/11\/2025-11-26_11-04-37-768x497.jpg 768w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/11\/2025-11-26_11-04-37-1536x993.jpg 1536w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/11\/2025-11-26_11-04-37-2048x1324.jpg 2048w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/11\/2025-11-26_11-04-37-1150x744.jpg 1150w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/11\/2025-11-26_11-04-37-750x485.jpg 750w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/11\/2025-11-26_11-04-37-400x259.jpg 400w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/11\/2025-11-26_11-04-37-250x162.jpg 250w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Search for your STM32 MCU, select the MCU and click on Start New Project as follows:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"723\" src=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/02\/2026-02-28_11-18-36-1024x723.jpg\" alt=\"\" class=\"wp-image-4247\" srcset=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/02\/2026-02-28_11-18-36-1024x723.jpg 1024w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/02\/2026-02-28_11-18-36-300x212.jpg 300w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/02\/2026-02-28_11-18-36-768x542.jpg 768w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/02\/2026-02-28_11-18-36-1536x1084.jpg 1536w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/02\/2026-02-28_11-18-36-2048x1445.jpg 2048w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/02\/2026-02-28_11-18-36-1150x812.jpg 1150w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/02\/2026-02-28_11-18-36-750x529.jpg 750w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/02\/2026-02-28_11-18-36-400x282.jpg 400w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/02\/2026-02-28_11-18-36-250x176.jpg 250w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<p>Next, from Timers, select TIM1 and configure it as follows:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"616\" src=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/02\/2026-02-28_12-24-56-1024x616.jpg\" alt=\"\" class=\"wp-image-4248\" srcset=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/02\/2026-02-28_12-24-56-1024x616.jpg 1024w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/02\/2026-02-28_12-24-56-300x180.jpg 300w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/02\/2026-02-28_12-24-56-768x462.jpg 768w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/02\/2026-02-28_12-24-56-1536x924.jpg 1536w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/02\/2026-02-28_12-24-56-1150x692.jpg 1150w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/02\/2026-02-28_12-24-56-750x451.jpg 750w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/02\/2026-02-28_12-24-56-400x241.jpg 400w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/02\/2026-02-28_12-24-56-250x150.jpg 250w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/02\/2026-02-28_12-24-56.jpg 1682w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Set Slave Mode to Trigger Mode.<\/li>\n\n\n\n<li>Trigger Source TI2FP2, this will set TIM1_CH2 as trigger source.<\/li>\n\n\n\n<li>Set Channel 1 as PWM generation CH1.<\/li>\n\n\n\n<li>Enable One Pulse Mode.<\/li>\n<\/ul>\n\n\n\n<p>Configure the parameters as follows:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"1016\" src=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/02\/2026-02-28_12-29-02-1024x1016.jpg\" alt=\"\" class=\"wp-image-4249\" srcset=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/02\/2026-02-28_12-29-02-1024x1016.jpg 1024w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/02\/2026-02-28_12-29-02-300x298.jpg 300w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/02\/2026-02-28_12-29-02-150x150.jpg 150w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/02\/2026-02-28_12-29-02-768x762.jpg 768w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/02\/2026-02-28_12-29-02-1150x1141.jpg 1150w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/02\/2026-02-28_12-29-02-750x744.jpg 750w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/02\/2026-02-28_12-29-02-400x397.jpg 400w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/02\/2026-02-28_12-29-02-250x248.jpg 250w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/02\/2026-02-28_12-29-02.jpg 1516w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Prescaller to 0<\/li>\n\n\n\n<li>Counter period to 1000.<\/li>\n\n\n\n<li>Repetition counter to 9, this will generate 10 pulses.<\/li>\n<\/ul>\n\n\n\n<p>For PWM Generation CH1:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>set Mode to PWM mode 1.<\/li>\n\n\n\n<li>Pulse to 500-1.<\/li>\n\n\n\n<li>CH Polarity to Low.<\/li>\n<\/ul>\n\n\n\n<p>Next, set PA5 as output as follows:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"963\" src=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/02\/2026-02-28_12-32-25-1024x963.jpg\" alt=\"\" class=\"wp-image-4250\" srcset=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/02\/2026-02-28_12-32-25-1024x963.jpg 1024w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/02\/2026-02-28_12-32-25-300x282.jpg 300w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/02\/2026-02-28_12-32-25-768x722.jpg 768w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/02\/2026-02-28_12-32-25-1536x1444.jpg 1536w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/02\/2026-02-28_12-32-25-1150x1081.jpg 1150w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/02\/2026-02-28_12-32-25-750x705.jpg 750w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/02\/2026-02-28_12-32-25-400x376.jpg 400w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/02\/2026-02-28_12-32-25-250x235.jpg 250w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/02\/2026-02-28_12-32-25.jpg 1604w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>From Project Manager:<\/p>\n\n\n\n<p>Give the project a name, set the location, set toolchain\/IDE to STM32CubeIDE and click on Generate Code.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"662\" src=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/02\/2026-02-28_11-29-52-1024x662.jpg\" alt=\"\" class=\"wp-image-4251\" srcset=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/02\/2026-02-28_11-29-52-1024x662.jpg 1024w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/02\/2026-02-28_11-29-52-300x194.jpg 300w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/02\/2026-02-28_11-29-52-768x497.jpg 768w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/02\/2026-02-28_11-29-52-1536x993.jpg 1536w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/02\/2026-02-28_11-29-52-2048x1324.jpg 2048w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/02\/2026-02-28_11-29-52-1150x744.jpg 1150w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/02\/2026-02-28_11-29-52-750x485.jpg 750w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/02\/2026-02-28_11-29-52-400x259.jpg 400w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/02\/2026-02-28_11-29-52-250x162.jpg 250w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">3. Firmware Development<\/h2>\n\n\n\n<p>Open STM32CubeIDE, select your workspace and click on Launch.<\/p>\n\n\n\n<p>From the IDE, click File and select STM32 Project Create\/Import as follows:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"873\" src=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/11\/2025-11-26_16-57-21-1024x873.jpg\" alt=\"\" class=\"wp-image-3997\" srcset=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/11\/2025-11-26_16-57-21-1024x873.jpg 1024w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/11\/2025-11-26_16-57-21-300x256.jpg 300w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/11\/2025-11-26_16-57-21-768x655.jpg 768w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/11\/2025-11-26_16-57-21-1150x981.jpg 1150w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/11\/2025-11-26_16-57-21-750x640.jpg 750w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/11\/2025-11-26_16-57-21-400x341.jpg 400w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/11\/2025-11-26_16-57-21-250x213.jpg 250w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/11\/2025-11-26_16-57-21.jpg 1524w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Next, from Import STM32 Project, select STM32CubeMX\/STM32CubeIDE Project and click on Next as follows:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"769\" src=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/11\/2025-11-26_17-00-37-1024x769.jpg\" alt=\"\" class=\"wp-image-3998\" srcset=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/11\/2025-11-26_17-00-37-1024x769.jpg 1024w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/11\/2025-11-26_17-00-37-300x225.jpg 300w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/11\/2025-11-26_17-00-37-768x577.jpg 768w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/11\/2025-11-26_17-00-37-1150x863.jpg 1150w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/11\/2025-11-26_17-00-37-750x563.jpg 750w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/11\/2025-11-26_17-00-37-400x300.jpg 400w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/11\/2025-11-26_17-00-37-250x188.jpg 250w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/11\/2025-11-26_17-00-37.jpg 1172w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Next, select the folder that contains the .ioc file and click on Finish as follows:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"652\" src=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/12\/2025-12-19_10-21-33-1024x652.jpg\" alt=\"\" class=\"wp-image-4100\" srcset=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/12\/2025-12-19_10-21-33-1024x652.jpg 1024w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/12\/2025-12-19_10-21-33-300x191.jpg 300w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/12\/2025-12-19_10-21-33-768x489.jpg 768w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/12\/2025-12-19_10-21-33-1536x977.jpg 1536w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/12\/2025-12-19_10-21-33-1150x732.jpg 1150w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/12\/2025-12-19_10-21-33-750x477.jpg 750w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/12\/2025-12-19_10-21-33-400x255.jpg 400w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/12\/2025-12-19_10-21-33-250x159.jpg 250w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/12\/2025-12-19_10-21-33.jpg 1760w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<p>Open main.c file for the project.<\/p>\n\n\n\n<p>In user code begin 2 in main function, start the timer in one pulse mode as follows:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;clike&quot;,&quot;mime&quot;:&quot;text\/x-csrc&quot;,&quot;theme&quot;:&quot;dracula&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;C&quot;,&quot;language&quot;:&quot;C&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;c&quot;}\">HAL_TIM_OnePulse_Start(&amp;htim1, TIM_CHANNEL_1);<\/pre><\/div>\n\n\n\n<p><\/p>\n\n\n\n<p>Next, in user code begin 3 in while 1 loop, set PA5 to high and then immediately to Low and wait for 1ms as follows:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;clike&quot;,&quot;mime&quot;:&quot;text\/x-csrc&quot;,&quot;theme&quot;:&quot;dracula&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;C&quot;,&quot;language&quot;:&quot;C&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;c&quot;}\">HAL_GPIO_WritePin(GPIOA, GPIO_PIN_5, GPIO_PIN_SET);\nHAL_GPIO_WritePin(GPIOA, GPIO_PIN_5, GPIO_PIN_RESET);\nHAL_Delay(1);<\/pre><\/div>\n\n\n\n<p>Thats all for the guide, click on run to save the project, build it and flash it as follows:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"37\" src=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/12\/2025-12-17_16-34-38-1024x37.jpg\" alt=\"\" class=\"wp-image-4091\" srcset=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/12\/2025-12-17_16-34-38-1024x37.jpg 1024w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/12\/2025-12-17_16-34-38-300x11.jpg 300w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/12\/2025-12-17_16-34-38-768x28.jpg 768w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/12\/2025-12-17_16-34-38-1536x55.jpg 1536w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/12\/2025-12-17_16-34-38-1150x41.jpg 1150w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/12\/2025-12-17_16-34-38-750x27.jpg 750w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/12\/2025-12-17_16-34-38-400x14.jpg 400w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/12\/2025-12-17_16-34-38-250x9.jpg 250w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/12\/2025-12-17_16-34-38.jpg 1726w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">4. Connection:<\/h2>\n\n\n\n<p><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"852\" src=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/02\/2026-02-28_12-40-05-1024x852.jpg\" alt=\"\" class=\"wp-image-4252\" srcset=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/02\/2026-02-28_12-40-05-1024x852.jpg 1024w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/02\/2026-02-28_12-40-05-300x250.jpg 300w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/02\/2026-02-28_12-40-05-768x639.jpg 768w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/02\/2026-02-28_12-40-05-1536x1278.jpg 1536w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/02\/2026-02-28_12-40-05-1150x957.jpg 1150w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/02\/2026-02-28_12-40-05-750x624.jpg 750w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/02\/2026-02-28_12-40-05-400x333.jpg 400w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/02\/2026-02-28_12-40-05-250x208.jpg 250w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/02\/2026-02-28_12-40-05.jpg 1676w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Connect PA9 to PA5 (D8 to D13 of Arduino pins) and connect PA8 (D7 of Arduino pins) to logic probe.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">5. Results:<\/h2>\n\n\n\n<p><\/p>\n\n\n\n<p>You should get the following:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"630\" src=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/02\/RigolDS6.png\" alt=\"\" class=\"wp-image-4253\" srcset=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/02\/RigolDS6.png 1024w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/02\/RigolDS6-300x185.png 300w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/02\/RigolDS6-768x473.png 768w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/02\/RigolDS6-750x461.png 750w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/02\/RigolDS6-400x246.png 400w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2026\/02\/RigolDS6-250x154.png 250w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>The yellow trace shows PA5, the trigger pin and blue is the PWM output. <\/p>\n\n\n\n<p>The edges are 10 which is expected as we set the repetition to 9.<\/p>\n\n\n\n<p>Feel free to trigger the timer using another timer etc.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>Happy coding \ud83d\ude09 <\/p>\n","protected":false},"excerpt":{"rendered":"<p>One Pulse Mode (OPM) in STM32 timers allows the generation of a single, precisely timed pulse in response to a trigger event, after which the timer automatically stops. This feature is ideal for applications requiring accurate one-shot signal generation, such as pulse triggering, time-of-flight measurement, ultrasonic bursts, and controlled actuator activation. In this guide, we [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2,11,12],"tags":[],"class_list":["post-4245","post","type-post","status-publish","format-standard","hentry","category-embedded-systems","category-peripheral-drivers","category-stm32"],"_links":{"self":[{"href":"https:\/\/blog.embeddedexpert.io\/index.php?rest_route=\/wp\/v2\/posts\/4245"}],"collection":[{"href":"https:\/\/blog.embeddedexpert.io\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.embeddedexpert.io\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.embeddedexpert.io\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.embeddedexpert.io\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4245"}],"version-history":[{"count":1,"href":"https:\/\/blog.embeddedexpert.io\/index.php?rest_route=\/wp\/v2\/posts\/4245\/revisions"}],"predecessor-version":[{"id":4254,"href":"https:\/\/blog.embeddedexpert.io\/index.php?rest_route=\/wp\/v2\/posts\/4245\/revisions\/4254"}],"wp:attachment":[{"href":"https:\/\/blog.embeddedexpert.io\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4245"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.embeddedexpert.io\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4245"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.embeddedexpert.io\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4245"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}