{"id":6154,"date":"2021-06-01T10:31:23","date_gmt":"2021-06-01T10:31:23","guid":{"rendered":"http:\/\/fastbitlab.com\/?p=6154"},"modified":"2023-09-02T17:10:40","modified_gmt":"2023-09-02T11:40:40","slug":"using-mcu-peripherals-and-implementing-initialization-codes","status":"publish","type":"post","link":"https:\/\/fastbitlab.com\/blog\/using-mcu-peripherals-and-implementing-initialization-codes\/","title":{"rendered":"FreeRTOS Lecture 33 &#8211; Using MCU peripherals and implementing initialization codes"},"content":{"rendered":"<div class=\"boldgrid-section\" style=\"background-image: linear-gradient(to left, #eeeeee, #eeeeee);\" data-bg-color-1=\"#EEEEEE\" data-bg-color-2=\"#EEEEEE\" data-bg-direction=\"to left\">\n<div class=\"container\">\n<div class=\"row\" style=\"padding-top: 35px; padding-bottom: 0px; background-image: linear-gradient(to left, #eeeeee, #eeeeee);\" data-bg-color-1=\"#EEEEEE\" data-bg-color-2=\"#EEEEEE\" data-bg-direction=\"to left\">\n<div class=\"col-md-1 col-sm-12 col-xs-12 col-lg-1\">\n<p>&nbsp;<\/p>\n<\/div>\n<div class=\"col-md-10 col-sm-12 col-xs-12 col-lg-10\">\n<h1 class=\"\" style=\"text-align: center; font-size: 32px; border-width: 0px; line-height: 50px;\"><span style=\"color: #000080;\">Using MCU peripherals and implementing initialization codes<\/span><\/h1>\n<div class=\"row bg-editor-hr-wrap\" style=\"border-width: 0px; margin-top: -25px;\">\n<div class=\"col-lg-12 col-md-12 col-xs-12 col-sm-12\">\n<div>\n<p>&nbsp;<\/p>\n<div class=\"bg-hr bg-hr-10 color2-color\" style=\"border-style: solid; border-width: 0px 0px 3px;\"><\/div>\n<p>&nbsp;<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">Now let\u2019s learn more about how FreeRTOS schedules the FreeRTOS related tasks, how exactly the task executes, and for how many durations each task executes. You will understand all these topics as you make progress.<\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">Our goal was to create two tasks and use semihosting to print some logs. But the semihosting is not that great idea. It is definitely helpful when you do debugging. But in order to get the logs using semihosting or printf\u2019s, you have to keep the board into debug mode. Then only it will work. Otherwise, it won\u2019t work.<\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">In this article, let\u2019s use the UART peripheral of the microcontroller to send logs to the computer over serial communication. <\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">Now let\u2019s see how we can configure the UART peripheral and how to use that in the FreeRTOS scenario. <\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">For that, we are going to use the standard peripheral driver given by the STMicroelectronics. We will be using various driver files like UART driver, clock driver, and GPIO driver to configure the UART peripheral.<\/span><\/p>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">Let\u2019s create one function called prvSetupHardware to configure the UART peripheral, where prv means private. This is a private function. You can even make it static, as shown below. <\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">It is a private function in order to implement all hardware-specific configurations. Hardware means microcontroller or board. All board-related initialization or any peripheral related initialization we can do in this function. <\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">So, let\u2019s keep all the microcontroller peripheral specific initialization inside this prvSetupHardware function.<\/span><\/p>\n<pre class=\"color-5-text-contrast color5-background-color\" style=\"font-size: 12px; box-shadow: #cecece 0px 0px 0px 0px inset;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\"><span style=\"color: #ff99cc;\">void<\/span> vTask2_handler(<span style=\"color: #ff99cc;\">void<\/span> *params)\r\n{\r\n   <span style=\"color: #ff99cc;\"> while<\/span>(1)\r\n    {\r\n         printf(\"Hello-world: From Task-2\\n\");\r\n    }\r\n}\r\n\r\n<span style=\"color: #ff99cc;\">static void<\/span> prvSetupUart(<span style=\"color: #ff99cc;\">void<\/span>)\r\n{\r\n\r\n}<\/pre>\n<p class=\"\" style=\"text-align: center;\"><span style=\"color: #000000;\">Function to setup the hardware<\/span><\/p>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">Now let\u2019s give the prototype of the prvSetupHardware function, as shown in Figure 1.<\/span><\/p>\n<figure id=\"attachment_6158\" aria-describedby=\"caption-attachment-6158\" style=\"width: 744px\" class=\"wp-caption aligncenter\"><img fetchpriority=\"high\" decoding=\"async\" class=\"wp-image-6158\" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2021\/05\/Figure-2-6.png\" alt=\"Figure 2. Prototype of prvSetupHardware function.\" width=\"744\" height=\"396\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/05\/Figure-2-6.png 1917w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/05\/Figure-2-6-300x159.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/05\/Figure-2-6-768x408.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/05\/Figure-2-6-1024x544.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/05\/Figure-2-6-600x319.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/05\/Figure-2-6-120x64.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/05\/Figure-2-6-500x266.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/05\/Figure-2-6-200x106.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/05\/Figure-2-6-400x213.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/05\/Figure-2-6-800x425.png 800w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/05\/Figure-2-6-1200x638.png 1200w\" sizes=\"(max-width: 744px) 100vw, 744px\" \/><figcaption id=\"caption-attachment-6158\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 1. Prototype of prvSetupHardware function.<\/span><\/figcaption><\/figure>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">Let\u2019s call the prvSetupHardware function from main, as shown in Figure 2.<\/span><\/p>\n<figure id=\"attachment_6159\" aria-describedby=\"caption-attachment-6159\" style=\"width: 744px\" class=\"wp-caption aligncenter\"><img decoding=\"async\" class=\" wp-image-6159\" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2021\/05\/Figure-3-6.png\" alt=\"\" width=\"744\" height=\"395\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/05\/Figure-3-6.png 1917w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/05\/Figure-3-6-300x159.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/05\/Figure-3-6-768x407.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/05\/Figure-3-6-1024x543.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/05\/Figure-3-6-600x318.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/05\/Figure-3-6-120x64.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/05\/Figure-3-6-500x265.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/05\/Figure-3-6-200x106.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/05\/Figure-3-6-400x212.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/05\/Figure-3-6-800x424.png 800w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/05\/Figure-3-6-1200x637.png 1200w\" sizes=\"(max-width: 744px) 100vw, 744px\" \/><figcaption id=\"caption-attachment-6159\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 2. Call for the prvSetupHardware function.<\/span><\/figcaption><\/figure>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">Instead of removing semihosting related calls, manage them using preprocessor macros, as shown below. Now the semihosting related calls are used only if the ifdef is defined.<\/span><\/p>\n<pre class=\"color-5-text-contrast color5-background-color\" style=\"font-size: 12px; box-shadow: #cecece 0px 0px 0px 0px;\"><span style=\"color: #ff99cc;\">#include<\/span>&lt;stdio.h&gt;\r\n<span style=\"color: #ff99cc;\">#include<\/span>&lt;stdint.h&gt;\r\n<span style=\"color: #ff99cc;\">#include<\/span>&lt;string.h&gt;\r\n<span style=\"color: #ff99cc;\">#include<\/span> \"stm32f4xx.h\"\r\n\r\n<span style=\"color: #ff99cc;\">#include<\/span> \"FreeRTOS.h\"\r\n<span style=\"color: #ff99cc;\">#include<\/span> \"task.h\"\r\n\r\nTaskHandle_t xTaskHandle1=NULL;\r\nTaskHandle_t xTaskHandle2=NULL;\r\n\r\n<span style=\"color: #008000;\">\/\/Task functions prototypes<\/span>\r\n<span style=\"color: #ff99cc;\">void<\/span> vTask1_handler(<span style=\"color: #ff99cc;\">void<\/span> *params);\r\n<span style=\"color: #ff99cc;\">void<\/span> vTask2_handler(<span style=\"color: #ff99cc;\">void<\/span> *params);\r\n\r\n<span style=\"color: #ff99cc;\">#ifdef<\/span> USE_SEMIHOSTING\r\n<span style=\"color: #008000;\">\/\/used for semihosting<\/span>\r\n<span style=\"color: #ff99cc;\">extern void<\/span> initialise_monitor_handles();\r\n<span style=\"color: #ff99cc;\">#endif<\/span>\r\n\r\n<span style=\"color: #ff99cc;\">static void<\/span> prvSetupHardware(void);\r\n\r\n<span style=\"color: #ff99cc;\">int<\/span> main(void)\r\n{\r\n\r\n<span style=\"color: #ff99cc;\">#ifdef<\/span> USE_SEMIHOSTING\r\n  &nbsp; &nbsp;initialise_monitor_handles();\r\n  &nbsp; &nbsp;printf(\"This is hello world example code\\n\");\r\n<span style=\"color: #ff99cc;\">#endif<\/span><\/pre>\n<p class=\"\"><span style=\"color: #000000;\">Use of preprocessor macros to manage the semihosting related calls<\/span><\/p>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">Remove the semihosting related printf\u2019s in the task handlers, as shown in Figure 3. You can replace it with UART-related printf\u2019s later.<\/span><\/p>\n<figure id=\"attachment_6161\" aria-describedby=\"caption-attachment-6161\" style=\"width: 740px\" class=\"wp-caption aligncenter\"><img decoding=\"async\" class=\"wp-image-6161\" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2021\/05\/Figure-5-6.png\" alt=\"Using MCU peripherals and implementing initialization codes\" width=\"740\" height=\"394\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/05\/Figure-5-6.png 1913w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/05\/Figure-5-6-300x160.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/05\/Figure-5-6-768x409.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/05\/Figure-5-6-1024x545.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/05\/Figure-5-6-600x320.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/05\/Figure-5-6-120x64.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/05\/Figure-5-6-500x266.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/05\/Figure-5-6-200x107.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/05\/Figure-5-6-400x213.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/05\/Figure-5-6-800x426.png 800w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/05\/Figure-5-6-1200x639.png 1200w\" sizes=\"(max-width: 740px) 100vw, 740px\" \/><figcaption id=\"caption-attachment-6161\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 3. Removing semihosting related codes from the task handlers.<\/span><\/figcaption><\/figure>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">Build this code and see whether it builds successfully or not (Figure 4). It builds successfully without any errors.<\/span><\/p>\n<figure id=\"attachment_6162\" aria-describedby=\"caption-attachment-6162\" style=\"width: 744px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-6162\" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2021\/05\/Figure-6-6.png\" alt=\"Using MCU peripherals and implementing initialization codes\" width=\"744\" height=\"397\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/05\/Figure-6-6.png 1913w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/05\/Figure-6-6-300x160.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/05\/Figure-6-6-768x410.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/05\/Figure-6-6-1024x547.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/05\/Figure-6-6-600x320.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/05\/Figure-6-6-120x64.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/05\/Figure-6-6-500x267.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/05\/Figure-6-6-200x107.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/05\/Figure-6-6-400x213.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/05\/Figure-6-6-800x427.png 800w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/05\/Figure-6-6-1200x640.png 1200w\" sizes=\"(max-width: 744px) 100vw, 744px\" \/><figcaption id=\"caption-attachment-6162\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 4. Building the project.<\/span><\/figcaption><\/figure>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">If you want to use semihosting, then you have to define the macro USE_SEMIHOSTING in the project settings. Let\u2019s see how we can do that.<\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\"> Just copy that macro and go to the project, select properties (Figure 5), after that go to C\/ C++ build, go to settings (Figure 6), go to MCU GCC compiler, and then go to the preprocessor (Figure 7). <\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">After that, click on the add option marked in Figure 8. You will see a popup; there, you paste the macro and click ok (Figure 9). Then apply those changes and click ok (Figure 10). If you don\u2019t want to use the semihosting, then you just disable that.<\/span><\/p>\n<figure id=\"attachment_6163\" aria-describedby=\"caption-attachment-6163\" style=\"width: 744px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-6163\" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2021\/05\/Figure-7-6.png\" alt=\"Using MCU peripherals and implementing initialization codes\" width=\"744\" height=\"394\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/05\/Figure-7-6.png 1919w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/05\/Figure-7-6-300x159.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/05\/Figure-7-6-768x406.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/05\/Figure-7-6-1024x542.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/05\/Figure-7-6-600x317.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/05\/Figure-7-6-120x63.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/05\/Figure-7-6-500x264.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/05\/Figure-7-6-200x106.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/05\/Figure-7-6-400x212.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/05\/Figure-7-6-800x423.png 800w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/05\/Figure-7-6-1200x635.png 1200w\" sizes=\"(max-width: 744px) 100vw, 744px\" \/><figcaption id=\"caption-attachment-6163\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 5. Properties of the current STM32 project.<\/span><\/figcaption><\/figure>\n<p class=\"\">&nbsp;<\/p>\n<figure id=\"attachment_6164\" aria-describedby=\"caption-attachment-6164\" style=\"width: 744px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-6164\" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2021\/05\/Figure-8-5.png\" alt=\"Using MCU peripherals and implementing initialization codes\" width=\"744\" height=\"392\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/05\/Figure-8-5.png 1915w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/05\/Figure-8-5-300x158.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/05\/Figure-8-5-768x405.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/05\/Figure-8-5-1024x540.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/05\/Figure-8-5-600x316.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/05\/Figure-8-5-120x63.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/05\/Figure-8-5-500x263.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/05\/Figure-8-5-200x105.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/05\/Figure-8-5-400x211.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/05\/Figure-8-5-800x422.png 800w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/05\/Figure-8-5-1200x632.png 1200w\" sizes=\"(max-width: 744px) 100vw, 744px\" \/><figcaption id=\"caption-attachment-6164\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 6. C\/ C++ build settings.<\/span><\/figcaption><\/figure>\n<p class=\"\">&nbsp;<\/p>\n<figure id=\"attachment_6165\" aria-describedby=\"caption-attachment-6165\" style=\"width: 744px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-6165\" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2021\/05\/Figure-9-5.png\" alt=\"Using MCU peripherals and implementing initialization codes\" width=\"744\" height=\"397\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/05\/Figure-9-5.png 1919w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/05\/Figure-9-5-300x160.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/05\/Figure-9-5-768x409.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/05\/Figure-9-5-1024x546.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/05\/Figure-9-5-600x320.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/05\/Figure-9-5-120x64.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/05\/Figure-9-5-500x267.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/05\/Figure-9-5-200x107.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/05\/Figure-9-5-400x213.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/05\/Figure-9-5-800x426.png 800w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/05\/Figure-9-5-1200x640.png 1200w\" sizes=\"(max-width: 744px) 100vw, 744px\" \/><figcaption id=\"caption-attachment-6165\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 7. Preprocessor of MCU GCC compiler.<\/span><\/figcaption><\/figure>\n<p class=\"\">&nbsp;<\/p>\n<figure id=\"attachment_6166\" aria-describedby=\"caption-attachment-6166\" style=\"width: 744px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-6166\" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2021\/05\/Figure-10-5.png\" alt=\"Using MCU peripherals and implementing initialization codes\" width=\"744\" height=\"396\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/05\/Figure-10-5.png 1915w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/05\/Figure-10-5-300x159.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/05\/Figure-10-5-768x408.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/05\/Figure-10-5-1024x544.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/05\/Figure-10-5-600x319.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/05\/Figure-10-5-120x64.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/05\/Figure-10-5-500x266.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/05\/Figure-10-5-200x106.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/05\/Figure-10-5-400x212.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/05\/Figure-10-5-800x425.png 800w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/05\/Figure-10-5-1200x637.png 1200w\" sizes=\"(max-width: 744px) 100vw, 744px\" \/><figcaption id=\"caption-attachment-6166\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 8. Option to add the preprocessor macro.<\/span><\/figcaption><\/figure>\n<p class=\"\">&nbsp;<\/p>\n<figure id=\"attachment_6167\" aria-describedby=\"caption-attachment-6167\" style=\"width: 744px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-6167\" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2021\/05\/Figure-11-4.png\" alt=\"Using MCU peripherals and implementing initialization codes\" width=\"744\" height=\"397\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/05\/Figure-11-4.png 1917w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/05\/Figure-11-4-300x160.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/05\/Figure-11-4-768x410.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/05\/Figure-11-4-1024x546.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/05\/Figure-11-4-600x320.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/05\/Figure-11-4-120x64.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/05\/Figure-11-4-500x267.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/05\/Figure-11-4-200x107.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/05\/Figure-11-4-400x213.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/05\/Figure-11-4-800x427.png 800w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/05\/Figure-11-4-1200x640.png 1200w\" sizes=\"(max-width: 744px) 100vw, 744px\" \/><figcaption id=\"caption-attachment-6167\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 9. Adding the preprocessor macro USE_SEMIHOSTING.<\/span><\/figcaption><\/figure>\n<p class=\"\">&nbsp;<\/p>\n<figure id=\"attachment_6168\" aria-describedby=\"caption-attachment-6168\" style=\"width: 744px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-6168\" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2021\/05\/Figure-12-4.png\" alt=\"Using MCU peripherals and implementing initialization codes\" width=\"744\" height=\"393\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/05\/Figure-12-4.png 1919w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/05\/Figure-12-4-300x158.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/05\/Figure-12-4-768x405.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/05\/Figure-12-4-1024x541.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/05\/Figure-12-4-600x317.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/05\/Figure-12-4-120x63.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/05\/Figure-12-4-500x264.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/05\/Figure-12-4-200x106.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/05\/Figure-12-4-400x211.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/05\/Figure-12-4-800x422.png 800w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/05\/Figure-12-4-1200x633.png 1200w\" sizes=\"(max-width: 744px) 100vw, 744px\" \/><figcaption id=\"caption-attachment-6168\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 10. Applying the changes.<\/span><\/figcaption><\/figure>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">Now let\u2019s see whether it builds properly or not (Figure 11). The project builds successfully without any problems.<\/span><\/p>\n<figure id=\"attachment_6169\" aria-describedby=\"caption-attachment-6169\" style=\"width: 744px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-6169\" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2021\/05\/Figure-13-4.png\" alt=\"Using MCU peripherals and implementing initialization codes\" width=\"744\" height=\"400\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/05\/Figure-13-4.png 1919w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/05\/Figure-13-4-300x161.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/05\/Figure-13-4-768x413.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/05\/Figure-13-4-1024x550.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/05\/Figure-13-4-600x322.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/05\/Figure-13-4-120x64.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/05\/Figure-13-4-500x269.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/05\/Figure-13-4-200x107.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/05\/Figure-13-4-400x215.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/05\/Figure-13-4-800x430.png 800w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/05\/Figure-13-4-1200x645.png 1200w\" sizes=\"(max-width: 744px) 100vw, 744px\" \/><figcaption id=\"caption-attachment-6169\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 11. Building the project.<\/span><\/figcaption><\/figure>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">But for this example, we don\u2019t need semihosting; therefore, let\u2019s remove that, as shown in Figure 12. After that, apply changes and click ok.<\/span><\/p>\n<figure id=\"attachment_6170\" aria-describedby=\"caption-attachment-6170\" style=\"width: 744px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-6170\" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2021\/05\/Figure-14-4.png\" alt=\"Using MCU peripherals and implementing initialization codes\" width=\"744\" height=\"398\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/05\/Figure-14-4.png 1919w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/05\/Figure-14-4-300x160.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/05\/Figure-14-4-768x410.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/05\/Figure-14-4-1024x547.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/05\/Figure-14-4-600x320.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/05\/Figure-14-4-120x64.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/05\/Figure-14-4-500x267.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/05\/Figure-14-4-200x107.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/05\/Figure-14-4-400x214.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/05\/Figure-14-4-800x427.png 800w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/05\/Figure-14-4-1200x641.png 1200w\" sizes=\"(max-width: 744px) 100vw, 744px\" \/><figcaption id=\"caption-attachment-6170\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 12. Removing preprocessor macro USE_SEMIHOSTING.<\/span><\/figcaption><\/figure>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\"><span style=\"color: #000080;\"><strong>FastBit Embedded Brain Academy Courses<\/strong><\/span><\/p>\n<p class=\"\"><a href=\"https:\/\/fastbitlab.com\/course1\">https:\/\/fastbitlab.com\/course1<\/a><\/p>\n<p class=\"\">&nbsp;<\/p>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp; Using MCU peripherals and implementing initialization codes &nbsp; &nbsp; Now let\u2019s learn more about how FreeRTOS schedules the FreeRTOS related tasks, how exactly the task executes, and for how many durations each task executes. You will understand all these topics as you make progress. Our goal was to create two tasks and use semihosting [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":6157,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"ocean_post_layout":"","ocean_both_sidebars_style":"","ocean_both_sidebars_content_width":0,"ocean_both_sidebars_sidebars_width":0,"ocean_sidebar":"0","ocean_second_sidebar":"0","ocean_disable_margins":"enable","ocean_add_body_class":"","ocean_shortcode_before_top_bar":"","ocean_shortcode_after_top_bar":"","ocean_shortcode_before_header":"","ocean_shortcode_after_header":"","ocean_has_shortcode":"","ocean_shortcode_after_title":"","ocean_shortcode_before_footer_widgets":"","ocean_shortcode_after_footer_widgets":"","ocean_shortcode_before_footer_bottom":"","ocean_shortcode_after_footer_bottom":"","ocean_display_top_bar":"default","ocean_display_header":"default","ocean_header_style":"","ocean_center_header_left_menu":"0","ocean_custom_header_template":"0","ocean_custom_logo":0,"ocean_custom_retina_logo":0,"ocean_custom_logo_max_width":0,"ocean_custom_logo_tablet_max_width":0,"ocean_custom_logo_mobile_max_width":0,"ocean_custom_logo_max_height":0,"ocean_custom_logo_tablet_max_height":0,"ocean_custom_logo_mobile_max_height":0,"ocean_header_custom_menu":"0","ocean_menu_typo_font_family":"0","ocean_menu_typo_font_subset":"","ocean_menu_typo_font_size":0,"ocean_menu_typo_font_size_tablet":0,"ocean_menu_typo_font_size_mobile":0,"ocean_menu_typo_font_size_unit":"px","ocean_menu_typo_font_weight":"","ocean_menu_typo_font_weight_tablet":"","ocean_menu_typo_font_weight_mobile":"","ocean_menu_typo_transform":"","ocean_menu_typo_transform_tablet":"","ocean_menu_typo_transform_mobile":"","ocean_menu_typo_line_height":0,"ocean_menu_typo_line_height_tablet":0,"ocean_menu_typo_line_height_mobile":0,"ocean_menu_typo_line_height_unit":"","ocean_menu_typo_spacing":0,"ocean_menu_typo_spacing_tablet":0,"ocean_menu_typo_spacing_mobile":0,"ocean_menu_typo_spacing_unit":"","ocean_menu_link_color":"","ocean_menu_link_color_hover":"","ocean_menu_link_color_active":"","ocean_menu_link_background":"","ocean_menu_link_hover_background":"","ocean_menu_link_active_background":"","ocean_menu_social_links_bg":"","ocean_menu_social_hover_links_bg":"","ocean_menu_social_links_color":"","ocean_menu_social_hover_links_color":"","ocean_disable_title":"default","ocean_disable_heading":"default","ocean_post_title":"","ocean_post_subheading":"","ocean_post_title_style":"","ocean_post_title_background_color":"","ocean_post_title_background":0,"ocean_post_title_bg_image_position":"","ocean_post_title_bg_image_attachment":"","ocean_post_title_bg_image_repeat":"","ocean_post_title_bg_image_size":"","ocean_post_title_height":0,"ocean_post_title_bg_overlay":0.5,"ocean_post_title_bg_overlay_color":"","ocean_disable_breadcrumbs":"default","ocean_breadcrumbs_color":"","ocean_breadcrumbs_separator_color":"","ocean_breadcrumbs_links_color":"","ocean_breadcrumbs_links_hover_color":"","ocean_display_footer_widgets":"default","ocean_display_footer_bottom":"default","ocean_custom_footer_template":"0","ocean_post_oembed":"","ocean_post_self_hosted_media":"","ocean_post_video_embed":"","ocean_link_format":"","ocean_link_format_target":"self","ocean_quote_format":"","ocean_quote_format_link":"post","ocean_gallery_link_images":"off","ocean_gallery_id":[],"footnotes":""},"categories":[8],"tags":[19],"class_list":["post-6154","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-blog","tag-freertos-lectures","entry","has-media"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.3 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Using MCU Peripherals and Implementing Initialization Codes in FreeRTOS<\/title>\n<meta name=\"description\" content=\"Learn how to configure and use the UART peripheral of a microcontroller in FreeRTOS to send logs to a computer over serial communication. MCU\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/fastbitlab.com\/blog\/using-mcu-peripherals-and-implementing-initialization-codes\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Using MCU Peripherals and Implementing Initialization Codes in FreeRTOS\" \/>\n<meta property=\"og:description\" content=\"Learn how to configure and use the UART peripheral of a microcontroller in FreeRTOS to send logs to a computer over serial communication. MCU\" \/>\n<meta property=\"og:url\" content=\"https:\/\/fastbitlab.com\/blog\/using-mcu-peripherals-and-implementing-initialization-codes\/\" \/>\n<meta property=\"og:site_name\" content=\"FastBit EBA\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/fastbiteba\/\" \/>\n<meta property=\"article:published_time\" content=\"2021-06-01T10:31:23+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-09-02T11:40:40+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/05\/Figure-1-6.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1919\" \/>\n\t<meta property=\"og:image:height\" content=\"1013\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"FastBitLab\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@fastbiteba\" \/>\n<meta name=\"twitter:site\" content=\"@fastbiteba\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"FastBitLab\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/using-mcu-peripherals-and-implementing-initialization-codes\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/using-mcu-peripherals-and-implementing-initialization-codes\\\/\"},\"author\":{\"name\":\"FastBitLab\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/#\\\/schema\\\/person\\\/e32b38e733a0d76ffa7e6bc998652e5d\"},\"headline\":\"FreeRTOS Lecture 33 &#8211; Using MCU peripherals and implementing initialization codes\",\"datePublished\":\"2021-06-01T10:31:23+00:00\",\"dateModified\":\"2023-09-02T11:40:40+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/using-mcu-peripherals-and-implementing-initialization-codes\\\/\"},\"wordCount\":707,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/using-mcu-peripherals-and-implementing-initialization-codes\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/wp-content\\\/uploads\\\/2021\\\/05\\\/Figure-1-6.png\",\"keywords\":[\"FreeRTOS Lectures\"],\"articleSection\":[\"Blog\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/using-mcu-peripherals-and-implementing-initialization-codes\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/using-mcu-peripherals-and-implementing-initialization-codes\\\/\",\"url\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/using-mcu-peripherals-and-implementing-initialization-codes\\\/\",\"name\":\"Using MCU Peripherals and Implementing Initialization Codes in FreeRTOS\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/using-mcu-peripherals-and-implementing-initialization-codes\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/using-mcu-peripherals-and-implementing-initialization-codes\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/wp-content\\\/uploads\\\/2021\\\/05\\\/Figure-1-6.png\",\"datePublished\":\"2021-06-01T10:31:23+00:00\",\"dateModified\":\"2023-09-02T11:40:40+00:00\",\"description\":\"Learn how to configure and use the UART peripheral of a microcontroller in FreeRTOS to send logs to a computer over serial communication. MCU\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/using-mcu-peripherals-and-implementing-initialization-codes\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/using-mcu-peripherals-and-implementing-initialization-codes\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/using-mcu-peripherals-and-implementing-initialization-codes\\\/#primaryimage\",\"url\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/wp-content\\\/uploads\\\/2021\\\/05\\\/Figure-1-6.png\",\"contentUrl\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/wp-content\\\/uploads\\\/2021\\\/05\\\/Figure-1-6.png\",\"width\":1919,\"height\":1013,\"caption\":\"Figure 1. Function to setup the hardware.\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/using-mcu-peripherals-and-implementing-initialization-codes\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"FreeRTOS Lecture 33 &#8211; Using MCU peripherals and implementing initialization codes\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/\",\"name\":\"FastBit EBA\",\"description\":\"Your Online Academy of Embedded Systems\",\"publisher\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/#organization\",\"name\":\"FastBit EBA\",\"url\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/04\\\/logo-EzNrEnyr.png\",\"contentUrl\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/04\\\/logo-EzNrEnyr.png\",\"width\":640,\"height\":640,\"caption\":\"FastBit EBA\"},\"image\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/fastbiteba\\\/\",\"https:\\\/\\\/x.com\\\/fastbiteba\",\"https:\\\/\\\/www.linkedin.com\\\/in\\\/fastbit-embedded-brain-academy-b3167b124\\\/\",\"https:\\\/\\\/www.youtube.com\\\/channel\\\/UCa1REBV9hyrzGp2mjJCagBg\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/#\\\/schema\\\/person\\\/e32b38e733a0d76ffa7e6bc998652e5d\",\"name\":\"FastBitLab\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/9230d0f9bdef28b63a01e7ca274ee7b2e8ed9abe932ee564af8809caaf52a0c8?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/9230d0f9bdef28b63a01e7ca274ee7b2e8ed9abe932ee564af8809caaf52a0c8?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/9230d0f9bdef28b63a01e7ca274ee7b2e8ed9abe932ee564af8809caaf52a0c8?s=96&d=mm&r=g\",\"caption\":\"FastBitLab\"},\"description\":\"The FastBit Embedded Brain Academy uses the power of internet to bring the online courses related to the field of embedded system programming, Real time operating system, Embedded Linux systems, etc at your finger tip with very low cost. Backed with strong experience of industry, we have produced lots of courses with the customer enrolment over 3000+ across 100+ countries.\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Using MCU Peripherals and Implementing Initialization Codes in FreeRTOS","description":"Learn how to configure and use the UART peripheral of a microcontroller in FreeRTOS to send logs to a computer over serial communication. MCU","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:\/\/fastbitlab.com\/blog\/using-mcu-peripherals-and-implementing-initialization-codes\/","og_locale":"en_US","og_type":"article","og_title":"Using MCU Peripherals and Implementing Initialization Codes in FreeRTOS","og_description":"Learn how to configure and use the UART peripheral of a microcontroller in FreeRTOS to send logs to a computer over serial communication. MCU","og_url":"https:\/\/fastbitlab.com\/blog\/using-mcu-peripherals-and-implementing-initialization-codes\/","og_site_name":"FastBit EBA","article_publisher":"https:\/\/www.facebook.com\/fastbiteba\/","article_published_time":"2021-06-01T10:31:23+00:00","article_modified_time":"2023-09-02T11:40:40+00:00","og_image":[{"width":1919,"height":1013,"url":"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/05\/Figure-1-6.png","type":"image\/png"}],"author":"FastBitLab","twitter_card":"summary_large_image","twitter_creator":"@fastbiteba","twitter_site":"@fastbiteba","twitter_misc":{"Written by":"FastBitLab","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/fastbitlab.com\/blog\/using-mcu-peripherals-and-implementing-initialization-codes\/#article","isPartOf":{"@id":"https:\/\/fastbitlab.com\/blog\/using-mcu-peripherals-and-implementing-initialization-codes\/"},"author":{"name":"FastBitLab","@id":"https:\/\/fastbitlab.com\/blog\/#\/schema\/person\/e32b38e733a0d76ffa7e6bc998652e5d"},"headline":"FreeRTOS Lecture 33 &#8211; Using MCU peripherals and implementing initialization codes","datePublished":"2021-06-01T10:31:23+00:00","dateModified":"2023-09-02T11:40:40+00:00","mainEntityOfPage":{"@id":"https:\/\/fastbitlab.com\/blog\/using-mcu-peripherals-and-implementing-initialization-codes\/"},"wordCount":707,"commentCount":0,"publisher":{"@id":"https:\/\/fastbitlab.com\/blog\/#organization"},"image":{"@id":"https:\/\/fastbitlab.com\/blog\/using-mcu-peripherals-and-implementing-initialization-codes\/#primaryimage"},"thumbnailUrl":"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/05\/Figure-1-6.png","keywords":["FreeRTOS Lectures"],"articleSection":["Blog"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/fastbitlab.com\/blog\/using-mcu-peripherals-and-implementing-initialization-codes\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/fastbitlab.com\/blog\/using-mcu-peripherals-and-implementing-initialization-codes\/","url":"https:\/\/fastbitlab.com\/blog\/using-mcu-peripherals-and-implementing-initialization-codes\/","name":"Using MCU Peripherals and Implementing Initialization Codes in FreeRTOS","isPartOf":{"@id":"https:\/\/fastbitlab.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/fastbitlab.com\/blog\/using-mcu-peripherals-and-implementing-initialization-codes\/#primaryimage"},"image":{"@id":"https:\/\/fastbitlab.com\/blog\/using-mcu-peripherals-and-implementing-initialization-codes\/#primaryimage"},"thumbnailUrl":"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/05\/Figure-1-6.png","datePublished":"2021-06-01T10:31:23+00:00","dateModified":"2023-09-02T11:40:40+00:00","description":"Learn how to configure and use the UART peripheral of a microcontroller in FreeRTOS to send logs to a computer over serial communication. MCU","breadcrumb":{"@id":"https:\/\/fastbitlab.com\/blog\/using-mcu-peripherals-and-implementing-initialization-codes\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/fastbitlab.com\/blog\/using-mcu-peripherals-and-implementing-initialization-codes\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/fastbitlab.com\/blog\/using-mcu-peripherals-and-implementing-initialization-codes\/#primaryimage","url":"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/05\/Figure-1-6.png","contentUrl":"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/05\/Figure-1-6.png","width":1919,"height":1013,"caption":"Figure 1. Function to setup the hardware."},{"@type":"BreadcrumbList","@id":"https:\/\/fastbitlab.com\/blog\/using-mcu-peripherals-and-implementing-initialization-codes\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/fastbitlab.com\/blog\/"},{"@type":"ListItem","position":2,"name":"FreeRTOS Lecture 33 &#8211; Using MCU peripherals and implementing initialization codes"}]},{"@type":"WebSite","@id":"https:\/\/fastbitlab.com\/blog\/#website","url":"https:\/\/fastbitlab.com\/blog\/","name":"FastBit EBA","description":"Your Online Academy of Embedded Systems","publisher":{"@id":"https:\/\/fastbitlab.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/fastbitlab.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/fastbitlab.com\/blog\/#organization","name":"FastBit EBA","url":"https:\/\/fastbitlab.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/fastbitlab.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2026\/04\/logo-EzNrEnyr.png","contentUrl":"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2026\/04\/logo-EzNrEnyr.png","width":640,"height":640,"caption":"FastBit EBA"},"image":{"@id":"https:\/\/fastbitlab.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/fastbiteba\/","https:\/\/x.com\/fastbiteba","https:\/\/www.linkedin.com\/in\/fastbit-embedded-brain-academy-b3167b124\/","https:\/\/www.youtube.com\/channel\/UCa1REBV9hyrzGp2mjJCagBg"]},{"@type":"Person","@id":"https:\/\/fastbitlab.com\/blog\/#\/schema\/person\/e32b38e733a0d76ffa7e6bc998652e5d","name":"FastBitLab","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/9230d0f9bdef28b63a01e7ca274ee7b2e8ed9abe932ee564af8809caaf52a0c8?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/9230d0f9bdef28b63a01e7ca274ee7b2e8ed9abe932ee564af8809caaf52a0c8?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/9230d0f9bdef28b63a01e7ca274ee7b2e8ed9abe932ee564af8809caaf52a0c8?s=96&d=mm&r=g","caption":"FastBitLab"},"description":"The FastBit Embedded Brain Academy uses the power of internet to bring the online courses related to the field of embedded system programming, Real time operating system, Embedded Linux systems, etc at your finger tip with very low cost. Backed with strong experience of industry, we have produced lots of courses with the customer enrolment over 3000+ across 100+ countries."}]}},"_links":{"self":[{"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/posts\/6154","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/comments?post=6154"}],"version-history":[{"count":5,"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/posts\/6154\/revisions"}],"predecessor-version":[{"id":15735,"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/posts\/6154\/revisions\/15735"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/media\/6157"}],"wp:attachment":[{"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/media?parent=6154"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/categories?post=6154"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/tags?post=6154"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}