{"id":6203,"date":"2021-06-03T09:56:28","date_gmt":"2021-06-03T09:56:28","guid":{"rendered":"http:\/\/fastbitlab.com\/?p=6203"},"modified":"2023-09-04T10:36:22","modified_gmt":"2023-09-04T05:06:22","slug":"uart-pin-configuration-using-std-peripheral-library-apis","status":"publish","type":"post","link":"https:\/\/fastbitlab.com\/blog\/uart-pin-configuration-using-std-peripheral-library-apis\/","title":{"rendered":"FreeRTOS Lecture 35 &#8211; UART pin configuration using STD. Peripheral Library APIs"},"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: 31px; border-width: 0px; line-height: 50px;\"><span style=\"color: #000080;\">UART pin configuration using STD. Peripheral Library APIs<\/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<ul 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=\"\">\n<li><span style=\"font-weight: 400; color: #000000;\">The second step is to configure the GPIO port A pin number 2 to behave as UART2 TX and GPIO port A pin number 3 to behave as UART2 RX. We call this step a pin alternate function configuration. For this, you have to use the GPIO driver of the standard peripheral layer since these are with respect to the pin configuration. In order to configure the pin, you have to refer to the GPIO (General Purpose I\/O).<\/span><\/li>\n<\/ul>\n<p class=\"\" style=\"margin-left: 40px; 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 go to the GPIO driver (Figure 1), here you will see various APIs in order to handle or change the mode of a microcontroller pin. In GPIO driver, you can see GPIO_DeInit, GPIO_Init, etc.<\/span><\/p>\n<figure id=\"attachment_6205\" aria-describedby=\"caption-attachment-6205\" style=\"width: 744px\" class=\"wp-caption aligncenter\"><img fetchpriority=\"high\" decoding=\"async\" class=\"wp-image-6205\" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2021\/06\/Figure-1-1.png\" alt=\"Figure 1. stm32f4xx_gpio.c.\" width=\"744\" height=\"396\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-1-1.png 1919w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-1-1-300x160.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-1-1-768x409.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-1-1-1024x545.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-1-1-600x319.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-1-1-120x64.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-1-1-500x266.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-1-1-200x106.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-1-1-400x213.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-1-1-800x426.png 800w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-1-1-1200x638.png 1200w\" sizes=\"(max-width: 744px) 100vw, 744px\" \/><figcaption id=\"caption-attachment-6205\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 1. stm32f4xx_gpio.c.<\/span><\/figcaption><\/figure>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"margin-left: 40px; 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;\">We are interested in GPIO_Init. Let\u2019s open and explore GPIO_Init (Figure 2).<\/span><\/p>\n<p class=\"\" style=\"margin-left: 40px; 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 initializes the GPIOx peripheral. We are using PA2 and PA3. That means GPIOA pin number 2 and GPIOA pin number 3. So, you have to populate the GPIO_InitTypeDef structure, and then you have to pass the address of that structure as an argument to this GPIO_Init function in order to carry out the initialization.<\/span><\/p>\n<pre class=\"color-neutral-text-contrast color-neutral-background-color\" style=\"padding-left: 40px; font-size: 12px; box-shadow: #cecece 0px 0px 0px 0px;\"><span style=\"color: #ff99cc;\">void<\/span> GPIO_Init(<span style=\"color: #008000;\">GPIO_TypeDef<\/span>* GPIOx, <span style=\"color: #008000;\">GPIO_InitTypeDef<\/span>* GPIO_InitStruct)<\/pre>\n<figure id=\"attachment_6206\" aria-describedby=\"caption-attachment-6206\" style=\"width: 744px\" class=\"wp-caption aligncenter\"><img decoding=\"async\" class=\"wp-image-6206\" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2021\/06\/Figure-2-1.png\" alt=\"Figure 2. GPIO_Init API.\" width=\"744\" height=\"394\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-2-1.png 1915w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-2-1-300x159.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-2-1-768x407.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-2-1-1024x543.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-2-1-600x318.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-2-1-120x64.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-2-1-500x265.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-2-1-200x106.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-2-1-400x212.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-2-1-800x424.png 800w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-2-1-1200x636.png 1200w\" sizes=\"(max-width: 744px) 100vw, 744px\" \/><figcaption id=\"caption-attachment-6206\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 2. GPIO_Init API.<\/span><\/figcaption><\/figure>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"margin-left: 40px; 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 the GPIO_Init API, go to the main.c, and paste it, as shown in Figure 3.<\/span><\/p>\n<figure id=\"attachment_6207\" aria-describedby=\"caption-attachment-6207\" style=\"width: 744px\" class=\"wp-caption aligncenter\"><img decoding=\"async\" class=\"wp-image-6207\" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2021\/06\/Figure-3-1.png\" alt=\"Figure 3. GPIO_Init API in main.c.\" width=\"744\" height=\"398\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-3-1.png 1919w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-3-1-300x160.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-3-1-768x410.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-3-1-1024x547.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-3-1-600x320.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-3-1-120x64.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-3-1-500x267.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-3-1-200x107.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-3-1-400x214.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-3-1-800x427.png 800w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-3-1-1200x641.png 1200w\" sizes=\"(max-width: 744px) 100vw, 744px\" \/><figcaption id=\"caption-attachment-6207\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 3. GPIO_Init API in main.c.<\/span><\/figcaption><\/figure>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"margin-left: 40px; 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;\">First, let\u2019s create a variable for the structure type GPIO_InitTypeDef and call it as gpio_uart_pins (Figure 4).<\/span><\/p>\n<figure id=\"attachment_6208\" aria-describedby=\"caption-attachment-6208\" style=\"width: 744px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-6208\" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2021\/06\/Figure-4-1.png\" alt=\"Figure 4. Creation of structure type variable.\" width=\"744\" height=\"396\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-4-1.png 1917w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-4-1-300x160.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-4-1-768x409.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-4-1-1024x545.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-4-1-600x320.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-4-1-120x64.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-4-1-500x266.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-4-1-200x107.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-4-1-400x213.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-4-1-800x426.png 800w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-4-1-1200x639.png 1200w\" sizes=\"(max-width: 744px) 100vw, 744px\" \/><figcaption id=\"caption-attachment-6208\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 4. Creation of structure type variable.<\/span><\/figcaption><\/figure>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"margin-left: 40px; 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 just populate the structure gpio_uart_pins. <\/span><\/p>\n<p class=\"\" style=\"margin-left: 40px; 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;\">Write gpio_uart_pins, give a dot (.) operator, and let\u2019s start accessing member elements. <\/span><\/p>\n<p class=\"\" style=\"margin-left: 40px; 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;\">First one, you have to mention what exactly is the pin number. We are using PA2 and PA3. First, let\u2019s configure PA2. <\/span><\/p>\n<p class=\"\" style=\"margin-left: 40px; 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 configuring PA2, you have to use the macros given by the standard peripheral driver. Just type GPIO_PIN_2, as shown in Figure 5.<\/span><\/p>\n<p class=\"\" style=\"margin-left: 40px; 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 don\u2019t understand what exactly is the macro name you have to use, then explore the member element GPIO_Pin marked in Figure 5. There you will find a reference (Figure 6). Always give attention to this ref, and here they are asking you to go and check the GPIO_pins_define. <\/span><\/p>\n<p class=\"\" style=\"margin-left: 40px; 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 copy GPIO_pins_define and search in the header file (stm32f4xx_gpio.h), as shown in Figure 7. It will take you to the pin\u2019s definition (Figure 8); you have to choose one among these. Since we want to configure pin number 2, we used PA2.<\/span><\/p>\n<figure id=\"attachment_6209\" aria-describedby=\"caption-attachment-6209\" style=\"width: 744px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-6209\" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2021\/06\/Figure-5-1.png\" alt=\"Figure 5. Configuring GPIO pin 2.\" width=\"744\" height=\"395\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-5-1.png 1917w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-5-1-300x159.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-5-1-768x407.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-5-1-1024x543.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-5-1-600x318.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-5-1-120x64.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-5-1-500x265.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-5-1-200x106.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-5-1-400x212.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-5-1-800x424.png 800w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-5-1-1200x637.png 1200w\" sizes=\"(max-width: 744px) 100vw, 744px\" \/><figcaption id=\"caption-attachment-6209\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 5. Configuring GPIO pin 2.<\/span><\/figcaption><\/figure>\n<p class=\"\">&nbsp;<\/p>\n<pre class=\"color-neutral-text-contrast color-neutral-background-color\" style=\"font-size: 12px; box-shadow: #cecece 0px 0px 0px 0px;\">typedef struct\r\n{\r\n<span style=\"color: #ff99cc;\">uint32_t<\/span> GPIO_Pin; <span style=\"color: #008000;\">\/*!&lt; Specifies the GPIO pins to be configured.<\/span>\r\n<span style=\"color: #008000;\">This parameter can be any value of @ref GPIO_pins_define *\/<\/span>\r\n\r\nGPIOMode_TypeDef GPIO_Mode; <span style=\"color: #008000;\">\/*!&lt; Specifies the operating mode for the selected pins.<\/span>\r\n<span style=\"color: #008000;\">This parameter can be a value of @ref GPIOMode_TypeDef *\/<\/span>\r\n\r\nGPIOSpeed_TypeDef GPIO_Speed; <span style=\"color: #008000;\">\/*!&lt; Specifies the speed for the selected pins.<\/span>\r\n<span style=\"color: #008000;\">This parameter can be a value of @ref GPIOSpeed_TypeDef *\/<\/span>\r\n\r\nGPIOOType_TypeDef GPIO_OType; <span style=\"color: #008000;\">\/*!&lt; Specifies the operating output type for the selected pins.<\/span>\r\n<span style=\"color: #008000;\">This parameter can be a value of @ref GPIOOType_TypeDef *\/<\/span>\r\n\r\nGPIOPuPd_TypeDef GPIO_PuPd; \/*!&lt; Specifies the operating Pull-up\/Pull down for the selected pins.\r\nThis parameter can be a value of @ref GPIOPuPd_TypeDef *\/\r\n}GPIO_InitTypeDef;<\/pre>\n<p class=\"\" style=\"text-align: center;\"><span style=\"color: #000000;\">Reference for GPIO_Pin<\/span><\/p>\n<figure id=\"attachment_6210\" aria-describedby=\"caption-attachment-6210\" style=\"width: 744px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-6210\" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2021\/06\/Figure-6-1.png\" alt=\"Figure 6. Reference for GPIO_Pin.\" width=\"744\" height=\"395\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-6-1.png 1919w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-6-1-300x159.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-6-1-768x407.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-6-1-1024x543.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-6-1-600x318.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-6-1-120x64.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-6-1-500x265.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-6-1-200x106.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-6-1-400x212.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-6-1-800x424.png 800w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-6-1-1200x636.png 1200w\" sizes=\"(max-width: 744px) 100vw, 744px\" \/><figcaption id=\"caption-attachment-6210\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 6. Reference for GPIO_Pin.<\/span><\/figcaption><\/figure>\n<p class=\"\">&nbsp;<\/p>\n<figure id=\"attachment_6211\" aria-describedby=\"caption-attachment-6211\" style=\"width: 744px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-6211\" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2021\/06\/Figure-7-1.png\" alt=\"Figure 7. Searching for GPIO_pins_define in stm32f4xx_gpio.h.\" width=\"744\" height=\"396\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-7-1.png 1919w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-7-1-300x160.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-7-1-768x409.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-7-1-1024x545.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-7-1-600x319.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-7-1-120x64.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-7-1-500x266.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-7-1-200x106.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-7-1-400x213.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-7-1-800x426.png 800w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-7-1-1200x638.png 1200w\" sizes=\"(max-width: 744px) 100vw, 744px\" \/><figcaption id=\"caption-attachment-6211\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 7. Searching for GPIO_pins_define in stm32f4xx_gpio.h.<\/span><\/figcaption><\/figure>\n<p class=\"\">&nbsp;<\/p>\n<figure id=\"attachment_6212\" aria-describedby=\"caption-attachment-6212\" style=\"width: 744px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-6212\" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2021\/06\/Figure-8-1.png\" alt=\"Figure 8. Pin\u2019s definition.\" width=\"744\" height=\"396\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-8-1.png 1915w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-8-1-300x159.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-8-1-768x408.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-8-1-1024x544.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-8-1-600x319.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-8-1-120x64.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-8-1-500x266.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-8-1-200x106.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-8-1-400x212.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-8-1-800x425.png 800w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-8-1-1200x637.png 1200w\" sizes=\"(max-width: 744px) 100vw, 744px\" \/><figcaption id=\"caption-attachment-6212\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 8. Pin\u2019s definition.<\/span><\/figcaption><\/figure>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"margin-left: 40px; 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;\">No need to configure the GPIO_Speed that is not relevant. So, let\u2019s use the default value there in the microcontroller. We took the default speed because this speed does nothing with the UART baud rate. This is pin transition speed, i.e., the switching speed of the GPIO engine so, we need not configure it.<\/span><\/p>\n<p class=\"\" style=\"margin-left: 40px; 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, let\u2019s configure the mode. <\/span><\/p>\n<p class=\"\" style=\"margin-left: 40px; 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 we don\u2019t know what exactly the mode we have to use. To know the mode information, just go to the GPIO_Mode marked in Figure 9 and explore from the reference shown in Figure 10. This specifies the operating mode for the selected pins. <\/span><\/p>\n<p class=\"\" style=\"margin-left: 40px; 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 what are the modes available. <\/span><\/p>\n<p class=\"\" style=\"margin-left: 40px; 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, just copy the GPIOMode_TypeDef (Figure 10) and search in the header file (stm32f4xx_gpio.h), as shown in Figure 11. <\/span><\/p>\n<p class=\"\" style=\"margin-left: 40px; 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 in Figure 12, you can see all the available modes. You can put the I\/O as GPIO_In, GPIO_Out, alternate function, or analog mode. <\/span><\/p>\n<p class=\"\" style=\"margin-left: 40px; 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 example, we are giving the GPIO pin to the UART peripheral. UART is going to use that pin. That\u2019s why the mode is actually an alternate function mode. We are using the pins for alternate functionality, i.e., UART functionality. To be specific we are using PA2 as UART TX. That means we have to assign alternate functionality to that pin. That\u2019s why, for PA2, we have to select mode as GPIO_Mode_AF (Figure 9).<\/span><\/p>\n<figure id=\"attachment_6213\" aria-describedby=\"caption-attachment-6213\" style=\"width: 744px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-6213\" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2021\/06\/Figure-9-1.png\" alt=\"Figure 9. Configuring pin mode.\" width=\"744\" height=\"396\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-9-1.png 1919w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-9-1-300x159.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-9-1-768x408.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-9-1-1024x544.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-9-1-600x319.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-9-1-120x64.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-9-1-500x266.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-9-1-200x106.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-9-1-400x212.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-9-1-800x425.png 800w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-9-1-1200x637.png 1200w\" sizes=\"(max-width: 744px) 100vw, 744px\" \/><figcaption id=\"caption-attachment-6213\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 9. Configuring pin mode.<\/span><\/figcaption><\/figure>\n<p class=\"\">&nbsp;<\/p>\n<figure id=\"attachment_6214\" aria-describedby=\"caption-attachment-6214\" style=\"width: 744px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-6214\" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2021\/06\/Figure-10-1.png\" alt=\"Figure 10. Reference for GPIO_Mode. UART pin configuration using STD. Peripheral Library APIs\" width=\"744\" height=\"393\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-10-1.png 1919w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-10-1-300x159.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-10-1-768x406.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-10-1-1024x542.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-10-1-600x317.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-10-1-120x63.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-10-1-500x264.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-10-1-200x106.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-10-1-400x212.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-10-1-800x423.png 800w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-10-1-1200x635.png 1200w\" sizes=\"(max-width: 744px) 100vw, 744px\" \/><figcaption id=\"caption-attachment-6214\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 10. Reference for GPIO_Mode.<\/span><\/figcaption><\/figure>\n<p class=\"\">&nbsp;<\/p>\n<figure id=\"attachment_6215\" aria-describedby=\"caption-attachment-6215\" style=\"width: 744px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-6215\" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2021\/06\/Figure-11.png\" alt=\"Figure 11. Searching for GPIOMode_TypeDef. UART pin configuration using STD. Peripheral Library APIs\" width=\"744\" height=\"396\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-11.png 1917w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-11-300x159.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-11-768x408.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-11-1024x544.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-11-600x319.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-11-120x64.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-11-500x266.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-11-200x106.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-11-400x213.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-11-800x425.png 800w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-11-1200x638.png 1200w\" sizes=\"(max-width: 744px) 100vw, 744px\" \/><figcaption id=\"caption-attachment-6215\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 11. Searching for GPIOMode_TypeDef.<\/span><\/figcaption><\/figure>\n<p class=\"\">&nbsp;<\/p>\n<figure id=\"attachment_6216\" aria-describedby=\"caption-attachment-6216\" style=\"width: 744px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-6216\" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2021\/06\/Figure-12.png\" alt=\"Figure 12. Available modes. UART pin configuration using STD. Peripheral Library APIs\" width=\"744\" height=\"393\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-12.png 1917w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-12-300x159.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-12-768x406.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-12-1024x541.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-12-600x317.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-12-120x63.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-12-500x264.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-12-200x106.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-12-400x211.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-12-800x423.png 800w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-12-1200x634.png 1200w\" sizes=\"(max-width: 744px) 100vw, 744px\" \/><figcaption id=\"caption-attachment-6216\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 12. Available modes.<\/span><\/figcaption><\/figure>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"margin-left: 40px; 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 proceed to configure the output type. The output type is actually not usable for this configuration because the mode is not output mode. That\u2019s why there is no need to configure the output type. Leave it as it is.<\/span><\/p>\n<p class=\"\" style=\"margin-left: 40px; 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;\">Next, we have to configure pull up or pull down. <\/span><\/p>\n<p class=\"\" style=\"margin-left: 40px; 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 what are the options available for pull up or pull down. Go to the GPIO_PuPd member element shown in Figure 13. Copy the reference GPIOPuPd_Typedef and search for it in stm32f4xx_gpio.h, as shown in Figure 14. <\/span><\/p>\n<p class=\"\" style=\"margin-left: 40px; 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;\">Look at Figure 15. You have a couple of options for pull up or pull down. For this example, let\u2019s go for GPIO pull up\/ pull down as pull up (GPIO_PuPd_UP) because whenever the UART TX or RX line is idle, the bus state will be high, i.e., logical 1.<\/span><\/p>\n<p class=\"\" style=\"margin-left: 40px; 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 observe the UART communication shown in Figure 16, when the line is idle, then it is pulled to high. Idle means no message is getting transferred over the TX and RX line. That\u2019s why we made GPIO_PuPd as UP (Figure 17).<\/span><\/p>\n<figure id=\"attachment_6217\" aria-describedby=\"caption-attachment-6217\" style=\"width: 744px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-6217\" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2021\/06\/Figure-13.png\" alt=\"Figure 13. Reference for GPIO_PuPd. UART pin configuration using STD. Peripheral Library APIs\" width=\"744\" height=\"395\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-13.png 1917w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-13-300x159.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-13-768x407.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-13-1024x543.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-13-600x318.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-13-120x64.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-13-500x265.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-13-200x106.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-13-400x212.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-13-800x424.png 800w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-13-1200x637.png 1200w\" sizes=\"(max-width: 744px) 100vw, 744px\" \/><figcaption id=\"caption-attachment-6217\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 13. Reference for GPIO_PuPd.<\/span><\/figcaption><\/figure>\n<p class=\"\">&nbsp;<\/p>\n<figure id=\"attachment_6219\" aria-describedby=\"caption-attachment-6219\" style=\"width: 744px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-6219\" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2021\/06\/Figure-14.png\" alt=\"Figure 14. Searching for GPIOPuPd_Typedef. UART pin configuration using STD. Peripheral Library APIs\" width=\"744\" height=\"397\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-14.png 1915w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-14-300x160.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-14-768x409.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-14-1024x546.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-14-600x320.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-14-120x64.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-14-500x267.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-14-200x107.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-14-400x213.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-14-800x427.png 800w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-14-1200x640.png 1200w\" sizes=\"(max-width: 744px) 100vw, 744px\" \/><figcaption id=\"caption-attachment-6219\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 14. Searching for GPIOPuPd_Typedef.<\/span><\/figcaption><\/figure>\n<p class=\"\">&nbsp;<\/p>\n<figure id=\"attachment_6220\" aria-describedby=\"caption-attachment-6220\" style=\"width: 744px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-6220\" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2021\/06\/Figure-15.png\" alt=\"Figure 15. Options for pull up\/ pull down. UART pin configuration using STD. Peripheral Library APIs\" width=\"744\" height=\"395\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-15.png 1917w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-15-300x159.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-15-768x407.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-15-1024x543.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-15-600x318.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-15-120x64.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-15-500x265.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-15-200x106.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-15-400x212.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-15-800x424.png 800w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-15-1200x637.png 1200w\" sizes=\"(max-width: 744px) 100vw, 744px\" \/><figcaption id=\"caption-attachment-6220\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 15. Options for pull up\/ pull down.<\/span><\/figcaption><\/figure>\n<p class=\"\">&nbsp;<\/p>\n<figure id=\"attachment_6221\" aria-describedby=\"caption-attachment-6221\" style=\"width: 744px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-6221\" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2021\/06\/Figure-16.png\" alt=\"Figure 16. Basic frame structure.\" width=\"744\" height=\"213\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-16.png 1801w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-16-300x86.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-16-768x220.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-16-1024x293.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-16-600x172.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-16-120x34.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-16-500x143.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-16-200x57.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-16-400x114.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-16-800x229.png 800w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-16-1200x343.png 1200w\" sizes=\"(max-width: 744px) 100vw, 744px\" \/><figcaption id=\"caption-attachment-6221\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 16. Basic frame structure.<\/span><\/figcaption><\/figure>\n<p class=\"\">&nbsp;<\/p>\n<figure id=\"attachment_6222\" aria-describedby=\"caption-attachment-6222\" style=\"width: 744px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-6222\" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2021\/06\/Figure-17.png\" alt=\"Figure 17. Configuring GPIO pull up\/ pull down. UART pin configuration using STD. Peripheral Library APIs\" width=\"744\" height=\"396\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-17.png 1915w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-17-300x159.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-17-768x408.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-17-1024x544.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-17-600x319.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-17-120x64.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-17-500x266.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-17-200x106.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-17-400x212.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-17-800x425.png 800w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-17-1200x637.png 1200w\" sizes=\"(max-width: 744px) 100vw, 744px\" \/><figcaption id=\"caption-attachment-6222\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 17. Configuring GPIO pull up\/ pull down.<\/span><\/figcaption><\/figure>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"margin-left: 40px; 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 all the above configuration, call GPIO_Init function (Figure 18) and let\u2019s send the address of the structure variable, i.e., gpio_uart_pins as the second argument of it. The first parameter is the base address of the GPIOA peripheral.<\/span><\/p>\n<figure id=\"attachment_6223\" aria-describedby=\"caption-attachment-6223\" style=\"width: 744px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-6223\" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2021\/06\/Figure-18.png\" alt=\"Figure 18. Call for GPIO_Init function. UART pin configuration using STD. Peripheral Library APIs\" width=\"744\" height=\"399\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-18.png 1913w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-18-300x161.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-18-768x412.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-18-1024x549.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-18-600x321.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-18-120x64.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-18-500x268.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-18-200x107.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-18-400x214.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-18-800x429.png 800w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-18-1200x643.png 1200w\" sizes=\"(max-width: 744px) 100vw, 744px\" \/><figcaption id=\"caption-attachment-6223\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 18. Call for GPIO_Init function.<\/span><\/figcaption><\/figure>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"margin-left: 40px; 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 Figure 18, we are actually doing configuration to GPIOA peripheral to behave as the alternate function mode. That\u2019s why we have to enable the GPIOA peripheral clock, which we can do, as shown in Figure 19. Since the GPIOA peripheral is hanging on the AHB1 bus, you have to enable the AHB1 clock.<\/span><\/p>\n<figure id=\"attachment_6224\" aria-describedby=\"caption-attachment-6224\" style=\"width: 744px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-6224\" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2021\/06\/Figure-19.png\" alt=\"Figure 19. Enabling the clock for GPIOA peripheral. UART pin configuration using STD. Peripheral Library APIs\" width=\"744\" height=\"396\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-19.png 1915w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-19-300x160.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-19-768x409.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-19-1024x545.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-19-600x319.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-19-120x64.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-19-500x266.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-19-200x106.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-19-400x213.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-19-800x426.png 800w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-19-1200x639.png 1200w\" sizes=\"(max-width: 744px) 100vw, 744px\" \/><figcaption id=\"caption-attachment-6224\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 19. Enabling the clock for GPIOA peripheral.<\/span><\/figcaption><\/figure>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"margin-left: 40px; 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;\">Here you have to configure both pin 2 and pin 3. That\u2019s why let\u2019s do bitwise OR of GPIO pin 2 and GPIO pin 3 (Figure 20). <\/span><\/p>\n<p class=\"\" style=\"margin-left: 40px; 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 both the GPIOA pin numbers 2 and 3 are configured for alternate functionality mode by doing some settings into the GPIOA registers. Since we touch the GPIOA registers, we have to enable the clock for that. Because before configuring the GPIOA, it should be alive.<\/span><\/p>\n<figure id=\"attachment_6225\" aria-describedby=\"caption-attachment-6225\" style=\"width: 744px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-6225\" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2021\/06\/Figure-20.png\" alt=\"Figure 20. ORing GPIOA pin 2 with GPIOA pin 3. UART pin configuration using STD. Peripheral Library APIs\" width=\"744\" height=\"396\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-20.png 1915w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-20-300x160.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-20-768x409.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-20-1024x545.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-20-600x319.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-20-120x64.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-20-500x266.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-20-200x106.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-20-400x213.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-20-800x426.png 800w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-20-1200x639.png 1200w\" sizes=\"(max-width: 744px) 100vw, 744px\" \/><figcaption id=\"caption-attachment-6225\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 20. ORing GPIOA pin 2 with GPIOA pin 3.<\/span><\/figcaption><\/figure>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"margin-left: 40px; 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 go to the GPIO driver once again. <\/span><\/p>\n<p class=\"\" style=\"margin-left: 40px; 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;\">There is one more API called GPIO_PinAFConfig, i.e., GPIO pin alternate function configure. For this function, you have to mention the pin source and its alternate functionality mode (Figure 21). It is very easy to understand if you check the datasheet. <\/span><\/p>\n<p class=\"\" style=\"margin-left: 40px; 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 go to the datasheet once again and go to the alternate function (Figure 22).<\/span><\/p>\n<figure id=\"attachment_6226\" aria-describedby=\"caption-attachment-6226\" style=\"width: 744px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-6226\" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2021\/06\/Figure-21.png\" alt=\"UART pin configuration using STD. Peripheral Library APIs. Figure 21. GPIO_PinAFConfig API.\" width=\"744\" height=\"396\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-21.png 1915w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-21-300x159.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-21-768x408.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-21-1024x544.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-21-600x319.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-21-120x64.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-21-500x266.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-21-200x106.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-21-400x212.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-21-800x425.png 800w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-21-1200x637.png 1200w\" sizes=\"(max-width: 744px) 100vw, 744px\" \/><figcaption id=\"caption-attachment-6226\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 21. GPIO_PinAFConfig API.<\/span><\/figcaption><\/figure>\n<p class=\"\">&nbsp;<\/p>\n<figure id=\"attachment_6227\" aria-describedby=\"caption-attachment-6227\" style=\"width: 744px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-6227\" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2021\/06\/Figure-22.png\" alt=\"Figure 22. Alternate function table. UART pin configuration using STD. Peripheral Library APIs\" width=\"744\" height=\"399\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-22.png 1793w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-22-300x161.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-22-768x412.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-22-1024x549.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-22-600x322.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-22-120x64.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-22-500x268.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-22-200x107.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-22-400x214.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-22-800x429.png 800w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-22-1200x643.png 1200w\" sizes=\"(max-width: 744px) 100vw, 744px\" \/><figcaption id=\"caption-attachment-6227\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 22. Alternate function table.<\/span><\/figcaption><\/figure>\n<p class=\"\" style=\"margin-left: 40px; 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;\">According to the table given in Figure 22, the PA2 can act as TX only when the alternate function mode is 7, and also remember that PA2 cannot act as RX. That means you can never be able to achieve PA3 acting as TX. The microcontroller will not allow PA3 to act as TX. So, PA2 can act as TX when it is configured for AF7, and PA3 can act as RX only when you configure it in alternate function 7. <\/span><\/p>\n<p class=\"\" style=\"margin-left: 40px; 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 do that using the GPIO_PinAFConfig function. You have to mention the pin source as a second parameter. The pin source specifies the pin, and the third parameter is alternate functionality mode.<\/span><\/p>\n<p class=\"\">&nbsp;<\/p>\n<ul 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=\"\">\n<li><span style=\"font-weight: 400; color: #000000;\">The third step is AF mode settings for the pins (Figure 23). For GPIO_PinAFConfig, first, you have to mention the peripheral base address, i.e., GPIOA. <\/span><\/li>\n<\/ul>\n<p class=\"\" style=\"padding-left: 40px; 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;\">The next parameter is pin source, i.e., PA2, and you have to keep in alternate function mode AF7, i.e., GPIO_AF_USART2. If you check the macro GPIO_AF_USART2, then that is nothing but 0x07, as expected. Now, PA2 is configured as TX.<\/span><\/p>\n<figure id=\"attachment_6228\" aria-describedby=\"caption-attachment-6228\" style=\"width: 744px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-6228\" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2021\/06\/Figure-23.png\" alt=\"Figure 23. Configuring PA2 as UART2 TX. UART pin configuration using STD. Peripheral Library APIs\" width=\"744\" height=\"400\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-23.png 1897w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-23-300x161.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-23-768x412.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-23-1024x549.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-23-600x322.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-23-120x64.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-23-500x268.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-23-200x107.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-23-400x214.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-23-800x429.png 800w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-23-1200x643.png 1200w\" sizes=\"(max-width: 744px) 100vw, 744px\" \/><figcaption id=\"caption-attachment-6228\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 23. Configuring PA2 as UART2 TX.<\/span><\/figcaption><\/figure>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"font-size: 17px; line-height: 30px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">Now let\u2019s do the same thing for PA3. Just change the pin source to GPIO_PinSource3 here. Now, PA3 will be behaving as UART2 RX.<\/span><\/p>\n<pre class=\"color-5-text-contrast color5-background-color\" style=\"box-shadow: #cecece 0px 0px 0px 0px inset; font-size: 12px;\"><span style=\"color: #ff99cc;\">static void<\/span> prvSetupUart(<span style=\"color: #ff99cc;\">void<\/span>)\r\n{\r\n  <span style=\"color: #008000;\"> GPIO_InitTypeDef<\/span> gpio_uart_pins;\r\n\r\n   <span style=\"color: #008000;\">\/\/1. Enable the UART2 and GPIOA Peripheral clock<\/span>\r\n   RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART2,ENABLE);\r\n   RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA,ENABLE);\r\n\r\n   <span style=\"color: #008000;\">\/\/PA2 is UART2_TX, PA3 is UART2_RX<\/span>\r\n\r\n  <span style=\"color: #008000;\"> \/\/2. Alternate function configuration of MCU pins to behave as UART2 TX and RX<\/span>\r\n\r\n   gpio_uart_pins.GPIO_Pin = GPIO_Pin_2 | GPIO_Pin_3;\r\n   gpio_uart_pins.GPIO_Mode = GPIO_Mode_AF;\r\n   gpio_uart_pins.GPIO_PuPd = GPIO_PuPd_UP;\r\n   GPIO_Init(GPIOA, &amp;gpio_uart_pins);\r\n\r\n  <span style=\"color: #008000;\"> \/\/3. AF mode settings for the pins<\/span>\r\n   GPIO_PinAFConfig(GPIOA,GPIO_PinSource2,GPIO_AF_USART2); <span style=\"color: #008000;\">\/\/PA2<\/span>\r\n   GPIO_PinAFConfig(GPIOA,GPIO_PinSource3,GPIO_AF_USART2); <span style=\"color: #008000;\">\/\/PA3<\/span>\r\n}<\/pre>\n<p class=\"\" style=\"text-align: center;\"><span style=\"color: #000000;\">Configuring PA3 as UART2 RX<\/span><\/p>\n<ul class=\"\" style=\"border-width: 0px; font-size: 17px; line-height: 30px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\">\n<li><span style=\"font-weight: 400; color: #000000;\">The fourth step is <span style=\"color: #0000ff;\"><a style=\"color: #0000ff; text-decoration: underline;\" href=\"http:\/\/fastbitlab.com\/exercise-uart-parameter-inits\/\" target=\"_blank\" rel=\"noopener\">UART parameter initializations<\/a>.<\/span><\/span><\/li>\n<\/ul>\n<p class=\"\">&nbsp;<\/p>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp; UART pin configuration using STD. Peripheral Library APIs &nbsp; &nbsp; The second step is to configure the GPIO port A pin number 2 to behave as UART2 TX and GPIO port A pin number 3 to behave as UART2 RX. We call this step a pin alternate function configuration. For this, you have to [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":6205,"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-6203","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>STM32 UART Pin Configuration Using STD Peripheral Library APIs<\/title>\n<meta name=\"description\" content=\"Learn how to configure UART pins (PA2 and PA3) on STM32 microcontrollers using the STD Peripheral Library APIs. For a smooth UART setup\" \/>\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\/uart-pin-configuration-using-std-peripheral-library-apis\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"STM32 UART Pin Configuration Using STD Peripheral Library APIs\" \/>\n<meta property=\"og:description\" content=\"Learn how to configure UART pins (PA2 and PA3) on STM32 microcontrollers using the STD Peripheral Library APIs. For a smooth UART setup\" \/>\n<meta property=\"og:url\" content=\"https:\/\/fastbitlab.com\/blog\/uart-pin-configuration-using-std-peripheral-library-apis\/\" \/>\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-03T09:56:28+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-09-04T05:06:22+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-1-1.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1919\" \/>\n\t<meta property=\"og:image:height\" content=\"1021\" \/>\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=\"12 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/uart-pin-configuration-using-std-peripheral-library-apis\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/uart-pin-configuration-using-std-peripheral-library-apis\\\/\"},\"author\":{\"name\":\"FastBitLab\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/#\\\/schema\\\/person\\\/e32b38e733a0d76ffa7e6bc998652e5d\"},\"headline\":\"FreeRTOS Lecture 35 &#8211; UART pin configuration using STD. Peripheral Library APIs\",\"datePublished\":\"2021-06-03T09:56:28+00:00\",\"dateModified\":\"2023-09-04T05:06:22+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/uart-pin-configuration-using-std-peripheral-library-apis\\\/\"},\"wordCount\":1620,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/uart-pin-configuration-using-std-peripheral-library-apis\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/wp-content\\\/uploads\\\/2021\\\/06\\\/Figure-1-1.png\",\"keywords\":[\"FreeRTOS Lectures\"],\"articleSection\":[\"Blog\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/uart-pin-configuration-using-std-peripheral-library-apis\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/uart-pin-configuration-using-std-peripheral-library-apis\\\/\",\"url\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/uart-pin-configuration-using-std-peripheral-library-apis\\\/\",\"name\":\"STM32 UART Pin Configuration Using STD Peripheral Library APIs\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/uart-pin-configuration-using-std-peripheral-library-apis\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/uart-pin-configuration-using-std-peripheral-library-apis\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/wp-content\\\/uploads\\\/2021\\\/06\\\/Figure-1-1.png\",\"datePublished\":\"2021-06-03T09:56:28+00:00\",\"dateModified\":\"2023-09-04T05:06:22+00:00\",\"description\":\"Learn how to configure UART pins (PA2 and PA3) on STM32 microcontrollers using the STD Peripheral Library APIs. For a smooth UART setup\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/uart-pin-configuration-using-std-peripheral-library-apis\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/uart-pin-configuration-using-std-peripheral-library-apis\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/uart-pin-configuration-using-std-peripheral-library-apis\\\/#primaryimage\",\"url\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/wp-content\\\/uploads\\\/2021\\\/06\\\/Figure-1-1.png\",\"contentUrl\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/wp-content\\\/uploads\\\/2021\\\/06\\\/Figure-1-1.png\",\"width\":1919,\"height\":1021,\"caption\":\"Figure 1. stm32f4xx_gpio.c.\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/uart-pin-configuration-using-std-peripheral-library-apis\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"FreeRTOS Lecture 35 &#8211; UART pin configuration using STD. Peripheral Library APIs\"}]},{\"@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":"STM32 UART Pin Configuration Using STD Peripheral Library APIs","description":"Learn how to configure UART pins (PA2 and PA3) on STM32 microcontrollers using the STD Peripheral Library APIs. For a smooth UART setup","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\/uart-pin-configuration-using-std-peripheral-library-apis\/","og_locale":"en_US","og_type":"article","og_title":"STM32 UART Pin Configuration Using STD Peripheral Library APIs","og_description":"Learn how to configure UART pins (PA2 and PA3) on STM32 microcontrollers using the STD Peripheral Library APIs. For a smooth UART setup","og_url":"https:\/\/fastbitlab.com\/blog\/uart-pin-configuration-using-std-peripheral-library-apis\/","og_site_name":"FastBit EBA","article_publisher":"https:\/\/www.facebook.com\/fastbiteba\/","article_published_time":"2021-06-03T09:56:28+00:00","article_modified_time":"2023-09-04T05:06:22+00:00","og_image":[{"width":1919,"height":1021,"url":"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-1-1.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":"12 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/fastbitlab.com\/blog\/uart-pin-configuration-using-std-peripheral-library-apis\/#article","isPartOf":{"@id":"https:\/\/fastbitlab.com\/blog\/uart-pin-configuration-using-std-peripheral-library-apis\/"},"author":{"name":"FastBitLab","@id":"https:\/\/fastbitlab.com\/blog\/#\/schema\/person\/e32b38e733a0d76ffa7e6bc998652e5d"},"headline":"FreeRTOS Lecture 35 &#8211; UART pin configuration using STD. Peripheral Library APIs","datePublished":"2021-06-03T09:56:28+00:00","dateModified":"2023-09-04T05:06:22+00:00","mainEntityOfPage":{"@id":"https:\/\/fastbitlab.com\/blog\/uart-pin-configuration-using-std-peripheral-library-apis\/"},"wordCount":1620,"commentCount":0,"publisher":{"@id":"https:\/\/fastbitlab.com\/blog\/#organization"},"image":{"@id":"https:\/\/fastbitlab.com\/blog\/uart-pin-configuration-using-std-peripheral-library-apis\/#primaryimage"},"thumbnailUrl":"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-1-1.png","keywords":["FreeRTOS Lectures"],"articleSection":["Blog"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/fastbitlab.com\/blog\/uart-pin-configuration-using-std-peripheral-library-apis\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/fastbitlab.com\/blog\/uart-pin-configuration-using-std-peripheral-library-apis\/","url":"https:\/\/fastbitlab.com\/blog\/uart-pin-configuration-using-std-peripheral-library-apis\/","name":"STM32 UART Pin Configuration Using STD Peripheral Library APIs","isPartOf":{"@id":"https:\/\/fastbitlab.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/fastbitlab.com\/blog\/uart-pin-configuration-using-std-peripheral-library-apis\/#primaryimage"},"image":{"@id":"https:\/\/fastbitlab.com\/blog\/uart-pin-configuration-using-std-peripheral-library-apis\/#primaryimage"},"thumbnailUrl":"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-1-1.png","datePublished":"2021-06-03T09:56:28+00:00","dateModified":"2023-09-04T05:06:22+00:00","description":"Learn how to configure UART pins (PA2 and PA3) on STM32 microcontrollers using the STD Peripheral Library APIs. For a smooth UART setup","breadcrumb":{"@id":"https:\/\/fastbitlab.com\/blog\/uart-pin-configuration-using-std-peripheral-library-apis\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/fastbitlab.com\/blog\/uart-pin-configuration-using-std-peripheral-library-apis\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/fastbitlab.com\/blog\/uart-pin-configuration-using-std-peripheral-library-apis\/#primaryimage","url":"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-1-1.png","contentUrl":"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/06\/Figure-1-1.png","width":1919,"height":1021,"caption":"Figure 1. stm32f4xx_gpio.c."},{"@type":"BreadcrumbList","@id":"https:\/\/fastbitlab.com\/blog\/uart-pin-configuration-using-std-peripheral-library-apis\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/fastbitlab.com\/blog\/"},{"@type":"ListItem","position":2,"name":"FreeRTOS Lecture 35 &#8211; UART pin configuration using STD. Peripheral Library APIs"}]},{"@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\/6203","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=6203"}],"version-history":[{"count":5,"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/posts\/6203\/revisions"}],"predecessor-version":[{"id":15474,"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/posts\/6203\/revisions\/15474"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/media\/6205"}],"wp:attachment":[{"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/media?parent=6203"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/categories?post=6203"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/tags?post=6203"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}