{"id":3409,"date":"2025-04-24T13:52:03","date_gmt":"2025-04-24T13:52:03","guid":{"rendered":"https:\/\/blog.embeddedexpert.io\/?p=3409"},"modified":"2025-04-25T03:09:35","modified_gmt":"2025-04-25T03:09:35","slug":"stm32-adc-application-part-1-adc-in-polling-mode","status":"publish","type":"post","link":"https:\/\/blog.embeddedexpert.io\/?p=3409","title":{"rendered":"STM32 ADC Application Part 1 : ADC in Polling Mode"},"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\/04\/ChatGPT-Image-Apr-24-2025-at-03_55_26-PM.png\" alt=\"\" class=\"wp-image-3410\" srcset=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/04\/ChatGPT-Image-Apr-24-2025-at-03_55_26-PM.png 1024w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/04\/ChatGPT-Image-Apr-24-2025-at-03_55_26-PM-300x300.png 300w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/04\/ChatGPT-Image-Apr-24-2025-at-03_55_26-PM-150x150.png 150w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/04\/ChatGPT-Image-Apr-24-2025-at-03_55_26-PM-768x768.png 768w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/04\/ChatGPT-Image-Apr-24-2025-at-03_55_26-PM-750x750.png 750w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/04\/ChatGPT-Image-Apr-24-2025-at-03_55_26-PM-400x400.png 400w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/04\/ChatGPT-Image-Apr-24-2025-at-03_55_26-PM-250x250.png 250w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Analog-to-Digital Converters (ADC) on STM32 microcontrollers allow precise measurement of analog signals by converting them into digital values for processing. Understanding the different ADC operating modes\u2014such as single, continuous, and discontinuous\u2014is essential for tailoring performance to specific application needs. In part 1, we shall cover the single Conversion Mode<\/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 to ADC.<\/li>\n\n\n\n<li>ADC configuration.<\/li>\n\n\n\n<li>ADC firmware.<\/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 to ADC:<\/h2>\n\n\n\n<h2 class=\"wp-block-heading\">1.1 What is the ADC<\/h2>\n\n\n\n<p>In&nbsp;electronics, an&nbsp;<strong>analog-to-digital converter<\/strong>&nbsp;(<strong>ADC<\/strong>,&nbsp;<strong>A\/D<\/strong>, or&nbsp;<strong>A-to-D<\/strong>) is a system that converts an&nbsp;analog signal, such as a sound picked up by a&nbsp;microphone&nbsp;or light entering a&nbsp;digital camera, into a&nbsp;digital signal that can be read by STM32.&nbsp;<\/p>\n\n\n\n<p>ADCs can vary greatly between microcontroller. The ADC on the STM32F411 is a 12-bit ADC meaning it has the ability to detect 4096(2^12) discrete analog levels (which is also called&nbsp;<strong><em>Resolution<\/em><\/strong>). Some microcontrollers have 8-bit ADCs (2^8 = 256 discrete levels) and some have 16-bit ADCs (2^16 = 65,536 discrete levels).<\/p>\n\n\n\n<p>The way an ADC works is fairly complex. There are a few different ways to achieve this feat (see Wikipedia&nbsp;<a href=\"http:\/\/en.wikipedia.org\/wiki\/Analog-to-digital_converter#ADC_types\">for a list<\/a>), but one of the most common technique uses the analog voltage to charge up an internal capacitor and then measure the time it takes to discharge across an internal resistor. The microcontroller monitors the number of clock cycles that pass before the capacitor is discharged. This number of cycles is the number that is returned once the ADC is complete. Other methods used called Successive-approximation ADC which you can read about it in details from this wikipedia page (<a href=\"https:\/\/en.wikipedia.org\/wiki\/Successive-approximation_ADC\" target=\"_blank\" rel=\"noreferrer noopener\">Link<\/a>)<\/p>\n\n\n\n<p>For more information about how the adc of STM32F4 works, refer to the user manual (RM0383).<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"relating-adc-value-to-voltage\">1.2 Relating ADC Value to Voltage<\/h2>\n\n\n\n<p>The ADC reports a&nbsp;<em>ratio metric value<\/em>. This means that the ADC assumes 3.3V is 4095 and anything less than 3.3V will be a ratio between 3.3V and 4095.<\/p>\n\n\n\n<p>For example if the sensor has output voltage of 1.66V hence the ADC output will be (4095\/3.3)*1.66=2059.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">2. ADC Configuration:<\/h2>\n\n\n\n<p>Create new project and name it as ADC_Polling, STM32CubeMX window shall appear.<\/p>\n\n\n\n<p>In analog from left side, select ADC1 and enable IN1 as single ended as following:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"961\" src=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/04\/2025-04-24_16-14-01-1024x961.jpg\" alt=\"\" class=\"wp-image-3411\" srcset=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/04\/2025-04-24_16-14-01-1024x961.jpg 1024w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/04\/2025-04-24_16-14-01-300x281.jpg 300w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/04\/2025-04-24_16-14-01-768x721.jpg 768w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/04\/2025-04-24_16-14-01-1150x1079.jpg 1150w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/04\/2025-04-24_16-14-01-750x704.jpg 750w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/04\/2025-04-24_16-14-01-400x375.jpg 400w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/04\/2025-04-24_16-14-01-250x235.jpg 250w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/04\/2025-04-24_16-14-01.jpg 1488w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<p>This will enable PA0 as ADC1_IN1. <\/p>\n\n\n\n<p>From parameter settings:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"896\" height=\"920\" src=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/04\/2025-04-24_16-13-46.jpg\" alt=\"\" class=\"wp-image-3412\" srcset=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/04\/2025-04-24_16-13-46.jpg 896w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/04\/2025-04-24_16-13-46-292x300.jpg 292w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/04\/2025-04-24_16-13-46-768x789.jpg 768w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/04\/2025-04-24_16-13-46-750x770.jpg 750w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/04\/2025-04-24_16-13-46-400x411.jpg 400w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/04\/2025-04-24_16-13-46-250x257.jpg 250w\" sizes=\"(max-width: 896px) 100vw, 896px\" \/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">&nbsp;<strong>ADC_Settings<\/strong><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Mode: Independent mode<\/strong><br>The ADC operates independently, not synchronized with another ADC unit (STM32F3 has multiple ADCs that can be run in dual mode).<\/li>\n\n\n\n<li><strong>Clock Prescaler: ADC Asynchronous clock mode<\/strong><br>The ADC uses an asynchronous clock source, independent of the main APB clock, often for better precision and flexibility.<\/li>\n\n\n\n<li><strong>Resolution: ADC 12-bit resolution<\/strong><br>The ADC provides 12-bit digital output, meaning the analog input is quantized into 4096 levels (2\u00b9\u00b2).<\/li>\n\n\n\n<li><strong>Data Alignment: Right alignment<\/strong><br>The digital conversion result is aligned to the right in the 16-bit ADC data register (least significant bits occupied). This will make handling the data easier.<\/li>\n\n\n\n<li><strong>Scan Conversion Mode: Disabled<\/strong><br>Only one channel will be converted; multi-channel scanning is not used.<\/li>\n\n\n\n<li><strong>Continuous Conversion Mode: Disabled<\/strong><br>The ADC performs only one conversion when triggered; does not keep converting continuously.<\/li>\n\n\n\n<li><strong>Discontinuous Conversion Mode: Disabled<\/strong><br>Not applicable here since scanning is disabled. In scan mode, this would group conversions into smaller sequences.<\/li>\n\n\n\n<li><strong>DMA Continuous Requests: Disabled<\/strong><br>DMA is not used to transfer ADC results. Normally used to offload CPU when many conversions are happening.<\/li>\n\n\n\n<li><strong>End Of Conversion Selection: End of single conversion<\/strong><br>The End of Conversion (EOC) flag is set after a single conversion (useful for polling or interrupt triggering).<\/li>\n\n\n\n<li><strong>Overrun Behavior: Overrun data overwritten<\/strong><br>If a new conversion finishes before the previous data was read, the old data is overwritten.<\/li>\n\n\n\n<li><strong>Low Power Auto Wait: Disabled<\/strong><br>The ADC does not wait until the previous data is read before starting a new conversion (can save power in low power mode).<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\" \/>\n\n\n\n<h3 class=\"wp-block-heading\">&nbsp;<strong>ADC_Regular_ConversionMode<\/strong><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Enable Regular Conversion: Enable<\/strong><br>The regular channel conversion (as opposed to injected conversions) is active.<\/li>\n\n\n\n<li><strong>Number Of Conversion: 1<\/strong><br>Only one channel is configured in the regular group (simple case).<\/li>\n\n\n\n<li><strong>External Trigger Conversion: Regular Conversion launched by &#8230;<\/strong><br>(The rest is truncated, but likely &#8220;software&#8221; or &#8220;timer&#8221;)<br>Determines how the ADC is triggered\u2014probably via software in this case.<\/li>\n\n\n\n<li><strong>External Trigger Conversion Edge: None<\/strong><br>No edge detection is enabled for an external trigger\u2014probably meaning software triggering is used.<\/li>\n\n\n\n<li><strong>SequencerNbRanks: 1<\/strong><br>Only one rank (position in sequence) is defined in the conversion sequence.<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\" \/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Channel Configuration<\/strong><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Channel: Channel 1<\/strong><br>The ADC is set to convert analog input on ADC Channel 1 (check pin mapping for which GPIO this corresponds to).<\/li>\n\n\n\n<li><strong>Sampling Time: 1.5 Cycles<\/strong><br>The ADC samples the input signal for 1.5 ADC clock cycles before converting\u2014faster but less accurate with high-impedance sources.<\/li>\n\n\n\n<li><strong>Offset Number: No offset<\/strong><br>No hardware offset correction applied to the measured value.<\/li>\n\n\n\n<li><strong>Offset: 0<\/strong><br>The offset value is 0\u2014so the raw ADC value is used directly.<\/li>\n<\/ul>\n\n\n\n<p>Later in next guides, we shall have deeper look into these configuration and how to use them.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>Save the project this will generate the project.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">3. ADC Firmware Development:<\/h2>\n\n\n\n<p>After the project has been generated, main.c shall be opened.<\/p>\n\n\n\n<p>After the project has been generated, main.c shall be opened.<\/p>\n\n\n\n<p>In main.c, in user code begin PV, declare a variable to hold the ADC results as following:<\/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 adcValue;<\/pre><\/div>\n\n\n\n<p>n while 1 loop in user code begin 3, we shall the ADC as following:<\/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_ADC_Start(&amp;hadc1);<\/pre><\/div>\n\n\n\n<p>The HAL_ADC_Start will start the ADC conversion and take one parameter which is the ADC handle which is hadc1 in this case.<\/p>\n\n\n\n<p>Next, we shall wait for the ADC to finish conversion by polling the ADC as following:<\/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_ADC_PollForConversion(&amp;hadc1, 100);<\/pre><\/div>\n\n\n\n<p>The function HAL_ADC_PollForConversion will wait for the ADC to finish conversion and takes the following:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Handle to the ADC which is hadc1 in this case.<\/li>\n\n\n\n<li>Time out which is the time for the function to timeout and report error which is 100 milliseconds in this case.<\/li>\n<\/ul>\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;}\">adcValue = HAL_ADC_GetValue(&amp;hadc1);<\/pre><\/div>\n\n\n\n<p>The HAL_ADC_GetValue will return the converted ADC results and takes the hadc1 as parameter.<\/p>\n\n\n\n<p>Next, stop the ADC as following:<\/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_ADC_Stop(&amp;hadc1);<\/pre><\/div>\n\n\n\n<p>Hence, the while 1 code as following:<\/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;}\">\tHAL_ADC_Start(&amp;hadc1);\n\tHAL_ADC_PollForConversion(&amp;hadc1, 100);\n\tadcValue = HAL_ADC_GetValue(&amp;hadc1);\n\tHAL_ADC_Stop(&amp;hadc1);<\/pre><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">4. Connection:<\/h2>\n\n\n\n<p>The connection as following:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"757\" src=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/04\/2025-04-25_06-08-00-1024x757.jpg\" alt=\"\" class=\"wp-image-3419\" srcset=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/04\/2025-04-25_06-08-00-1024x757.jpg 1024w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/04\/2025-04-25_06-08-00-300x222.jpg 300w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/04\/2025-04-25_06-08-00-768x568.jpg 768w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/04\/2025-04-25_06-08-00-1536x1135.jpg 1536w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/04\/2025-04-25_06-08-00-2048x1514.jpg 2048w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/04\/2025-04-25_06-08-00-1150x850.jpg 1150w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/04\/2025-04-25_06-08-00-750x554.jpg 750w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/04\/2025-04-25_06-08-00-400x296.jpg 400w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/04\/2025-04-25_06-08-00-250x185.jpg 250w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">5. Results:<\/h2>\n\n\n\n<p>Start a debug session and add adcValue to live expression<\/p>\n\n\n\n<p>When the pot is near the GND wire, you will get zero or near zero value as following:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"40\" src=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/04\/Screenshot-2025-04-24-at-4.41.06\u202fPM-1024x40.png\" alt=\"\" class=\"wp-image-3415\" srcset=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/04\/Screenshot-2025-04-24-at-4.41.06\u202fPM-1024x40.png 1024w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/04\/Screenshot-2025-04-24-at-4.41.06\u202fPM-300x12.png 300w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/04\/Screenshot-2025-04-24-at-4.41.06\u202fPM-768x30.png 768w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/04\/Screenshot-2025-04-24-at-4.41.06\u202fPM-750x30.png 750w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/04\/Screenshot-2025-04-24-at-4.41.06\u202fPM-400x16.png 400w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/04\/Screenshot-2025-04-24-at-4.41.06\u202fPM-250x10.png 250w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/04\/Screenshot-2025-04-24-at-4.41.06\u202fPM.png 1066w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>On the other size of the pot:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"85\" src=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/04\/2025-04-24_16-42-25-1024x85.jpg\" alt=\"\" class=\"wp-image-3416\" srcset=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/04\/2025-04-24_16-42-25-1024x85.jpg 1024w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/04\/2025-04-24_16-42-25-300x25.jpg 300w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/04\/2025-04-24_16-42-25-768x64.jpg 768w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/04\/2025-04-24_16-42-25-750x62.jpg 750w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/04\/2025-04-24_16-42-25-400x33.jpg 400w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/04\/2025-04-24_16-42-25-250x21.jpg 250w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/04\/2025-04-24_16-42-25.jpg 1058w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<p>We have successfully created first ADC drive.<\/p>\n\n\n\n<p>However, this will block the CPU from doing anything during the conversion and getting the results.<\/p>\n\n\n\n<p>This can be solved when interrupt shall be used.<\/p>\n\n\n\n<p>Stay tuned.<\/p>\n\n\n\n<p>Happy coding \ud83d\ude09<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Analog-to-Digital Converters (ADC) on STM32 microcontrollers allow precise measurement of analog signals by converting them into digital values for processing. Understanding the different ADC operating modes\u2014such as single, continuous, and discontinuous\u2014is essential for tailoring performance to specific application needs. In part 1, we shall cover the single Conversion Mode In this guide, we shall cover [&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-3409","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\/3409"}],"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=3409"}],"version-history":[{"count":3,"href":"https:\/\/blog.embeddedexpert.io\/index.php?rest_route=\/wp\/v2\/posts\/3409\/revisions"}],"predecessor-version":[{"id":3420,"href":"https:\/\/blog.embeddedexpert.io\/index.php?rest_route=\/wp\/v2\/posts\/3409\/revisions\/3420"}],"wp:attachment":[{"href":"https:\/\/blog.embeddedexpert.io\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3409"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.embeddedexpert.io\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3409"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.embeddedexpert.io\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3409"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}