{"id":5035,"date":"2020-07-06T19:43:18","date_gmt":"2020-07-06T17:43:18","guid":{"rendered":"https:\/\/deepbluembedded.com\/?p=5035"},"modified":"2023-08-17T23:51:26","modified_gmt":"2023-08-17T20:51:26","slug":"map-function-embedded-c","status":"publish","type":"post","link":"https:\/\/deepbluembedded.com\/map-function-embedded-c\/","title":{"rendered":"Map Function, Constrain, FIR Filters, And Other Math Functions"},"content":{"rendered":"<table style=\"border-collapse: collapse; width: 100%;\" border=\"1\">\n<tbody>\n<tr>\n<td style=\"background-color: #ffffff; width: 5%;\"><a href=\"https:\/\/deepbluembedded.com\/interfacing-7-segment-display-stm32\/\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-1666 alignleft\" src=\"https:\/\/deepbluembedded.com\/wp-content\/uploads\/2018\/06\/play-256L-150x150.png\" alt=\"Previous Tutorial\" width=\"35\" height=\"35\" srcset=\"https:\/\/deepbluembedded.com\/wp-content\/uploads\/2018\/06\/play-256L-150x150.png 150w, https:\/\/deepbluembedded.com\/wp-content\/uploads\/2018\/06\/play-256L-160x160.png 160w, https:\/\/deepbluembedded.com\/wp-content\/uploads\/2018\/06\/play-256L-320x320.png 320w, https:\/\/deepbluembedded.com\/wp-content\/uploads\/2018\/06\/play-256L-50x50.png 50w, https:\/\/deepbluembedded.com\/wp-content\/uploads\/2018\/06\/play-256L.png 256w\" sizes=\"auto, (max-width: 35px) 100vw, 35px\" \/><\/a><\/td>\n<td style=\"background-color: #ffffff; width: 30%; text-align: left;\" colspan=\"2\"><a href=\"https:\/\/deepbluembedded.com\/interfacing-7-segment-display-stm32\/\"><strong>Previous Tutorial<\/strong><\/a><\/td>\n<td style=\"background-color: #ffffff; width: 30%; text-align: center;\" colspan=\"2\"><span style=\"color: #000000;\"><strong><span style=\"font-size: 14pt;\">Tutorial 33<\/span><\/strong><\/span><\/td>\n<td style=\"background-color: #ffffff; width: 30%; text-align: right;\" colspan=\"2\"><a href=\"https:\/\/deepbluembedded.com\/stm32-gpio-leds-buttons-interfacing-driver\/\"><strong>Next Tutorial<\/strong><\/a><\/td>\n<td style=\"background-color: #ffffff; width: 5%;\"><a href=\"https:\/\/deepbluembedded.com\/stm32-gpio-leds-buttons-interfacing-driver\/\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-1667 alignright\" src=\"https:\/\/deepbluembedded.com\/wp-content\/uploads\/2018\/06\/play-256-150x150.png\" alt=\"Next Tutorial\" width=\"35\" height=\"35\" srcset=\"https:\/\/deepbluembedded.com\/wp-content\/uploads\/2018\/06\/play-256-150x150.png 150w, https:\/\/deepbluembedded.com\/wp-content\/uploads\/2018\/06\/play-256-160x160.png 160w, https:\/\/deepbluembedded.com\/wp-content\/uploads\/2018\/06\/play-256-320x320.png 320w, https:\/\/deepbluembedded.com\/wp-content\/uploads\/2018\/06\/play-256-50x50.png 50w, https:\/\/deepbluembedded.com\/wp-content\/uploads\/2018\/06\/play-256.png 256w\" sizes=\"auto, (max-width: 35px) 100vw, 35px\" \/><\/a><\/td>\n<\/tr>\n<tr>\n<td style=\"background-color: #ffffff; width: 5%;\"><\/td>\n<td style=\"background-color: #ffffff; text-align: center;\" colspan=\"6\"><span style=\"font-size: 14pt;\"><strong>Map Function, Constrain, FIR Filters, And Other Math Functions<\/strong><\/span><\/td>\n<td style=\"background-color: #ffffff; width: 5%;\"><\/td>\n<\/tr>\n<tr>\n<td style=\"background-color: #ffffff; width: 5%;\"><\/td>\n<td style=\"width: 20%; background-color: #ffffff; text-align: center;\" colspan=\"6\"><a href=\"https:\/\/deepbluembedded.com\/stm32-arm-programming-tutorials\/#_STM32_Course_Table_OF_Contents\"><span style=\"font-size: 10pt;\"><strong>STM32 Course Home Page <\/strong><\/span>????<\/a><\/td>\n<td style=\"background-color: #ffffff; width: 5%;\"><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-5043\" src=\"https:\/\/deepbluembedded.com\/wp-content\/uploads\/2020\/07\/Map-Function-Constrain-And-Moving-Averge-Filters-and-MATH.jpg\" alt=\"Map Function, Constrain, And Moving Averge Filters and MATH\" width=\"720\" height=\"340\" srcset=\"https:\/\/deepbluembedded.com\/wp-content\/uploads\/2020\/07\/Map-Function-Constrain-And-Moving-Averge-Filters-and-MATH.jpg 720w, https:\/\/deepbluembedded.com\/wp-content\/uploads\/2020\/07\/Map-Function-Constrain-And-Moving-Averge-Filters-and-MATH-300x142.jpg 300w, https:\/\/deepbluembedded.com\/wp-content\/uploads\/2020\/07\/Map-Function-Constrain-And-Moving-Averge-Filters-and-MATH-520x245.jpg 520w\" sizes=\"auto, (max-width: 720px) 100vw, 720px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: arial, helvetica, sans-serif; color: #000000;\">In this article, we&#8217;ll discuss some <strong>math functions like map function, constrain, digital filtering, and how to implement them in Embedded-C<\/strong>. We&#8217;ll be using these functions in the upcoming tutorials and you&#8217;ll find them in the math directory in the STM32 course repo. So I&#8217;ve decided to briefly mention each of them at least the ones we&#8217;ll be using in the near future. And let&#8217;s dive right in!<\/span><\/p>\n<hr \/>\n<h3 style=\"text-align: left;\"><span style=\"background-color: #333333;\"><strong><span style=\"color: #ffffff;\">\u00a0 \u00a0Map Function &amp; Implementation In C<\/span><\/strong><strong><span style=\"color: #ffffff;\">\u00a0 \u00a0<\/span><\/strong><\/span><\/h3>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: arial, helvetica, sans-serif; color: #000000;\">Let&#8217;s start with the map function which we quite often use in different embedded systems applications. The map function is commonly used as a built-in <a href=\"https:\/\/www.arduino.cc\/\" target=\"_blank\" rel=\"noopener noreferrer\">Arduino<\/a> C function and it&#8217;s very handy in a wide range of applications. Mathematically, the mapping function is to find the corresponding value from a certain domain to another domain. Here is an example of this.<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: arial, helvetica, sans-serif; color: #000000;\">We can use a potentiometer with an ADC to read the analog voltage and if the ADC is 10-Bit in resolution then its digital output is going to be in this range (domain) [0 up to 1023]. If we&#8217;re willing to use this value as a control signal to position a servo motor whose angle has a range (domain) of [0\u00b0 up to 180\u00b0], then we need to do a mapping from the first domain to the second one. As you can see in the diagram below.<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-5038\" src=\"https:\/\/deepbluembedded.com\/wp-content\/uploads\/2020\/07\/Map-function-implementation-in-C-Arduino.jpg\" alt=\"Map function implementation in C - Arduino\" width=\"436\" height=\"344\" srcset=\"https:\/\/deepbluembedded.com\/wp-content\/uploads\/2020\/07\/Map-function-implementation-in-C-Arduino.jpg 436w, https:\/\/deepbluembedded.com\/wp-content\/uploads\/2020\/07\/Map-function-implementation-in-C-Arduino-300x237.jpg 300w\" sizes=\"auto, (max-width: 436px) 100vw, 436px\" \/><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: arial, helvetica, sans-serif; color: #000000;\">The map function does this conversion ting from the ADC result to the servo motor angle. The function will simply figure out the conversion ratio from domain1 to domain2, does the arithmetic, and return the result.<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: arial, helvetica, sans-serif; color: #000000;\">I personally used to do this manually back in the days in process control exams. The procedure was as follows: first of all, I&#8217;ll draw both domains and their ranges on top of each other like in the diagram below. The first one (from 0 up to 1023) and the second one (from 0 up to 180). Then, I take an arbitrarily chosen point (x) which represents the ADC reading at any time instance. And define the goal to be finding out the corresponding point (y) in the other domain that maps to the x point.<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: arial, helvetica, sans-serif; color: #000000;\">With keeping in mind the fact that the length of the (<span style=\"color: #ff6600;\"><strong>orange<\/strong><\/span>) bars are equal and the ratio between each one of them to its full domain range is also equal. Therefore, x\/1023 = y\/180. Which results in the following equation which we also call the (map function) or equation y=(x.180)\/1023<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-5039\" src=\"https:\/\/deepbluembedded.com\/wp-content\/uploads\/2020\/07\/Map-function-In-Arduino-example-and-explanation-and-implemetnation-in-C-language.jpg\" alt=\"Map function In Arduino example and explanation and implemetnation in C language\" width=\"536\" height=\"302\" srcset=\"https:\/\/deepbluembedded.com\/wp-content\/uploads\/2020\/07\/Map-function-In-Arduino-example-and-explanation-and-implemetnation-in-C-language.jpg 536w, https:\/\/deepbluembedded.com\/wp-content\/uploads\/2020\/07\/Map-function-In-Arduino-example-and-explanation-and-implemetnation-in-C-language-300x169.jpg 300w\" sizes=\"auto, (max-width: 536px) 100vw, 536px\" \/><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: arial, helvetica, sans-serif; color: #000000;\">Here is an implementation for the map function in C language which we&#8217;ll add to our MATH.c source code in the MATH directory. You&#8217;ll find it also in the <a href=\"https:\/\/github.com\/Khaled-Magdy-DeepBlue\/STM32_Course_DeepBlue\" target=\"_blank\" rel=\"noopener noreferrer\">course&#8217;s repo on GitHub<\/a>.<\/span><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"c\">uint32_t MAP(uint32_t au32_IN, uint32_t au32_INmin, uint32_t au32_INmax, uint32_t au32_OUTmin, uint32_t au32_OUTmax)\r\n{\r\n    return ((((au32_IN - au32_INmin)*(au32_OUTmax - au32_OUTmin))\/(au32_INmax - au32_INmin)) + au32_OUTmin);\r\n}<\/pre>\n<p style=\"text-align: justify;\"><span style=\"font-family: arial, helvetica, sans-serif; color: #000000;\">We&#8217;ll implement this example at the end of this article as well. To give you an example application code for how to include and use the MATH functions that we&#8217;ll be implementing today.<\/span><\/p>\n<p>&nbsp;<\/p>\n<hr \/>\n<h3 style=\"text-align: left;\"><span style=\"background-color: #333333;\"><strong><span style=\"color: #ffffff;\">\u00a0 Constrain Function<\/span><\/strong><strong><span style=\"color: #ffffff;\">\u00a0\u00a0<\/span><\/strong><\/span><\/h3>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: arial, helvetica, sans-serif; color: #000000;\">The constrain function is a very simple logical operation. We typically perform this function on sensors&#8217; readings when want to hard-limit or cap the readings of a specific sensor and also define a minimum output value to be accepted by the system. <\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: arial, helvetica, sans-serif; color: #000000;\">Using this function guarantees that any digital controller or calculations performing mathematical operations on a specific sensor&#8217;s reading would not go wrong. As it&#8217;s guaranteed to fall in the specified range by using this function.<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: arial, helvetica, sans-serif; color: #000000;\">Here is a very simple implementation for this function in C language.<\/span><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"c\">uint32_t Constrain(uint32_t au32_IN, uint32_t au32_MIN, uint32_t au32_MAX)\r\n{\r\n    if(au32_IN &lt; au32_MIN)\r\n    {\r\n\treturn au32_MIN;\r\n    }\r\n    else if (au32_IN &gt; au32_MAX)\r\n    {\r\n\treturn au32_MAX;\r\n    }\r\n    else\r\n    {\r\n\treturn au32_IN;\r\n    }\r\n}<\/pre>\n<p>&nbsp;<\/p>\n<hr \/>\n<h3 style=\"text-align: left;\"><span style=\"background-color: #333333;\"><strong><span style=\"color: #ffffff;\">\u00a0 \u00a0Min &amp; Max Functions\u00a0 \u00a0<\/span><\/strong><\/span><\/h3>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: arial, helvetica, sans-serif; color: #000000;\">The min &amp; max functions are commonly used in different applications. And the task required by each of them is very basic and simple. It&#8217;s a searching routine that goes through an array of values to find the maximum or minimum and return it back.<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: arial, helvetica, sans-serif; color: #000000;\">Sometimes you may have a system that records some variables or sensors&#8217; readings and would like to find the maximum or minimum peaks or drops. Or maybe use this information to know if your data needs some sort of digital filtering or not. In case of high spikes in the readings recorded.<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: arial, helvetica, sans-serif; color: #000000;\">Here is an implementation in C for both functions.<\/span><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"c\">MATH_DataType MIN(MATH_DataType* IN_Arr, uint32_t au32_LEN)\r\n{\r\n    uint32_t i = 0;\r\n    MATH_DataType MIN = 0;\r\n\r\n    for(i=0; i&lt;au32_LEN; i++)\r\n    {\r\n\tif(IN_Arr[i] &lt; MIN)\r\n\t{\r\n\t    MIN = IN_Arr[i];\r\n\t}\r\n    }\r\n    return MIN;\r\n}\r\n\r\nMATH_DataType MAX(MATH_DataType* IN_Arr, uint32_t au32_LEN)\r\n{\r\n    uint32_t i = 0;\r\n    MATH_DataType MAX = 0;\r\n\r\n    for(i=0; i&lt;au32_LEN; i++)\r\n    {\r\n\tif(IN_Arr[i] &gt; MAX)\r\n\t{\r\n\t    MAX = IN_Arr[i];\r\n\t}\r\n    }\r\n    return MAX;\r\n}<\/pre>\n<p style=\"text-align: justify;\"><span style=\"font-family: arial, helvetica, sans-serif; color: #000000;\">Note that the data type being used here is defined so that the user (the programmer) can adjust it if the variable being monitored is a floating-point number of signed values that can go negative. In case of having negative numbers, you have to be careful in the MIN function as defining the min value at the beginning with 0 may not converge to the right result.<\/span><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"c\">typedef uint32_t MATH_DataType;<\/pre>\n<p>&nbsp;<\/p>\n<hr \/>\n<h3 style=\"text-align: left;\"><span style=\"background-color: #333333;\"><strong><span style=\"color: #ffffff;\">\u00a0 \u00a0Moving Average FIR Digital Filter\u00a0 \u00a0<\/span><\/strong><\/span><\/h3>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: arial, helvetica, sans-serif; color: #000000;\">I&#8217;ll discuss this topic in detail in the next tutorial and show you how to create a simple yet effective digital filter in order to eliminate the push-button bouncing issue. A moving average filter is a very simple special case of the general Finite Impulse Response (FIR) digital filters.<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: arial, helvetica, sans-serif; color: #000000;\">Simple, you&#8217;ll save the most recent N values of a sensor&#8217;s reading. And constantly add a new reading, remove the oldest one, and calculate the average by summing all readings in the array and divide by N. Now you have got the average value and it&#8217;ll be way smoother than the original sensor&#8217;s reading.<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: arial, helvetica, sans-serif; color: #000000;\">For example, the <a href=\"https:\/\/deepbluembedded.com\/mpu6050-with-microchip-pic-accelerometer-gyroscope-interfacing-with-pic\/\" target=\"_blank\" rel=\"noopener noreferrer\">IMU (gyro + accelerometer) module MPU6050<\/a> which we&#8217;ve discussed in detail in a previous tutorial. This sensor&#8217;s output is very noisy in nature every when you fix the sensor in place with no motion at all. Here is an example for the output data (the raw data from the sensor) and the same data points but after applying this simple moving average filter (with an order of 20).<\/span><\/p>\n<p><span style=\"color: #0000ff;\"><strong>Raw Data From The Accelerometer Sensor (in Blue)<\/strong><\/span><\/p>\n<p><span style=\"color: #ff0000;\"><strong>Filtered Sensor Data with AVG Filter order 20 (in Red)<\/strong><\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-5041\" src=\"https:\/\/deepbluembedded.com\/wp-content\/uploads\/2020\/07\/Map-Function-In-Arduino-Example-And-Moving-Average-Filters.jpg\" alt=\"Map Function In Arduino Example And Moving Average Filters\" width=\"1280\" height=\"720\" srcset=\"https:\/\/deepbluembedded.com\/wp-content\/uploads\/2020\/07\/Map-Function-In-Arduino-Example-And-Moving-Average-Filters.jpg 1280w, https:\/\/deepbluembedded.com\/wp-content\/uploads\/2020\/07\/Map-Function-In-Arduino-Example-And-Moving-Average-Filters-300x169.jpg 300w, https:\/\/deepbluembedded.com\/wp-content\/uploads\/2020\/07\/Map-Function-In-Arduino-Example-And-Moving-Average-Filters-1024x576.jpg 1024w, https:\/\/deepbluembedded.com\/wp-content\/uploads\/2020\/07\/Map-Function-In-Arduino-Example-And-Moving-Average-Filters-768x432.jpg 768w\" sizes=\"auto, (max-width: 1280px) 100vw, 1280px\" \/><\/p>\n<p>&nbsp;<\/p>\n<hr \/>\n<h3 style=\"text-align: left;\"><span style=\"background-color: #333333;\"><strong><span style=\"color: #ffffff;\">\u00a0Map Function Example Application &#8211; LAB\u00a0<\/span><\/strong><\/span><\/h3>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: arial, helvetica, sans-serif; color: #000000;\">In this LAB, we&#8217;ll be using the MAP function with the ADC readings from a potentiometer (12-Bit ADC). To control a servo motor&#8217;s angle (0 to 180). This example was exactly performed in a <a href=\"https:\/\/deepbluembedded.com\/stm32-servo-motor-control-with-pwm-servo-library-examples-code\/\" target=\"_blank\" rel=\"noopener noreferrer\">previous tutorial (Servo Motor Control)<\/a> but without having the map function implemented in code. So here is an example application for it.<\/span><\/p>\n<p><span style=\"color: #333399; font-size: 14pt;\"><strong>The Application Code For This LAB (main.c)<\/strong><\/span><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"c\">#include \"main.h\"\r\n#include \"..\/MATH\/MATH.h\"\r\n#include \"..\/ECUAL\/SERVO\/SERVO.h\"\r\n\r\n#define SERVO_Motor1  0\r\n\r\nADC_HandleTypeDef hadc1;\r\n\r\nvoid SystemClock_Config(void);\r\nstatic void MX_GPIO_Init(void);\r\nstatic void MX_ADC1_Init(void);\r\n\r\nint main(void)\r\n{\r\n    uint16_t AD_RES = 0;\r\n    uint16_t Angle = 0;\r\n\r\n    HAL_Init();\r\n    SystemClock_Config();\r\n    MX_GPIO_Init();\r\n    MX_ADC1_Init();\r\n    SERVO_Init(SERVO_Motor1);\r\n\r\n    while (1)\r\n    {\r\n    \t\/\/ Start ADC Conversion\r\n    \tHAL_ADC_Start(&amp;hadc1);\r\n    \t\/\/ Poll ADC1 Perihperal &amp; TimeOut = 1mSec\r\n    \tHAL_ADC_PollForConversion(&amp;hadc1, 1);\r\n    \t\/\/ Read The ADC Conversion Result &amp; Map Servo Motor Angle\r\n    \tAD_RES = HAL_ADC_GetValue(&amp;hadc1);\r\n    \t\/\/ Map The ADC Result To Servo Pulse Width\r\n    \tAngle = MAP(AD_RES, 0, 4096, 0, 180);\r\n    \t\/\/ Move The Servo Motor To The Angle\r\n    \tSERVO_MoveTo(SERVO_Motor1, Angle);\r\n    \tHAL_Delay(1);\r\n    }\r\n}<\/pre>\n<p style=\"text-align: justify;\"><span style=\"font-family: arial, helvetica, sans-serif; color: #000000;\">We give the function the input (AD_RES) from the ADC reading that is 12-Bit in resolution so its range is from 0 up to 4096. And the target range from 0 up to 180. And that&#8217;s it! the map function will calculate and return the result as Angle and we&#8217;ll send it to the Servo_MoveTo function.<\/span><\/p>\n<p><span style=\"color: #333399; font-size: 14pt;\"><strong>Here is the result for this LAB<\/strong><\/span><\/p>\n<p><span style=\"font-family: arial, helvetica, sans-serif; color: #000000;\">The same as the previous servo motor LAB that I highly recommend checking it out if you didn&#8217;t yet (servo motor control tutorial &#8211; LAB27).<\/span><\/p>\n<p><iframe loading=\"lazy\" src=\"https:\/\/www.youtube-nocookie.com\/embed\/JrXnUUGel94\" width=\"560\" height=\"315\" frameborder=\"0\" allowfullscreen=\"allowfullscreen\"><\/iframe><\/p>\n<p><a href=\"https:\/\/drive.google.com\/file\/d\/1CMxmAPxt-gLnlqUIfy4U2YgYhdJvEjTt\/view?usp=sharing\" target=\"_blank\" rel=\"noopener noreferrer\"><strong>Download This LAB Project Folder<\/strong><\/a><\/p>\n<hr \/>\n<p><strong>Did you find this helpful? If yes, please consider <a href=\"https:\/\/www.patreon.com\/deep_blue\">supporting this work<\/a> and sharing these tutorials!<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: center;\"><span style=\"color: #333399;\"><strong>Stay tuned for the upcoming tutorials and don&#8217;t forget to <span style=\"color: #ff9900;\">SHARE<\/span> these tutorials. And consider <span style=\"color: #ff9900;\"><a style=\"color: #ff9900;\" href=\"https:\/\/www.patreon.com\/deep_blue\" target=\"_blank\" rel=\"noopener noreferrer\">SUPPORTING<\/a><\/span> this work to keep publishing free content just like this!<\/strong><\/span><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<table style=\"border-collapse: collapse; width: 100%;\" border=\"1\">\n<tbody>\n<tr>\n<td style=\"background-color: #ffffff; width: 5%;\"><a href=\"https:\/\/deepbluembedded.com\/interfacing-7-segment-display-stm32\/\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-1666 alignleft\" src=\"https:\/\/deepbluembedded.com\/wp-content\/uploads\/2018\/06\/play-256L-150x150.png\" alt=\"Previous Tutorial\" width=\"35\" height=\"35\" srcset=\"https:\/\/deepbluembedded.com\/wp-content\/uploads\/2018\/06\/play-256L-150x150.png 150w, https:\/\/deepbluembedded.com\/wp-content\/uploads\/2018\/06\/play-256L-160x160.png 160w, https:\/\/deepbluembedded.com\/wp-content\/uploads\/2018\/06\/play-256L-320x320.png 320w, https:\/\/deepbluembedded.com\/wp-content\/uploads\/2018\/06\/play-256L-50x50.png 50w, https:\/\/deepbluembedded.com\/wp-content\/uploads\/2018\/06\/play-256L.png 256w\" sizes=\"auto, (max-width: 35px) 100vw, 35px\" \/><\/a><\/td>\n<td style=\"background-color: #ffffff; width: 30%; text-align: left;\" colspan=\"2\"><a href=\"https:\/\/deepbluembedded.com\/interfacing-7-segment-display-stm32\/\"><strong>Previous Tutorial<\/strong><\/a><\/td>\n<td style=\"background-color: #ffffff; width: 30%; text-align: center;\" colspan=\"2\"><span style=\"color: #000000;\"><strong><span style=\"font-size: 14pt;\">Tutorial 33<\/span><\/strong><\/span><\/td>\n<td style=\"background-color: #ffffff; width: 30%; text-align: right;\" colspan=\"2\"><a href=\"https:\/\/deepbluembedded.com\/stm32-gpio-leds-buttons-interfacing-driver\/\"><strong>Next Tutorial<\/strong><\/a><\/td>\n<td style=\"background-color: #ffffff; width: 5%;\"><a href=\"https:\/\/deepbluembedded.com\/stm32-gpio-leds-buttons-interfacing-driver\/\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-1667 alignright\" src=\"https:\/\/deepbluembedded.com\/wp-content\/uploads\/2018\/06\/play-256-150x150.png\" alt=\"Next Tutorial\" width=\"35\" height=\"35\" srcset=\"https:\/\/deepbluembedded.com\/wp-content\/uploads\/2018\/06\/play-256-150x150.png 150w, https:\/\/deepbluembedded.com\/wp-content\/uploads\/2018\/06\/play-256-160x160.png 160w, https:\/\/deepbluembedded.com\/wp-content\/uploads\/2018\/06\/play-256-320x320.png 320w, https:\/\/deepbluembedded.com\/wp-content\/uploads\/2018\/06\/play-256-50x50.png 50w, https:\/\/deepbluembedded.com\/wp-content\/uploads\/2018\/06\/play-256.png 256w\" sizes=\"auto, (max-width: 35px) 100vw, 35px\" \/><\/a><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p> &#8230; <\/p>\n<p class=\"read-more-container\"><a title=\"Map Function, Constrain, FIR Filters, And Other Math Functions\" class=\"read-more button\" href=\"https:\/\/deepbluembedded.com\/map-function-embedded-c\/#more-5035\" aria-label=\"Read more about Map Function, Constrain, FIR Filters, And Other Math Functions\">Read More<\/a><\/p>\n","protected":false},"author":1,"featured_media":5043,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[28,30,103],"tags":[106,13,72,73,15,32,17,104,34],"class_list":["post-5035","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-embedded-systems","category-embedded-tutorials","category-stm32-arm","tag-arm","tag-embedded-c","tag-embedded-systems","tag-embedded-systems-articles","tag-firmware","tag-learn-embedded-systems","tag-microcontrollers","tag-stm32","tag-tutorials","generate-columns","tablet-grid-50","mobile-grid-100","grid-parent","grid-33","no-featured-image-padding"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Map Function, Constrain, FIR Filters, And Other Math Functions In C<\/title>\n<meta name=\"description\" content=\"Map function and constrain function in Arduino C and Embedded C. Some other math functions and FIR filters in C language implementations\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/deepbluembedded.com\/map-function-embedded-c\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Map Function, Constrain, FIR Filters, And Other Math Functions In C\" \/>\n<meta property=\"og:description\" content=\"Map function and constrain function in Arduino C and Embedded C. Some other math functions and FIR filters in C language implementations\" \/>\n<meta property=\"og:url\" content=\"https:\/\/deepbluembedded.com\/map-function-embedded-c\/\" \/>\n<meta property=\"og:site_name\" content=\"DeepBlue\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/khaled.elrawy.359\/\" \/>\n<meta property=\"article:author\" content=\"https:\/\/www.facebook.com\/khaled.elrawy.359\/\" \/>\n<meta property=\"article:published_time\" content=\"2020-07-06T17:43:18+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-08-17T20:51:26+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/deepbluembedded.com\/wp-content\/uploads\/2020\/07\/Map-Function-Constrain-And-Moving-Averge-Filters-and-MATH.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"720\" \/>\n\t<meta property=\"og:image:height\" content=\"340\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Khaled Magdy\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Khaled Magdy\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"8 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/deepbluembedded.com\\\/map-function-embedded-c\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/deepbluembedded.com\\\/map-function-embedded-c\\\/\"},\"author\":{\"name\":\"Khaled Magdy\",\"@id\":\"https:\\\/\\\/deepbluembedded.com\\\/#\\\/schema\\\/person\\\/30259d66cf68c6c681562dbe551b7867\"},\"headline\":\"Map Function, Constrain, FIR Filters, And Other Math Functions\",\"datePublished\":\"2020-07-06T17:43:18+00:00\",\"dateModified\":\"2023-08-17T20:51:26+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/deepbluembedded.com\\\/map-function-embedded-c\\\/\"},\"wordCount\":1205,\"commentCount\":1,\"publisher\":{\"@id\":\"https:\\\/\\\/deepbluembedded.com\\\/#\\\/schema\\\/person\\\/30259d66cf68c6c681562dbe551b7867\"},\"image\":{\"@id\":\"https:\\\/\\\/deepbluembedded.com\\\/map-function-embedded-c\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/deepbluembedded.com\\\/wp-content\\\/uploads\\\/2020\\\/07\\\/Map-Function-Constrain-And-Moving-Averge-Filters-and-MATH.jpg\",\"keywords\":[\"ARM\",\"Embedded C\",\"Embedded Systems\",\"Embedded Systems Articles\",\"Firmware\",\"Learn Embedded Systems\",\"Microcontrollers\",\"STM32\",\"Tutorials\"],\"articleSection\":[\"Embedded Systems\",\"Embedded Tutorials\",\"STM32 ARM\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/deepbluembedded.com\\\/map-function-embedded-c\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/deepbluembedded.com\\\/map-function-embedded-c\\\/\",\"url\":\"https:\\\/\\\/deepbluembedded.com\\\/map-function-embedded-c\\\/\",\"name\":\"Map Function, Constrain, FIR Filters, And Other Math Functions In C\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/deepbluembedded.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/deepbluembedded.com\\\/map-function-embedded-c\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/deepbluembedded.com\\\/map-function-embedded-c\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/deepbluembedded.com\\\/wp-content\\\/uploads\\\/2020\\\/07\\\/Map-Function-Constrain-And-Moving-Averge-Filters-and-MATH.jpg\",\"datePublished\":\"2020-07-06T17:43:18+00:00\",\"dateModified\":\"2023-08-17T20:51:26+00:00\",\"description\":\"Map function and constrain function in Arduino C and Embedded C. Some other math functions and FIR filters in C language implementations\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/deepbluembedded.com\\\/map-function-embedded-c\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/deepbluembedded.com\\\/map-function-embedded-c\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/deepbluembedded.com\\\/map-function-embedded-c\\\/#primaryimage\",\"url\":\"https:\\\/\\\/deepbluembedded.com\\\/wp-content\\\/uploads\\\/2020\\\/07\\\/Map-Function-Constrain-And-Moving-Averge-Filters-and-MATH.jpg\",\"contentUrl\":\"https:\\\/\\\/deepbluembedded.com\\\/wp-content\\\/uploads\\\/2020\\\/07\\\/Map-Function-Constrain-And-Moving-Averge-Filters-and-MATH.jpg\",\"width\":720,\"height\":340,\"caption\":\"Map Function, Constrain, And Moving Averge Filters and MATH\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/deepbluembedded.com\\\/map-function-embedded-c\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/deepbluembedded.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Map Function, Constrain, FIR Filters, And Other Math Functions\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/deepbluembedded.com\\\/#website\",\"url\":\"https:\\\/\\\/deepbluembedded.com\\\/\",\"name\":\"DeepBlueMbedded\",\"description\":\"Embedded Systems And Computer Engineering Tutorials &amp; Articles\",\"publisher\":{\"@id\":\"https:\\\/\\\/deepbluembedded.com\\\/#\\\/schema\\\/person\\\/30259d66cf68c6c681562dbe551b7867\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/deepbluembedded.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/deepbluembedded.com\\\/#\\\/schema\\\/person\\\/30259d66cf68c6c681562dbe551b7867\",\"name\":\"Khaled Magdy\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/a8b5dc7385ec807e129b584974394d27e41c9979f3a2d0fd785b552b73529032?s=96&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/a8b5dc7385ec807e129b584974394d27e41c9979f3a2d0fd785b552b73529032?s=96&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/a8b5dc7385ec807e129b584974394d27e41c9979f3a2d0fd785b552b73529032?s=96&r=g\",\"caption\":\"Khaled Magdy\"},\"logo\":{\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/a8b5dc7385ec807e129b584974394d27e41c9979f3a2d0fd785b552b73529032?s=96&r=g\"},\"description\":\"Principal Embedded Systems Engineer with years of experience in embedded software and hardware design. I work in the Automotive &amp; e-Mobility industry. However, I still do Hardware design and SW development for DSP, Control Systems, Robotics, AI\\\/ML, and other fields I'm passionate about. I love reading, writing, creating projects, and teaching. A reader by day and a writer by night, it's my lifestyle. I believe that the combination of brilliant minds, bold ideas, and a complete disregard for what is possible, can and will change the world! I will be there when it happens, will you?\",\"sameAs\":[\"https:\\\/\\\/deepbluembedded.com\",\"https:\\\/\\\/www.facebook.com\\\/khaled.elrawy.359\\\/\",\"https:\\\/\\\/www.instagram.com\\\/deepbluembedded\\\/\",\"https:\\\/\\\/www.linkedin.com\\\/in\\\/khaled-magdy-\\\/\",\"https:\\\/\\\/www.youtube.com\\\/channel\\\/UCzLSrNZD4rCjSCOVU9hknvA\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Map Function, Constrain, FIR Filters, And Other Math Functions In C","description":"Map function and constrain function in Arduino C and Embedded C. Some other math functions and FIR filters in C language implementations","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/deepbluembedded.com\/map-function-embedded-c\/","og_locale":"en_US","og_type":"article","og_title":"Map Function, Constrain, FIR Filters, And Other Math Functions In C","og_description":"Map function and constrain function in Arduino C and Embedded C. Some other math functions and FIR filters in C language implementations","og_url":"https:\/\/deepbluembedded.com\/map-function-embedded-c\/","og_site_name":"DeepBlue","article_publisher":"https:\/\/www.facebook.com\/khaled.elrawy.359\/","article_author":"https:\/\/www.facebook.com\/khaled.elrawy.359\/","article_published_time":"2020-07-06T17:43:18+00:00","article_modified_time":"2023-08-17T20:51:26+00:00","og_image":[{"width":720,"height":340,"url":"https:\/\/deepbluembedded.com\/wp-content\/uploads\/2020\/07\/Map-Function-Constrain-And-Moving-Averge-Filters-and-MATH.jpg","type":"image\/jpeg"}],"author":"Khaled Magdy","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Khaled Magdy","Est. reading time":"8 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/deepbluembedded.com\/map-function-embedded-c\/#article","isPartOf":{"@id":"https:\/\/deepbluembedded.com\/map-function-embedded-c\/"},"author":{"name":"Khaled Magdy","@id":"https:\/\/deepbluembedded.com\/#\/schema\/person\/30259d66cf68c6c681562dbe551b7867"},"headline":"Map Function, Constrain, FIR Filters, And Other Math Functions","datePublished":"2020-07-06T17:43:18+00:00","dateModified":"2023-08-17T20:51:26+00:00","mainEntityOfPage":{"@id":"https:\/\/deepbluembedded.com\/map-function-embedded-c\/"},"wordCount":1205,"commentCount":1,"publisher":{"@id":"https:\/\/deepbluembedded.com\/#\/schema\/person\/30259d66cf68c6c681562dbe551b7867"},"image":{"@id":"https:\/\/deepbluembedded.com\/map-function-embedded-c\/#primaryimage"},"thumbnailUrl":"https:\/\/deepbluembedded.com\/wp-content\/uploads\/2020\/07\/Map-Function-Constrain-And-Moving-Averge-Filters-and-MATH.jpg","keywords":["ARM","Embedded C","Embedded Systems","Embedded Systems Articles","Firmware","Learn Embedded Systems","Microcontrollers","STM32","Tutorials"],"articleSection":["Embedded Systems","Embedded Tutorials","STM32 ARM"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/deepbluembedded.com\/map-function-embedded-c\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/deepbluembedded.com\/map-function-embedded-c\/","url":"https:\/\/deepbluembedded.com\/map-function-embedded-c\/","name":"Map Function, Constrain, FIR Filters, And Other Math Functions In C","isPartOf":{"@id":"https:\/\/deepbluembedded.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/deepbluembedded.com\/map-function-embedded-c\/#primaryimage"},"image":{"@id":"https:\/\/deepbluembedded.com\/map-function-embedded-c\/#primaryimage"},"thumbnailUrl":"https:\/\/deepbluembedded.com\/wp-content\/uploads\/2020\/07\/Map-Function-Constrain-And-Moving-Averge-Filters-and-MATH.jpg","datePublished":"2020-07-06T17:43:18+00:00","dateModified":"2023-08-17T20:51:26+00:00","description":"Map function and constrain function in Arduino C and Embedded C. Some other math functions and FIR filters in C language implementations","breadcrumb":{"@id":"https:\/\/deepbluembedded.com\/map-function-embedded-c\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/deepbluembedded.com\/map-function-embedded-c\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/deepbluembedded.com\/map-function-embedded-c\/#primaryimage","url":"https:\/\/deepbluembedded.com\/wp-content\/uploads\/2020\/07\/Map-Function-Constrain-And-Moving-Averge-Filters-and-MATH.jpg","contentUrl":"https:\/\/deepbluembedded.com\/wp-content\/uploads\/2020\/07\/Map-Function-Constrain-And-Moving-Averge-Filters-and-MATH.jpg","width":720,"height":340,"caption":"Map Function, Constrain, And Moving Averge Filters and MATH"},{"@type":"BreadcrumbList","@id":"https:\/\/deepbluembedded.com\/map-function-embedded-c\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/deepbluembedded.com\/"},{"@type":"ListItem","position":2,"name":"Map Function, Constrain, FIR Filters, And Other Math Functions"}]},{"@type":"WebSite","@id":"https:\/\/deepbluembedded.com\/#website","url":"https:\/\/deepbluembedded.com\/","name":"DeepBlueMbedded","description":"Embedded Systems And Computer Engineering Tutorials &amp; Articles","publisher":{"@id":"https:\/\/deepbluembedded.com\/#\/schema\/person\/30259d66cf68c6c681562dbe551b7867"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/deepbluembedded.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/deepbluembedded.com\/#\/schema\/person\/30259d66cf68c6c681562dbe551b7867","name":"Khaled Magdy","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/a8b5dc7385ec807e129b584974394d27e41c9979f3a2d0fd785b552b73529032?s=96&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/a8b5dc7385ec807e129b584974394d27e41c9979f3a2d0fd785b552b73529032?s=96&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/a8b5dc7385ec807e129b584974394d27e41c9979f3a2d0fd785b552b73529032?s=96&r=g","caption":"Khaled Magdy"},"logo":{"@id":"https:\/\/secure.gravatar.com\/avatar\/a8b5dc7385ec807e129b584974394d27e41c9979f3a2d0fd785b552b73529032?s=96&r=g"},"description":"Principal Embedded Systems Engineer with years of experience in embedded software and hardware design. I work in the Automotive &amp; e-Mobility industry. However, I still do Hardware design and SW development for DSP, Control Systems, Robotics, AI\/ML, and other fields I'm passionate about. I love reading, writing, creating projects, and teaching. A reader by day and a writer by night, it's my lifestyle. I believe that the combination of brilliant minds, bold ideas, and a complete disregard for what is possible, can and will change the world! I will be there when it happens, will you?","sameAs":["https:\/\/deepbluembedded.com","https:\/\/www.facebook.com\/khaled.elrawy.359\/","https:\/\/www.instagram.com\/deepbluembedded\/","https:\/\/www.linkedin.com\/in\/khaled-magdy-\/","https:\/\/www.youtube.com\/channel\/UCzLSrNZD4rCjSCOVU9hknvA"]}]}},"jetpack_featured_media_url":"https:\/\/deepbluembedded.com\/wp-content\/uploads\/2020\/07\/Map-Function-Constrain-And-Moving-Averge-Filters-and-MATH.jpg","jetpack_shortlink":"https:\/\/wp.me\/p9SirL-1jd","jetpack-related-posts":[{"id":4203,"url":"https:\/\/deepbluembedded.com\/stm32-ecosystem-development-environment-setup\/","url_meta":{"origin":5035,"position":0},"title":"STM32 EcoSystem (Development Environment) Setup","author":"Khaled Magdy","date":"June 2, 2020","format":false,"excerpt":"Previous Tutorial Tutorial 0 Next Tutorial Setting-Up STM32 Ecosystem STM32 Course Home Page ???? \u00a0 At the beginning of this series of tutorials, we'll set up the development environment which we'll be using throughout the entire course tutorials, LABs, and projects. In this short tutorial, I'll list down the required\u2026","rel":"","context":"In &quot;Embedded Systems&quot;","block_context":{"text":"Embedded Systems","link":"https:\/\/deepbluembedded.com\/embedded-systems\/"},"img":{"alt_text":"Setting-Up Dev Env Thumbnail","src":"https:\/\/i0.wp.com\/deepbluembedded.com\/wp-content\/uploads\/2020\/05\/Setting-Up-Dev-Env-Thumbnail.jpg?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/deepbluembedded.com\/wp-content\/uploads\/2020\/05\/Setting-Up-Dev-Env-Thumbnail.jpg?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/deepbluembedded.com\/wp-content\/uploads\/2020\/05\/Setting-Up-Dev-Env-Thumbnail.jpg?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/deepbluembedded.com\/wp-content\/uploads\/2020\/05\/Setting-Up-Dev-Env-Thumbnail.jpg?resize=700%2C400&ssl=1 2x"},"classes":[]},{"id":4263,"url":"https:\/\/deepbluembedded.com\/stm32-hal-library-tutorial-examples\/","url_meta":{"origin":5035,"position":1},"title":"STM32 HAL Library Tutorial","author":"Khaled Magdy","date":"June 2, 2020","format":false,"excerpt":"Previous Tutorial Tutorial 2 Next Tutorial STM32 HAL Library STM32 Course Home Page ???? \u00a0 STMCube\u00ae is STMicroelectronics's original initiative to ease and accelerate the development cycle of embedded products. STM32Cube covers the STM32 portfolio of microcontrollers. It provides the developer with all the low-level drivers, APIs, and enables him\/her\u2026","rel":"","context":"In &quot;Embedded Systems&quot;","block_context":{"text":"Embedded Systems","link":"https:\/\/deepbluembedded.com\/embedded-systems\/"},"img":{"alt_text":"STM32 HAL Library","src":"https:\/\/i0.wp.com\/deepbluembedded.com\/wp-content\/uploads\/2020\/06\/STM32-HAL-Library.jpg?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/deepbluembedded.com\/wp-content\/uploads\/2020\/06\/STM32-HAL-Library.jpg?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/deepbluembedded.com\/wp-content\/uploads\/2020\/06\/STM32-HAL-Library.jpg?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/deepbluembedded.com\/wp-content\/uploads\/2020\/06\/STM32-HAL-Library.jpg?resize=700%2C400&ssl=1 2x"},"classes":[]},{"id":2555,"url":"https:\/\/deepbluembedded.com\/embedded-systems-tutorials-final-episode\/","url_meta":{"origin":5035,"position":2},"title":"Embedded Systems Tutorials With PIC MCUs | Final Episode","author":"Khaled Magdy","date":"April 3, 2019","format":false,"excerpt":"Previous Tutorial End of The 1st Edition Next Tutorial Concluding The 1st Edition Of Embedded Systems Tutorials (With PIC MCUs) \u00a0 Congratulations to everyone who have been following my embedded systems tutorials up to this point. Up till now, you've approached reading ~100k words of tutorials. That's a lot of\u2026","rel":"","context":"In &quot;Embedded Systems&quot;","block_context":{"text":"Embedded Systems","link":"https:\/\/deepbluembedded.com\/embedded-systems\/"},"img":{"alt_text":"Embedded Systems Tutorials Edition1 End","src":"https:\/\/i0.wp.com\/deepbluembedded.com\/wp-content\/uploads\/2019\/04\/Embedded-Systems-Tutorials-Edition1-End.jpg?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/deepbluembedded.com\/wp-content\/uploads\/2019\/04\/Embedded-Systems-Tutorials-Edition1-End.jpg?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/deepbluembedded.com\/wp-content\/uploads\/2019\/04\/Embedded-Systems-Tutorials-Edition1-End.jpg?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/deepbluembedded.com\/wp-content\/uploads\/2019\/04\/Embedded-Systems-Tutorials-Edition1-End.jpg?resize=700%2C400&ssl=1 2x"},"classes":[]},{"id":13263,"url":"https:\/\/deepbluembedded.com\/stm32-unique-id-uid-96-bit-reading\/","url_meta":{"origin":5035,"position":3},"title":"STM32 Unique ID UID (96-Bit) | How To Read","author":"Khaled Magdy","date":"July 31, 2024","format":false,"excerpt":"In this article, we'll discuss the STM32 unique ID (UID) which is a unique 96-bit value assigned to each STM32 microcontroller IC, how to read this UID value, and what are the possible applications and use cases for the STM32 UID. Without further ado, let's get right into it! STM32\u2026","rel":"","context":"In &quot;Embedded Systems&quot;","block_context":{"text":"Embedded Systems","link":"https:\/\/deepbluembedded.com\/embedded-systems\/"},"img":{"alt_text":"STM32 Unique ID UID (96-Bit) - How To Read","src":"https:\/\/i0.wp.com\/deepbluembedded.com\/wp-content\/uploads\/2024\/07\/STM32-Unique-ID-UID-96-Bit-How-To-Read.jpg?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/deepbluembedded.com\/wp-content\/uploads\/2024\/07\/STM32-Unique-ID-UID-96-Bit-How-To-Read.jpg?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/deepbluembedded.com\/wp-content\/uploads\/2024\/07\/STM32-Unique-ID-UID-96-Bit-How-To-Read.jpg?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/deepbluembedded.com\/wp-content\/uploads\/2024\/07\/STM32-Unique-ID-UID-96-Bit-How-To-Read.jpg?resize=700%2C400&ssl=1 2x, https:\/\/i0.wp.com\/deepbluembedded.com\/wp-content\/uploads\/2024\/07\/STM32-Unique-ID-UID-96-Bit-How-To-Read.jpg?resize=1050%2C600&ssl=1 3x"},"classes":[]},{"id":6769,"url":"https:\/\/deepbluembedded.com\/stm32-i2c-scanner-hal-code-example\/","url_meta":{"origin":5035,"position":4},"title":"STM32 I2C Scanner HAL Code Example","author":"Khaled Magdy","date":"April 17, 2021","format":false,"excerpt":"Previous Tutorial Tutorial 45 Next Tutorial STM32 I2C Scanner Example STM32 Course Home Page ???? In this short tutorial, we'll be creating an STM32 I2C Scanner example project. To check for the connected slave devices on the I2C bus and report their addresses over UART to our PC. The I2C\u2026","rel":"","context":"In &quot;Embedded Systems&quot;","block_context":{"text":"Embedded Systems","link":"https:\/\/deepbluembedded.com\/embedded-systems\/"},"img":{"alt_text":"STM32 I2C Scanner HAL Example Code","src":"https:\/\/i0.wp.com\/deepbluembedded.com\/wp-content\/uploads\/2021\/04\/STM32-I2C-Scanner-HAL-Example-Code.jpg?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/deepbluembedded.com\/wp-content\/uploads\/2021\/04\/STM32-I2C-Scanner-HAL-Example-Code.jpg?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/deepbluembedded.com\/wp-content\/uploads\/2021\/04\/STM32-I2C-Scanner-HAL-Example-Code.jpg?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/deepbluembedded.com\/wp-content\/uploads\/2021\/04\/STM32-I2C-Scanner-HAL-Example-Code.jpg?resize=700%2C400&ssl=1 2x, https:\/\/i0.wp.com\/deepbluembedded.com\/wp-content\/uploads\/2021\/04\/STM32-I2C-Scanner-HAL-Example-Code.jpg?resize=1050%2C600&ssl=1 3x"},"classes":[]},{"id":11909,"url":"https:\/\/deepbluembedded.com\/stm32-blue-pill-pinout-programming-guide\/","url_meta":{"origin":5035,"position":5},"title":"STM32 Blue Pill Pinout &amp; Programming Guide","author":"Khaled Magdy","date":"January 22, 2024","format":false,"excerpt":"In this article, you\u2019ll find the STM32 Blue Pill Pinout Diagram\u00a0for both blue pill boards based on the STM32F103C8T6 & STM32F103C6T6. You'll also learn how to program & simulate STM32 Blue Pill Projects with STM32CubeIDE, Arduino IDE, and Proteus ISIS software. Without further ado, let\u2019s get right into it! STM32\u2026","rel":"","context":"In &quot;Embedded Systems&quot;","block_context":{"text":"Embedded Systems","link":"https:\/\/deepbluembedded.com\/embedded-systems\/"},"img":{"alt_text":"STM32 Blue Pill Pinout & Programming Guide","src":"https:\/\/i0.wp.com\/deepbluembedded.com\/wp-content\/uploads\/2024\/01\/STM32-Blue-Pill-Pinout-Programming-Guide.jpg?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/deepbluembedded.com\/wp-content\/uploads\/2024\/01\/STM32-Blue-Pill-Pinout-Programming-Guide.jpg?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/deepbluembedded.com\/wp-content\/uploads\/2024\/01\/STM32-Blue-Pill-Pinout-Programming-Guide.jpg?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/deepbluembedded.com\/wp-content\/uploads\/2024\/01\/STM32-Blue-Pill-Pinout-Programming-Guide.jpg?resize=700%2C400&ssl=1 2x, https:\/\/i0.wp.com\/deepbluembedded.com\/wp-content\/uploads\/2024\/01\/STM32-Blue-Pill-Pinout-Programming-Guide.jpg?resize=1050%2C600&ssl=1 3x"},"classes":[]}],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/deepbluembedded.com\/wp-json\/wp\/v2\/posts\/5035","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/deepbluembedded.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/deepbluembedded.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/deepbluembedded.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/deepbluembedded.com\/wp-json\/wp\/v2\/comments?post=5035"}],"version-history":[{"count":11,"href":"https:\/\/deepbluembedded.com\/wp-json\/wp\/v2\/posts\/5035\/revisions"}],"predecessor-version":[{"id":10727,"href":"https:\/\/deepbluembedded.com\/wp-json\/wp\/v2\/posts\/5035\/revisions\/10727"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/deepbluembedded.com\/wp-json\/wp\/v2\/media\/5043"}],"wp:attachment":[{"href":"https:\/\/deepbluembedded.com\/wp-json\/wp\/v2\/media?parent=5035"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/deepbluembedded.com\/wp-json\/wp\/v2\/categories?post=5035"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/deepbluembedded.com\/wp-json\/wp\/v2\/tags?post=5035"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}