{"id":5280,"date":"2021-03-03T09:12:20","date_gmt":"2021-03-03T09:12:20","guid":{"rendered":"http:\/\/fastbitlab.com\/?p=5280"},"modified":"2023-09-04T15:24:04","modified_gmt":"2023-09-04T09:54:04","slug":"stm32-usart-lecture-3-configuration-options-and-usart-registers","status":"publish","type":"post","link":"https:\/\/fastbitlab.com\/blog\/stm32-usart-lecture-3-configuration-options-and-usart-registers\/","title":{"rendered":"STM32 USART Lecture 3 &#8211; Configuration options and USART registers"},"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: 25px; 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: 30px; border-width: 0px; line-height: 50px;\"><span style=\"color: #000080;\">Configuration options and USART registers<\/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;\">In the usart_driver.h file, in the beginning, mention the device specific header file (Figure 1).<\/span><\/p>\n<figure id=\"attachment_5283\" aria-describedby=\"caption-attachment-5283\" style=\"width: 744px\" class=\"wp-caption aligncenter\"><img fetchpriority=\"high\" decoding=\"async\" class=\"wp-image-5283\" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2021\/03\/Figure-1.png\" alt=\"Device specific header in driver.h file\" width=\"744\" height=\"397\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-1.png 1919w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-1-300x160.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-1-768x409.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-1-1024x546.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-1-600x320.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-1-120x64.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-1-500x267.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-1-200x107.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-1-400x213.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-1-800x426.png 800w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-1-1200x640.png 1200w\" sizes=\"(max-width: 744px) 100vw, 744px\" \/><figcaption id=\"caption-attachment-5283\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 1. Device specific header in driver.h file.<\/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;\">Figure 2 shows the configuration and handle structure for the USART peripheral.<\/span><\/p>\n<figure id=\"attachment_5284\" aria-describedby=\"caption-attachment-5284\" style=\"width: 744px\" class=\"wp-caption aligncenter\"><img decoding=\"async\" class=\"wp-image-5284\" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2021\/03\/Figure-2.png\" alt=\"Configuration and handle structure\" width=\"744\" height=\"399\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-2.png 1917w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-2-300x161.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-2-768x411.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-2-1024x549.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-2-600x321.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-2-120x64.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-2-500x268.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-2-200x107.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-2-400x214.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-2-800x429.png 800w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-2-1200x643.png 1200w\" sizes=\"(max-width: 744px) 100vw, 744px\" \/><figcaption id=\"caption-attachment-5284\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 2. Configuration and handle structure.<\/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;\">All the prototypes are copied into the driver.h file, as shown in Figure 3.<\/span><\/p>\n<figure id=\"attachment_5285\" aria-describedby=\"caption-attachment-5285\" style=\"width: 744px\" class=\"wp-caption aligncenter\"><img decoding=\"async\" class=\"wp-image-5285\" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2021\/03\/Figure-3.png\" alt=\"Prototypes of all the APIs supported by this driver\" width=\"744\" height=\"397\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-3.png 1919w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-3-300x160.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-3-768x409.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-3-1024x546.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-3-600x320.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-3-120x64.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-3-500x267.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-3-200x107.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-3-400x213.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-3-800x426.png 800w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-3-1200x640.png 1200w\" sizes=\"(max-width: 744px) 100vw, 744px\" \/><figcaption id=\"caption-attachment-5285\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 3. Prototypes of all the APIs supported by this driver.<\/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;\">Mention the usart_driver.h header file in the usart_driver.c (Figure 4).<\/span><\/p>\n<figure id=\"attachment_5286\" aria-describedby=\"caption-attachment-5286\" style=\"width: 744px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-5286\" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2021\/03\/Figure-4.png\" alt=\"Adding usart_driver.h header file in the usart_driver.c\" width=\"744\" height=\"396\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-4.png 1919w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-4-300x160.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-4-768x409.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-4-1024x545.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-4-600x319.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-4-120x64.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-4-500x266.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-4-200x106.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-4-400x213.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-4-800x426.png 800w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-4-1200x638.png 1200w\" sizes=\"(max-width: 744px) 100vw, 744px\" \/><figcaption id=\"caption-attachment-5286\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 4. Adding usart_driver.h header file in the usart_driver.c.<\/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;\">Include the usart_driver.h at the end of the MCU specific header file (Figure 5).<\/span><\/p>\n<figure id=\"attachment_5287\" aria-describedby=\"caption-attachment-5287\" style=\"width: 744px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-5287\" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2021\/03\/Figure-5.png\" alt=\"Adding usart_driver.h in MCU specific header file\" width=\"744\" height=\"398\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-5.png 1915w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-5-300x160.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-5-768x410.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-5-1024x547.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-5-600x321.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-5-120x64.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-5-500x267.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-5-200x107.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-5-400x214.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-5-800x427.png 800w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-5-1200x641.png 1200w\" sizes=\"(max-width: 744px) 100vw, 744px\" \/><figcaption id=\"caption-attachment-5287\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 5. Adding usart_driver.h in MCU specific header file.<\/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;\">In the driver.c file, you must implement peripheral control, peripheral clock control, and other APIs, as shown in Figure 6 and Figure 7, respectively.<\/span><\/p>\n<figure id=\"attachment_5289\" aria-describedby=\"caption-attachment-5289\" style=\"width: 744px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-5289\" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2021\/03\/Figure-6.png\" alt=\"Configuration options and USART registers\" width=\"744\" height=\"397\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-6.png 1919w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-6-300x160.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-6-768x409.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-6-1024x546.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-6-600x320.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-6-120x64.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-6-500x267.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-6-200x107.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-6-400x213.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-6-800x426.png 800w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-6-1200x640.png 1200w\" sizes=\"(max-width: 744px) 100vw, 744px\" \/><figcaption id=\"caption-attachment-5289\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 6. Peripheral control API.<\/span><\/figcaption><\/figure>\n<p class=\"\">&nbsp;<\/p>\n<figure id=\"attachment_5290\" aria-describedby=\"caption-attachment-5290\" style=\"width: 744px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-5290\" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2021\/03\/Figure-7.png\" alt=\"Configuration options and USART registers\" width=\"744\" height=\"398\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-7.png 1917w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-7-300x160.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-7-768x411.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-7-1024x548.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-7-600x321.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-7-120x64.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-7-500x267.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-7-200x107.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-7-400x214.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-7-800x428.png 800w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-7-1200x642.png 1200w\" sizes=\"(max-width: 744px) 100vw, 744px\" \/><figcaption id=\"caption-attachment-5290\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 7. Peripheral clock control API.<\/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 go to the usart_driver.h file to discuss the options to configure the configuration structure.<\/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;\"><span style=\"color: #000080;\"><strong>USART_Mode:<\/strong><\/span> In order to configure the USART mode, the user application can use the macros shown in Figure 8, which you can get from the file USART_API_prototype.h attached in the resource section. 0, 1 and 2 are the codes for USART_MODE_ONLY_TX, USART_MODE_ONLY_RX and USART_MODE_TXRX macros.<\/span><\/p>\n<figure id=\"attachment_5291\" aria-describedby=\"caption-attachment-5291\" style=\"width: 744px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-5291\" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2021\/03\/Figure-8.png\" alt=\"Configuration options and USART registers\" width=\"744\" height=\"397\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-8.png 1917w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-8-300x160.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-8-768x410.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-8-1024x546.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-8-600x320.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-8-120x64.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-8-500x267.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-8-200x107.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-8-400x213.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-8-800x427.png 800w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-8-1200x640.png 1200w\" sizes=\"(max-width: 744px) 100vw, 744px\" \/><figcaption id=\"caption-attachment-5291\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 8. Macros used to configure the USART_Mode.<\/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;\"><strong><span style=\"color: #000080;\">USART_Baud:<\/span> <\/strong>The standard baud rate values from 1200bps to 3Mbps (Figure 9) can be used to decide the baud rate value. The USART baud macros can be selected by going through the baud rate generation table of the USART peripheral mentioned in the reference manual.<\/span><\/p>\n<figure id=\"attachment_5292\" aria-describedby=\"caption-attachment-5292\" style=\"width: 744px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-5292\" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2021\/03\/Figure-9.png\" alt=\"Configuration options and USART registers\" width=\"744\" height=\"398\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-9.png 1917w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-9-300x160.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-9-768x411.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-9-1024x548.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-9-600x321.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-9-120x64.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-9-500x267.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-9-200x107.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-9-400x214.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-9-800x428.png 800w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-9-1200x642.png 1200w\" sizes=\"(max-width: 744px) 100vw, 744px\" \/><figcaption id=\"caption-attachment-5292\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 9. Macros used to configure the USART_Baud.<\/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;\">In the reference manual, go to the functional description section of the USART peripheral, there you will get a fractional baud rate generation section (Figure 10).<\/span><\/p>\n<figure id=\"attachment_5294\" aria-describedby=\"caption-attachment-5294\" style=\"width: 744px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-5294\" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2021\/03\/Figure-10.png\" alt=\"Configuration options and USART registers\" width=\"744\" height=\"424\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-10.png 1423w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-10-300x171.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-10-768x438.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-10-1024x584.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-10-600x342.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-10-120x68.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-10-500x285.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-10-200x114.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-10-400x228.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-10-800x456.png 800w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-10-1200x684.png 1200w\" sizes=\"(max-width: 744px) 100vw, 744px\" \/><figcaption id=\"caption-attachment-5294\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 10. Fractional baud rate generation Section.<\/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;\">As you browse through this document, you will get a table shown in Figure 11. Since our peripheral clock is 16MHz, we have to use this table for <span style=\"text-decoration: underline; color: #ff6600;\"><a style=\"color: #ff6600; text-decoration: underline;\" href=\"http:\/\/fastbitlab.com\/stm32-usart-lecture-8-usart-baud-rate-calculation-part-2\/\" target=\"_blank\" rel=\"noopener\">baud rate calculation<\/a><\/span>. <\/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 Figure 11, you can see that if the peripheral clock is 16MHz, then it is possible to reach up to 3Mbps. Since the baud rates in Figure 11 are standard baud rates, they are coded as C macros.<\/span><\/p>\n<figure id=\"attachment_5295\" aria-describedby=\"caption-attachment-5295\" style=\"width: 744px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-5295\" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2021\/03\/Figure-11.png\" alt=\"Configuration options and USART registers\" width=\"744\" height=\"535\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-11.png 981w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-11-300x216.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-11-768x552.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-11-600x431.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-11-120x86.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-11-500x359.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-11-200x144.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-11-400x287.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-11-800x575.png 800w\" sizes=\"(max-width: 744px) 100vw, 744px\" \/><figcaption id=\"caption-attachment-5295\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 11. Error calculation for programmed baud rates at fPCLK = 16MHz or fPCLK = 24MHz, oversampling by 16(1).<\/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;\"><span style=\"color: #000080;\"><strong>USART_ParityControl:<\/strong> <\/span>There are three options (Figure 12) for parity control. One is USART_PARITY_DISABLE, then USART_PARITY_EN_EVEN, and another is USART_PARITY_EN_ODD.<\/span><\/p>\n<figure id=\"attachment_5296\" aria-describedby=\"caption-attachment-5296\" style=\"width: 744px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-5296\" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2021\/03\/Figure-12.png\" alt=\"Configuration options and USART registers\" width=\"744\" height=\"398\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-12.png 1919w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-12-300x160.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-12-768x410.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-12-1024x547.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-12-600x320.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-12-120x64.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-12-500x267.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-12-200x107.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-12-400x214.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-12-800x427.png 800w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-12-1200x641.png 1200w\" sizes=\"(max-width: 744px) 100vw, 744px\" \/><figcaption id=\"caption-attachment-5296\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 12. Macros to configure USART parity control.<\/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;\"><strong><span style=\"color: #000080;\">USART_WordLength:<\/span><\/strong> There are two choices for word length, either 8 bits or 9 bits. Therefore, you can use two macros, as shown in Figure 13, to configure the word length.<\/span><\/p>\n<figure id=\"attachment_5297\" aria-describedby=\"caption-attachment-5297\" style=\"width: 744px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-5297\" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2021\/03\/Figure-13.png\" alt=\"Configuration options and USART registers\" width=\"744\" height=\"398\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-13.png 1919w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-13-300x160.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-13-768x410.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-13-1024x547.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-13-600x320.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-13-120x64.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-13-500x267.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-13-200x107.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-13-400x214.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-13-800x427.png 800w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-13-1200x641.png 1200w\" sizes=\"(max-width: 744px) 100vw, 744px\" \/><figcaption id=\"caption-attachment-5297\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 13. Macros to configure the USART word length.<\/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;\"><strong><span style=\"color: #000080;\">USART_NoOfStopBits:<\/span><\/strong> There are four options for the number of stop bits, as shown in Figure 14. They are only one stop bit, 0.5 stop bit, 2 stop bits, or 1.5 stop bits.<\/span><\/p>\n<figure id=\"attachment_5298\" aria-describedby=\"caption-attachment-5298\" style=\"width: 744px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-5298\" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2021\/03\/Figure-14.png\" alt=\"Macros to configure the number of stop bits\" width=\"744\" height=\"419\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-14.png 1920w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-14-300x169.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-14-768x432.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-14-1024x576.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-14-600x338.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-14-120x68.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-14-500x281.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-14-200x113.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-14-400x225.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-14-800x450.png 800w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-14-1200x675.png 1200w\" sizes=\"(max-width: 744px) 100vw, 744px\" \/><figcaption id=\"caption-attachment-5298\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 14. Macros to configure the number of stop bits.<\/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;\"><strong><span style=\"color: #000080;\">USART_HWFlowControl:<\/span><\/strong> Hardware flow control none, hardware flow control CTS, hardware flow control RTS and hardware flow control both CTS and RTS are the macros used to configure the hardware flow control (Figure 15).<\/span><\/p>\n<figure id=\"attachment_5299\" aria-describedby=\"caption-attachment-5299\" style=\"width: 744px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-5299\" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2021\/03\/Figure-15.png\" alt=\"Macros to configure hardware flow control\" width=\"744\" height=\"396\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-15.png 1919w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-15-300x160.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-15-768x409.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-15-1024x545.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-15-600x319.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-15-120x64.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-15-500x266.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-15-200x106.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-15-400x213.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-15-800x426.png 800w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-15-1200x638.png 1200w\" sizes=\"(max-width: 744px) 100vw, 744px\" \/><figcaption id=\"caption-attachment-5299\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 15. Macros to configure hardware flow control.<\/span><\/figcaption><\/figure>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"font-size: 22px; border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; line-height: 33px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><strong><span style=\"color: #000080;\">Where to configure the USART_Mode?<\/span><\/strong><\/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;\">The USART_Mode can be configured by enabling or disabling bits 2 and 3 of the CR1 register (Figure 16). Bit 2 is receiver enable, and bit 3 is transmitter enable. <\/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;\">If you want to configure the microcontroller only to transmit the data over the USART peripheral, then you need to enable the transmitter, not a receiver, thereby saving some power. <\/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;\">If you only want receive data, then you can use the receiver enable bit by turning off the transmitter. If you want it to be involved in both transmission and reception, then you can turn on both bits 2 and 3.<\/span><\/p>\n<figure id=\"attachment_5300\" aria-describedby=\"caption-attachment-5300\" style=\"width: 744px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-5300\" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2021\/03\/Figure-16.png\" alt=\"USART control register 1 (USART_CR1)\" width=\"744\" height=\"439\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-16.png 1345w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-16-300x177.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-16-768x453.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-16-1024x605.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-16-600x354.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-16-120x71.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-16-500x295.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-16-200x118.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-16-400x236.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-16-800x472.png 800w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-16-1200x708.png 1200w\" sizes=\"(max-width: 744px) 100vw, 744px\" \/><figcaption id=\"caption-attachment-5300\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 16. USART control register 1 (USART_CR1).<\/span><\/figcaption><\/figure>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"font-size: 20px; border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; line-height: 32px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><strong><span style=\"color: #000080;\">Where to configure the USART_Baud?<\/span><\/strong><\/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;\">Remember that, to configure the baud rate, you have to properly configure the mantissa and fraction part of the USART_BRR register shown in Figure 17 according to the baud rate you want to use.<\/span><\/p>\n<figure id=\"attachment_5301\" aria-describedby=\"caption-attachment-5301\" style=\"width: 744px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-5301\" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2021\/03\/Figure-17.png\" alt=\"Configuration options and USART registers\" width=\"744\" height=\"355\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-17.png 1379w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-17-300x143.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-17-768x366.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-17-1024x488.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-17-600x286.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-17-120x57.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-17-500x238.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-17-200x95.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-17-400x191.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-17-800x381.png 800w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-17-1200x572.png 1200w\" sizes=\"(max-width: 744px) 100vw, 744px\" \/><figcaption id=\"caption-attachment-5301\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 17. USART baud rate register (USART_BRR).<\/span><\/figcaption><\/figure>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"font-size: 20px; border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; line-height: 32px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><strong><span style=\"color: #000080;\">Where to configure the USART parity control?<\/span><\/strong><\/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;\">You have to configure bits 9 and 10 of the CR1 register (Figure 18) in order to control the parity. The bit number 10 is disabled by default. Once you enable the bit number 10, the parity control will be enabled. Bit 9 can make sense only when the parity control is enabled. By using bit 9, you can configure either even parity or odd parity. By default, it will be even parity.<\/span><\/p>\n<figure id=\"attachment_5302\" aria-describedby=\"caption-attachment-5302\" style=\"width: 744px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-5302\" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2021\/03\/Figure-18.png\" alt=\"Configuration options and USART registers\" width=\"744\" height=\"447\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-18.png 1309w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-18-300x180.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-18-768x462.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-18-1024x616.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-18-600x361.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-18-120x72.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-18-500x301.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-18-200x120.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-18-400x240.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-18-800x481.png 800w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-18-1200x721.png 1200w\" sizes=\"(max-width: 744px) 100vw, 744px\" \/><figcaption id=\"caption-attachment-5302\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 18. USART control register 1 (USART_CR1).<\/span><\/figcaption><\/figure>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"font-size: 20px; border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; line-height: 33px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><strong><span style=\"color: #000080;\">Where to configure the USART word length?<\/span><\/strong><\/p>\n<p class=\"\" style=\"border-width: 0px; font-size: 17px; font-family: 'Roboto Slab'; font-weight: 400; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">The word length can be configured in the bit number 12 of the CR1 register (Figure 19). The 12th bit of the CR1 register determines the word length, and it is set and cleared by the software. If this bit is zero means one start bit, 8 data bits, and n stop bits. Here the n will be decided later by using another control bit. If it is 1, then it means 1 start bit, 9 data bits, and n stop bits.<\/span><\/p>\n<figure id=\"attachment_5303\" aria-describedby=\"caption-attachment-5303\" style=\"width: 745px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-5303\" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2021\/03\/Figure-19.png\" alt=\"USART control register 1 (USART_CR1)\" width=\"745\" height=\"318\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-19.png 1329w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-19-300x128.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-19-768x328.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-19-1024x437.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-19-600x256.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-19-120x51.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-19-500x213.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-19-940x400.png 940w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-19-200x85.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-19-400x171.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-19-800x341.png 800w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-19-1200x512.png 1200w\" sizes=\"(max-width: 745px) 100vw, 745px\" \/><figcaption id=\"caption-attachment-5303\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 19. USART control register 1 (USART_CR1).<\/span><\/figcaption><\/figure>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"font-size: 20px; border-width: 0px; line-height: 30px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><strong><span style=\"color: #000080;\">Where to configure the number of stop bits?<\/span><\/strong><\/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;\">The number of stop bits can be configured in the CR2 register (Figure 20). There are 4 options for configuring stop bits. They are:<\/span><\/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 style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400; color: #000000;\">1 stop bit.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400; color: #000000;\">0.5 stop bit.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400; color: #000000;\">2 stop bit.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400; color: #000000;\">1.5 stop bit.<\/span><\/li>\n<\/ul>\n<p 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=\"\"><span style=\"font-weight: 400; color: #000000;\">You can use any of these four options. <\/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;\">If you use a higher baud rate (3Mbps or 4Mbps), then it\u2019s better to use more stop bits to give some time for the receiver to interpret the data properly. Usually, we use 2 stop bits in a higher baud rate situation. If the baud rate is lesser, like less than 1Mbps, then you can use 1 stop bit. When the baud rate is lesser than or equal to 9600bps, you can use 0.5 stop bit.<\/span><\/p>\n<figure id=\"attachment_5304\" aria-describedby=\"caption-attachment-5304\" style=\"width: 744px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-5304\" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2021\/03\/Figure-20.png\" alt=\"USART control register 2 (USART_CR2)\" width=\"744\" height=\"479\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-20.png 1313w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-20-300x193.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-20-768x494.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-20-1024x659.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-20-600x386.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-20-120x77.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-20-500x322.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-20-460x295.png 460w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-20-200x129.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-20-400x257.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-20-800x515.png 800w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-20-1200x772.png 1200w\" sizes=\"(max-width: 744px) 100vw, 744px\" \/><figcaption id=\"caption-attachment-5304\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 20. USART control register 2 (USART_CR2).<\/span><\/figcaption><\/figure>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"font-size: 22px; border-width: 0px; line-height: 30px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><strong><span style=\"color: #000080;\">Where to configure the hardware flow control?<\/span><\/strong><\/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;\">The hardware flow control can be configured in a CR3 register by going through bit 8 and bit 9 (Figure 21). If you enable bit 9, then the CTS will be enabled. If you enable bit 8, the RTS line will be enabled, and if you enable both the bits 8 and 9, then both CTS and RTS lines will be enabled.<\/span><\/p>\n<figure id=\"attachment_5305\" aria-describedby=\"caption-attachment-5305\" style=\"width: 744px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-5305\" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2021\/03\/Figure-21.png\" alt=\"USART control register 3 (USART_CR3)\" width=\"744\" height=\"463\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-21.png 1353w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-21-300x186.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-21-768x477.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-21-1024x636.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-21-600x373.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-21-320x200.png 320w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-21-120x75.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-21-500x311.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-21-200x124.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-21-400x249.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-21-800x497.png 800w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-21-1200x746.png 1200w\" sizes=\"(max-width: 744px) 100vw, 744px\" \/><figcaption id=\"caption-attachment-5305\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 21. USART control register 3 (USART_CR3).<\/span><\/figcaption><\/figure>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"font-size: 21px; border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; line-height: 36px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"text-decoration: underline; color: #000080;\"><b>Exercise:<\/b><\/span><\/p>\n<p 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=\"\"><span style=\"font-weight: 400; color: #000000;\">Write the macro definition for all the macros shown in Figure 22 in order to initialize the configuration structure.<\/span><\/p>\n<figure id=\"attachment_5306\" aria-describedby=\"caption-attachment-5306\" style=\"width: 744px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-5306\" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2021\/03\/Figure-22.png\" alt=\"Exercise\" width=\"744\" height=\"399\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-22.png 1915w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-22-300x161.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-22-768x412.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-22-1024x549.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-22-600x322.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-22-120x64.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-22-500x268.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-22-200x107.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-22-400x215.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-22-800x429.png 800w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-22-1200x644.png 1200w\" sizes=\"(max-width: 744px) 100vw, 744px\" \/><figcaption id=\"caption-attachment-5306\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 22. Exercise.<\/span><\/figcaption><\/figure>\n<p>&nbsp;<\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 31px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"color: #000000;\">In the following article, let&#8217;s see<\/span> <span style=\"color: #ff6600;\"><a style=\"color: #ff6600; text-decoration: underline;\" href=\"http:\/\/fastbitlab.com\/usart-driver-api-usart-init\/\" target=\"_blank\" rel=\"noopener\">USART Driver API: USART Init<\/a><\/span>.&nbsp;<\/p>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 20px; line-height: 25px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"color: #000080;\"><b>FastBit Embedded Brain Academy Courses<\/b><\/span><\/p>\n<p class=\"\" style=\"border-width: 0px;\"><span style=\"color: #000000;\">Click here:<\/span>&nbsp;<span style=\"color: #0000ff;\"><a style=\"color: #0000ff; text-decoration: underline;\" href=\"http:\/\/fastbitlab.com\/course1\" target=\"_blank\" rel=\"noopener\">https:\/\/fastbitlab.com\/course1<\/a><\/span><\/p>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp; Configuration options and USART registers &nbsp; &nbsp; In the usart_driver.h file, in the beginning, mention the device specific header file (Figure 1). &nbsp; Figure 2 shows the configuration and handle structure for the USART peripheral. &nbsp; All the prototypes are copied into the driver.h file, as shown in Figure 3. &nbsp; Mention the usart_driver.h [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":5283,"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":[24],"class_list":["post-5280","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-blog","tag-stm32-usart-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 USART Lecture 3 - Configuration options and USART registers<\/title>\n<meta name=\"description\" content=\"Configuration options and USART registers. In the usart_driver.h file, in the beginning, mention the device specific header file (Figure 1).\" \/>\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\/stm32-usart-lecture-3-configuration-options-and-usart-registers\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"STM32 USART Lecture 3 - Configuration options and USART registers\" \/>\n<meta property=\"og:description\" content=\"Configuration options and USART registers. In the usart_driver.h file, in the beginning, mention the device specific header file (Figure 1).\" \/>\n<meta property=\"og:url\" content=\"https:\/\/fastbitlab.com\/blog\/stm32-usart-lecture-3-configuration-options-and-usart-registers\/\" \/>\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-03-03T09:12:20+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-09-04T09:54:04+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-1.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1919\" \/>\n\t<meta property=\"og:image:height\" content=\"1023\" \/>\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=\"10 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/stm32-usart-lecture-3-configuration-options-and-usart-registers\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/stm32-usart-lecture-3-configuration-options-and-usart-registers\\\/\"},\"author\":{\"name\":\"FastBitLab\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/#\\\/schema\\\/person\\\/e32b38e733a0d76ffa7e6bc998652e5d\"},\"headline\":\"STM32 USART Lecture 3 &#8211; Configuration options and USART registers\",\"datePublished\":\"2021-03-03T09:12:20+00:00\",\"dateModified\":\"2023-09-04T09:54:04+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/stm32-usart-lecture-3-configuration-options-and-usart-registers\\\/\"},\"wordCount\":1296,\"commentCount\":2,\"publisher\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/stm32-usart-lecture-3-configuration-options-and-usart-registers\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/wp-content\\\/uploads\\\/2021\\\/03\\\/Figure-1.png\",\"keywords\":[\"STM32 USART Lectures\"],\"articleSection\":[\"Blog\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/stm32-usart-lecture-3-configuration-options-and-usart-registers\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/stm32-usart-lecture-3-configuration-options-and-usart-registers\\\/\",\"url\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/stm32-usart-lecture-3-configuration-options-and-usart-registers\\\/\",\"name\":\"STM32 USART Lecture 3 - Configuration options and USART registers\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/stm32-usart-lecture-3-configuration-options-and-usart-registers\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/stm32-usart-lecture-3-configuration-options-and-usart-registers\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/wp-content\\\/uploads\\\/2021\\\/03\\\/Figure-1.png\",\"datePublished\":\"2021-03-03T09:12:20+00:00\",\"dateModified\":\"2023-09-04T09:54:04+00:00\",\"description\":\"Configuration options and USART registers. In the usart_driver.h file, in the beginning, mention the device specific header file (Figure 1).\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/stm32-usart-lecture-3-configuration-options-and-usart-registers\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/stm32-usart-lecture-3-configuration-options-and-usart-registers\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/stm32-usart-lecture-3-configuration-options-and-usart-registers\\\/#primaryimage\",\"url\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/wp-content\\\/uploads\\\/2021\\\/03\\\/Figure-1.png\",\"contentUrl\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/wp-content\\\/uploads\\\/2021\\\/03\\\/Figure-1.png\",\"width\":1919,\"height\":1023,\"caption\":\"Figure 1. Device specific header in driver.h file.\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/stm32-usart-lecture-3-configuration-options-and-usart-registers\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"STM32 USART Lecture 3 &#8211; Configuration options and USART registers\"}]},{\"@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 USART Lecture 3 - Configuration options and USART registers","description":"Configuration options and USART registers. In the usart_driver.h file, in the beginning, mention the device specific header file (Figure 1).","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\/stm32-usart-lecture-3-configuration-options-and-usart-registers\/","og_locale":"en_US","og_type":"article","og_title":"STM32 USART Lecture 3 - Configuration options and USART registers","og_description":"Configuration options and USART registers. In the usart_driver.h file, in the beginning, mention the device specific header file (Figure 1).","og_url":"https:\/\/fastbitlab.com\/blog\/stm32-usart-lecture-3-configuration-options-and-usart-registers\/","og_site_name":"FastBit EBA","article_publisher":"https:\/\/www.facebook.com\/fastbiteba\/","article_published_time":"2021-03-03T09:12:20+00:00","article_modified_time":"2023-09-04T09:54:04+00:00","og_image":[{"width":1919,"height":1023,"url":"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-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":"10 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/fastbitlab.com\/blog\/stm32-usart-lecture-3-configuration-options-and-usart-registers\/#article","isPartOf":{"@id":"https:\/\/fastbitlab.com\/blog\/stm32-usart-lecture-3-configuration-options-and-usart-registers\/"},"author":{"name":"FastBitLab","@id":"https:\/\/fastbitlab.com\/blog\/#\/schema\/person\/e32b38e733a0d76ffa7e6bc998652e5d"},"headline":"STM32 USART Lecture 3 &#8211; Configuration options and USART registers","datePublished":"2021-03-03T09:12:20+00:00","dateModified":"2023-09-04T09:54:04+00:00","mainEntityOfPage":{"@id":"https:\/\/fastbitlab.com\/blog\/stm32-usart-lecture-3-configuration-options-and-usart-registers\/"},"wordCount":1296,"commentCount":2,"publisher":{"@id":"https:\/\/fastbitlab.com\/blog\/#organization"},"image":{"@id":"https:\/\/fastbitlab.com\/blog\/stm32-usart-lecture-3-configuration-options-and-usart-registers\/#primaryimage"},"thumbnailUrl":"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-1.png","keywords":["STM32 USART Lectures"],"articleSection":["Blog"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/fastbitlab.com\/blog\/stm32-usart-lecture-3-configuration-options-and-usart-registers\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/fastbitlab.com\/blog\/stm32-usart-lecture-3-configuration-options-and-usart-registers\/","url":"https:\/\/fastbitlab.com\/blog\/stm32-usart-lecture-3-configuration-options-and-usart-registers\/","name":"STM32 USART Lecture 3 - Configuration options and USART registers","isPartOf":{"@id":"https:\/\/fastbitlab.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/fastbitlab.com\/blog\/stm32-usart-lecture-3-configuration-options-and-usart-registers\/#primaryimage"},"image":{"@id":"https:\/\/fastbitlab.com\/blog\/stm32-usart-lecture-3-configuration-options-and-usart-registers\/#primaryimage"},"thumbnailUrl":"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-1.png","datePublished":"2021-03-03T09:12:20+00:00","dateModified":"2023-09-04T09:54:04+00:00","description":"Configuration options and USART registers. In the usart_driver.h file, in the beginning, mention the device specific header file (Figure 1).","breadcrumb":{"@id":"https:\/\/fastbitlab.com\/blog\/stm32-usart-lecture-3-configuration-options-and-usart-registers\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/fastbitlab.com\/blog\/stm32-usart-lecture-3-configuration-options-and-usart-registers\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/fastbitlab.com\/blog\/stm32-usart-lecture-3-configuration-options-and-usart-registers\/#primaryimage","url":"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-1.png","contentUrl":"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2021\/03\/Figure-1.png","width":1919,"height":1023,"caption":"Figure 1. Device specific header in driver.h file."},{"@type":"BreadcrumbList","@id":"https:\/\/fastbitlab.com\/blog\/stm32-usart-lecture-3-configuration-options-and-usart-registers\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/fastbitlab.com\/blog\/"},{"@type":"ListItem","position":2,"name":"STM32 USART Lecture 3 &#8211; Configuration options and USART registers"}]},{"@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\/5280","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=5280"}],"version-history":[{"count":5,"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/posts\/5280\/revisions"}],"predecessor-version":[{"id":12655,"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/posts\/5280\/revisions\/12655"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/media\/5283"}],"wp:attachment":[{"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/media?parent=5280"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/categories?post=5280"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/tags?post=5280"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}