{"id":3603,"date":"2025-07-05T13:50:50","date_gmt":"2025-07-05T13:50:50","guid":{"rendered":"https:\/\/blog.embeddedexpert.io\/?p=3603"},"modified":"2025-07-05T13:50:52","modified_gmt":"2025-07-05T13:50:52","slug":"stm32-adc-application-part-6-external-trigger-using-timers","status":"publish","type":"post","link":"https:\/\/blog.embeddedexpert.io\/?p=3603","title":{"rendered":"STM32 ADC Application Part 6: External Trigger Using Timers"},"content":{"rendered":"\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"1024\" src=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/07\/ChatGPT-Image-Jul-5-2025-at-04_13_08-PM.png\" alt=\"\" class=\"wp-image-3604\" srcset=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/07\/ChatGPT-Image-Jul-5-2025-at-04_13_08-PM.png 1024w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/07\/ChatGPT-Image-Jul-5-2025-at-04_13_08-PM-300x300.png 300w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/07\/ChatGPT-Image-Jul-5-2025-at-04_13_08-PM-150x150.png 150w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/07\/ChatGPT-Image-Jul-5-2025-at-04_13_08-PM-768x768.png 768w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/07\/ChatGPT-Image-Jul-5-2025-at-04_13_08-PM-750x750.png 750w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/07\/ChatGPT-Image-Jul-5-2025-at-04_13_08-PM-400x400.png 400w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/07\/ChatGPT-Image-Jul-5-2025-at-04_13_08-PM-250x250.png 250w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<p>In this part of the STM32 ADC series, we explore how to use\u00a0<strong>external triggers from timers<\/strong>\u00a0to start ADC conversions automatically. This method enables precise and periodic sampling synchronized with timer events, ideal for real-time control, signal acquisition, and deterministic sampling applications.<\/p>\n\n\n\n<p><\/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>STM32CubeIDE setup.<\/li>\n\n\n\n<li>Firmware development.<\/li>\n\n\n\n<li>Results.<\/li>\n<\/ul>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">1. Introduction:<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\"> Introduction to ADC External Trigger Using Timer in STM32<\/h3>\n\n\n\n<p>In embedded systems, precise and deterministic sampling of analog signals is essential for real-time monitoring, control, and signal processing. Relying on software-triggered ADC conversions introduces uncertainties due to variable software execution times and interrupt latencies, especially in multitasking environments. To overcome this, STM32 microcontrollers offer the capability to use&nbsp;<strong>external triggers<\/strong>, particularly from&nbsp;<strong>internal timers<\/strong>, to initiate ADC conversions at exact intervals with minimal jitter.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">What is an External Trigger?<\/h4>\n\n\n\n<p>An&nbsp;<strong>external trigger<\/strong>&nbsp;for ADC is a hardware event or signal that instructs the ADC to start a conversion without CPU intervention. While \u201cexternal\u201d often refers to external pins, STM32 also allows internal peripherals, such as timers, to act as trigger sources. This mechanism is invaluable in applications requiring:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Periodic sampling<\/strong>\u00a0at fixed frequencies (e.g. data loggers, sensor acquisition).<\/li>\n\n\n\n<li><strong>Synchronized sampling<\/strong>\u00a0with PWM signals in motor control and power conversion systems.<\/li>\n\n\n\n<li><strong>Real-time signal processing<\/strong>, where sampling period consistency directly affects accuracy (e.g. FFT or digital filters).<\/li>\n\n\n\n<li><strong>Reduced CPU load<\/strong>, since timers autonomously generate the trigger without software polling or manual triggering.<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">How Does Timer Trigger Work?<\/h4>\n\n\n\n<p>When configured, a&nbsp;<strong>timer output event<\/strong>&nbsp;(such as an update event, compare match, or PWM edge) is routed internally as the ADC\u2019s external trigger input. Upon receiving this event, the ADC immediately begins its sampling and conversion process. The timer continues counting based on its configuration, generating periodic triggers at precise intervals determined by the system clock and timer prescaler settings.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Key Benefits<\/h4>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Deterministic Sampling Interval<\/strong>: Hardware triggers ensure each ADC conversion starts at exactly the intended time, essential for time-domain signal integrity.<\/li>\n\n\n\n<li><strong>Minimal Jitter<\/strong>: Unlike software-triggered conversions, timer-based triggering has negligible timing jitter, improving measurement accuracy.<\/li>\n\n\n\n<li><strong>Offloading the CPU<\/strong>: The CPU does not need to manage conversion timing manually, freeing it for data processing or other tasks.<\/li>\n\n\n\n<li><strong>Synchronization with Other Peripherals<\/strong>: In motor control, the ADC can sample current precisely aligned with PWM cycles to implement effective closed-loop control.<\/li>\n<\/ol>\n\n\n\n<h4 class=\"wp-block-heading\">Practical Example Applications<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Motor Control (FOC, BLDC)<\/strong>: Sampling phase currents synchronised to PWM cycles.<\/li>\n\n\n\n<li><strong>Digital Oscilloscope or Data Logger<\/strong>: Acquiring voltage signals at uniform sample rates for plotting or storage.<\/li>\n\n\n\n<li><strong>Power Monitoring<\/strong>: Sampling voltage and current waveforms synchronised with grid frequency or inverter switching.<\/li>\n<\/ul>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">2. STM32CubeIDE Setup:<\/h2>\n\n\n\n<p>Once you started a new project, enable ADC CH1 as follows:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>IN1 as single ended (Not all STM32 MCUs have this feature).<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"762\" src=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/07\/2025-07-05_16-19-01-1024x762.jpg\" alt=\"\" class=\"wp-image-3605\" srcset=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/07\/2025-07-05_16-19-01-1024x762.jpg 1024w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/07\/2025-07-05_16-19-01-300x223.jpg 300w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/07\/2025-07-05_16-19-01-768x571.jpg 768w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/07\/2025-07-05_16-19-01-1536x1143.jpg 1536w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/07\/2025-07-05_16-19-01-1150x856.jpg 1150w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/07\/2025-07-05_16-19-01-750x558.jpg 750w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/07\/2025-07-05_16-19-01-400x298.jpg 400w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/07\/2025-07-05_16-19-01-250x186.jpg 250w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/07\/2025-07-05_16-19-01.jpg 1688w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<p>Next, in Parameters Settings:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Set DMA Continuous Requests to Enabled.<\/li>\n\n\n\n<li>External Trigger Conversion Source to Timer 3 Trigger Out event.<\/li>\n\n\n\n<li>External Trigger Edge to rising edge. <\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"816\" height=\"1024\" src=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/07\/2025-07-05_16-20-59-816x1024.jpg\" alt=\"\" class=\"wp-image-3606\" srcset=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/07\/2025-07-05_16-20-59-816x1024.jpg 816w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/07\/2025-07-05_16-20-59-239x300.jpg 239w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/07\/2025-07-05_16-20-59-768x963.jpg 768w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/07\/2025-07-05_16-20-59-750x941.jpg 750w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/07\/2025-07-05_16-20-59-400x502.jpg 400w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/07\/2025-07-05_16-20-59-250x314.jpg 250w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/07\/2025-07-05_16-20-59.jpg 1124w\" sizes=\"(max-width: 816px) 100vw, 816px\" \/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<p>Note: In case you have selected capture compare event, select the edge to be both, rising and falling edge.<\/p>\n\n\n\n<p>Next, DMA Settings tab, configure the DMA as follows:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Add DMA for ADC1.<\/li>\n\n\n\n<li>Set the mode to Circular.<\/li>\n\n\n\n<li>Data Width to half word (16-bit).<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"675\" src=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/07\/2025-07-05_16-25-42-1024x675.jpg\" alt=\"\" class=\"wp-image-3607\" srcset=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/07\/2025-07-05_16-25-42-1024x675.jpg 1024w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/07\/2025-07-05_16-25-42-300x198.jpg 300w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/07\/2025-07-05_16-25-42-768x506.jpg 768w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/07\/2025-07-05_16-25-42-1150x758.jpg 1150w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/07\/2025-07-05_16-25-42-750x494.jpg 750w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/07\/2025-07-05_16-25-42-400x264.jpg 400w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/07\/2025-07-05_16-25-42-250x165.jpg 250w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/07\/2025-07-05_16-25-42.jpg 1514w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<p>Next, before we configure the timer, we need to find the timer frequency, from Clock Configuration:<\/p>\n\n\n\n<p>Note the APB1 and APB2 timer clocks, in this case is 8MHz since the default frequency for STM32F303 is 8MHz.<\/p>\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=\"432\" src=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/07\/2025-07-05_16-27-36-1024x432.jpg\" alt=\"\" class=\"wp-image-3608\" srcset=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/07\/2025-07-05_16-27-36-1024x432.jpg 1024w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/07\/2025-07-05_16-27-36-300x127.jpg 300w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/07\/2025-07-05_16-27-36-768x324.jpg 768w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/07\/2025-07-05_16-27-36-1536x648.jpg 1536w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/07\/2025-07-05_16-27-36-2048x864.jpg 2048w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/07\/2025-07-05_16-27-36-1150x485.jpg 1150w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/07\/2025-07-05_16-27-36-750x316.jpg 750w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/07\/2025-07-05_16-27-36-400x169.jpg 400w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/07\/2025-07-05_16-27-36-250x105.jpg 250w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<p>Next, we shall configure TIM3 as follows:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Clock Source to Internal Clock.<\/li>\n\n\n\n<li>Prescaler to 8-1 (The timer now is operating at 1MHz).<\/li>\n\n\n\n<li>Counter Period to 100-1. The timer shall overflow each 100uS.<\/li>\n\n\n\n<li>Set Trigger event Selection to Update Event.<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"951\" src=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/07\/2025-07-05_16-30-20-1024x951.jpg\" alt=\"\" class=\"wp-image-3609\" srcset=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/07\/2025-07-05_16-30-20-1024x951.jpg 1024w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/07\/2025-07-05_16-30-20-300x279.jpg 300w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/07\/2025-07-05_16-30-20-768x713.jpg 768w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/07\/2025-07-05_16-30-20-1536x1426.jpg 1536w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/07\/2025-07-05_16-30-20-1150x1068.jpg 1150w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/07\/2025-07-05_16-30-20-750x696.jpg 750w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/07\/2025-07-05_16-30-20-400x371.jpg 400w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/07\/2025-07-05_16-30-20-250x232.jpg 250w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/07\/2025-07-05_16-30-20.jpg 2040w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<p>In case you have select capture compare event:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Set the required channel to Output Compare No Output.<\/li>\n\n\n\n<li>Trigger Event Selection to Output Compare (OCxREF), where x is the channel number.<\/li>\n\n\n\n<li>Set channel mode to be Toggle on Match.<\/li>\n<\/ul>\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=\"1009\" src=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/07\/2025-07-05_16-36-34-1024x1009.jpg\" alt=\"\" class=\"wp-image-3611\" srcset=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/07\/2025-07-05_16-36-34-1024x1009.jpg 1024w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/07\/2025-07-05_16-36-34-300x296.jpg 300w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/07\/2025-07-05_16-36-34-768x757.jpg 768w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/07\/2025-07-05_16-36-34-1536x1513.jpg 1536w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/07\/2025-07-05_16-36-34-1150x1133.jpg 1150w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/07\/2025-07-05_16-36-34-750x739.jpg 750w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/07\/2025-07-05_16-36-34-400x394.jpg 400w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/07\/2025-07-05_16-36-34-250x246.jpg 250w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/07\/2025-07-05_16-36-34.jpg 2046w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<p>Also, enable any pin as GPIO output (Here we are using PA5):<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"755\" src=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/07\/2025-07-05_16-39-39-1024x755.jpg\" alt=\"\" class=\"wp-image-3612\" srcset=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/07\/2025-07-05_16-39-39-1024x755.jpg 1024w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/07\/2025-07-05_16-39-39-300x221.jpg 300w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/07\/2025-07-05_16-39-39-768x566.jpg 768w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/07\/2025-07-05_16-39-39-1536x1133.jpg 1536w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/07\/2025-07-05_16-39-39-1150x848.jpg 1150w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/07\/2025-07-05_16-39-39-750x553.jpg 750w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/07\/2025-07-05_16-39-39-400x295.jpg 400w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/07\/2025-07-05_16-39-39-250x184.jpg 250w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/07\/2025-07-05_16-39-39.jpg 1562w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>Thats all for the configuration. Save the project and this will generate the project.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">3. Firmware Development:<\/h2>\n\n\n\n<p>After the code has been generated, main.c will be opened.<\/p>\n\n\n\n<p>In main.c in user code begin PV, declare the following variable to hold the ADC value as follows:<br><\/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;}\">uint16_t ADC_VAL[1];<\/pre><\/div>\n\n\n\n<p><\/p>\n\n\n\n<p>In user code begin 0, declare the following function:<\/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;}\">void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef *hadc)\n{\n  HAL_GPIO_TogglePin(GPIOA, GPIO_PIN_5);\n}<\/pre><\/div>\n\n\n\n<p>This function shall be called every time ADC finishes conversion.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>In user code begin 2, start the ADC in DMA mode and the timer in base 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_Base_Start(&amp;htim3);\n  HAL_ADC_Start_DMA(&amp;hadc1, (uint32_t)&amp;ADC_VAL, 1);<\/pre><\/div>\n\n\n\n<p><\/p>\n\n\n\n<p>Thats all for the firmware, save the project and start a debugging session.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"43\" src=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/07\/image-1024x43.png\" alt=\"\" class=\"wp-image-3600\" srcset=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/07\/image-1024x43.png 1024w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/07\/image-300x13.png 300w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/07\/image-768x32.png 768w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/07\/image-1536x65.png 1536w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/07\/image-1150x48.png 1150w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/07\/image-750x31.png 750w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/07\/image-400x17.png 400w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/07\/image-250x10.png 250w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/07\/image.png 2048w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">4. Results:<\/h2>\n\n\n\n<p>By adding ADC_VAL to Live expression, you should get the following:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"800\" height=\"792\" src=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/07\/ezgif-875779c3b5aa18.gif\" alt=\"\" class=\"wp-image-3613\" \/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<p>By probing PA5 or the pin you selected, you should notice 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\/2025\/07\/RigolDS2.png\" alt=\"\" class=\"wp-image-3614\" srcset=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/07\/RigolDS2.png 1024w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/07\/RigolDS2-300x185.png 300w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/07\/RigolDS2-768x473.png 768w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/07\/RigolDS2-750x461.png 750w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/07\/RigolDS2-400x246.png 400w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/07\/RigolDS2-250x154.png 250w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Notice the +width and -width of the signal, they are 100uS. Thats means the ADC is triggered every 100uS which is according to the timer setup.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>Happy coding \ud83d\ude09<\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this part of the STM32 ADC series, we explore how to use\u00a0external triggers from timers\u00a0to start ADC conversions automatically. This method enables precise and periodic sampling synchronized with timer events, ideal for real-time control, signal acquisition, and deterministic sampling applications. In this guide, we shall cover the following: 1. Introduction: Introduction to ADC External [&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-3603","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\/3603"}],"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=3603"}],"version-history":[{"count":1,"href":"https:\/\/blog.embeddedexpert.io\/index.php?rest_route=\/wp\/v2\/posts\/3603\/revisions"}],"predecessor-version":[{"id":3615,"href":"https:\/\/blog.embeddedexpert.io\/index.php?rest_route=\/wp\/v2\/posts\/3603\/revisions\/3615"}],"wp:attachment":[{"href":"https:\/\/blog.embeddedexpert.io\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3603"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.embeddedexpert.io\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3603"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.embeddedexpert.io\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3603"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}