{"id":291,"date":"2023-06-28T07:58:20","date_gmt":"2023-06-28T07:58:20","guid":{"rendered":"http:\/\/localhost\/embeddedwala\/?p=291"},"modified":"2023-07-27T04:13:57","modified_gmt":"2023-07-27T04:13:57","slug":"getting-started-with-uart-a-beginners-guide","status":"publish","type":"post","link":"https:\/\/embeddedwala.com\/beta\/blogs\/digital-communication\/getting-started-with-uart-a-beginners-guide\/","title":{"rendered":"Getting Started with UART: A Beginner&#8217;s Guide"},"content":{"rendered":"\t\t<div data-elementor-type=\"wp-post\" data-elementor-id=\"291\" class=\"elementor elementor-291\" data-elementor-post-type=\"post\">\n\t\t\t\t\t\t\t\t\t<section data-particle_enable=\"false\" data-particle-mobile-disabled=\"false\" class=\"elementor-section elementor-top-section elementor-element elementor-element-979f441 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"979f441\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-dc422f9\" data-id=\"dc422f9\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t\t\t<section data-particle_enable=\"false\" data-particle-mobile-disabled=\"false\" class=\"elementor-section elementor-inner-section elementor-element elementor-element-42bffc9 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"42bffc9\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-inner-column elementor-element elementor-element-2e9c585\" data-id=\"2e9c585\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t\t\t<div class=\"elementor-element elementor-element-0053ae9 elementor-widget elementor-widget-text-editor\" data-id=\"0053ae9\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<p><span data-contrast=\"auto\"><strong>UART (Universal Asynchronous Receiver\/Transmitter)<\/strong>\u00a0is a communication protocol commonly used in microcontrollers and other embedded systems. It allows for serial communication, enabling the transfer of data between two or more devices. T<\/span>wo main components in UART are:\u00a0<strong>a transmitter<\/strong>\u00a0and\u00a0<strong>a receiver<\/strong>. The transmitter converts parallel data from a microcontroller or computer into a serial stream of bits, while the receiver converts the serial stream of bits back into parallel data. The data is transmitted in the form of packets called frames, which consist of a start bit, data bits, optional parity bit, and stop bits.<\/p><p><strong>UART Hardware<\/strong><\/p><p>The\u00a0<strong>push-pull<\/strong>\u00a0configuration in UART hardware refers to the way in which the TX and RX lines are driven. In a push-pull configuration, each line is connected to a pair of transistors: one transistor is responsible for pulling the line low (logic 0), while the other transistor is responsible for pulling the line high (logic 1).<\/p><p>\u00a0<\/p><p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-282\" src=\"http:\/\/localhost\/embeddedwala\/wp-content\/uploads\/2023\/06\/Push-pull.png\" alt=\"\" width=\"1920\" height=\"1080\" \/><\/p><p>When data is\u00a0<strong>transmitted<\/strong>\u00a0from the TX line, the UART hardware first sends a start bit, which is a low-level signal. The push-pull configuration of the UART hardware then pulls the line low using one of the transistors. The data bits are then transmitted one at a time, with the push-pull configuration switching between pulling the line low and high to indicate a 0 or 1 bit, respectively. Finally, one or more stop bits are sent at the end of the frame.<\/p><p>On the\u00a0<strong>receiving<\/strong>\u00a0end, the push-pull configuration works in reverse. When the RX line receives a start bit, the UART hardware pulls the line low using one of the transistors. It then samples the incoming data bits at regular intervals to determine whether each bit is a 0 or 1. Once all the data bits have been received, the UART hardware raises the RX line high using the other transistor to signal the end of the frame.<\/p><p><strong>UART Packet Format<\/strong><\/p><p>As mentioned above, UART communication involves transmitting data in the form of\u00a0<strong>frames<\/strong>, with each frame consisting of a start bit, data bits, optional parity bit, and stop bit. Details of the frame is as below:\u00a0<\/p><ul><li><strong>The Start Bit<\/strong>: The start bit is a logic low (0) signal that indicates the beginning of the data frame. It is used to alert the receiver that data is about to be transmitted.\u00a0<\/li><li><strong>The Data Bits<\/strong>: The data bits contain the actual data being transmitted. The number of data bits in a frame can vary depending on the application, with 8 bits being the most common. The data bits are transmitted least significant bit first, and can represent any type of information, such as ASCII characters or binary values.<\/li><li><strong>The Parity Bit<\/strong>: The parity bit is an optional bit that is sometimes included in the data frame to detect errors during transmission. There are two types of parity:\u00a0<strong>even<\/strong>\u00a0and\u00a0<strong>odd<\/strong>. In even parity, the parity bit is set to ensure that the total number of 1s in the data bits (excluding the parity bit) is even. In odd parity, the parity bit is set to ensure that the total number of 1s in the data bits is odd. If a bit error occurs during transmission, the parity check will fail and the receiver will know that the data is corrupt.<\/li><li><strong>The Stop Bit<\/strong>: The stop bit is a logic high (1) signal that indicates the end of the data frame. It is used to signal the receiver that the data transmission is complete. The stop bit can be one or two bits long, depending on the UART configuration.<\/li><\/ul><p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-293\" src=\"http:\/\/localhost\/embeddedwala\/wp-content\/uploads\/2023\/06\/UART-complete-frame-blog.png\" alt=\"\" width=\"1897\" height=\"833\" \/><\/p><p><strong>UART Data Communication<\/strong><\/p><p>UART data communication can occur in two ways:\u00a0<strong>synchronous<\/strong>\u00a0and\u00a0<strong>asynchronous<\/strong>. In synchronous communication, both the transmitter and receiver use a common clock signal to synchronize data transmission. In asynchronous communication, however, there is no common clock signal, and the start and stop bits are used to synchronize data transmission.<\/p><p>Asynchronous communication is the most common method used in UART data communication, and is generally considered more flexible and reliable than synchronous communication. Asynchronous communication allows for variable length data frames and can be used with a wide range of data rates. As shown below, The start bit indicates the start of a new frame and is always a logic low (0) signal. The data bits are the actual data being transmitted, with each bit being sent one after the other. In the given scenario, there are 8 bits of data and 1 parity bit. The stop bit is the final bit in the frame and is always a logic high (1) signal. The stop bit indicates the end of the frame and allows the receiving device to detect when the frame has ended.<\/p><p>\u00a0<\/p><p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-294\" src=\"http:\/\/localhost\/embeddedwala\/wp-content\/uploads\/2023\/06\/UART-frame.png\" alt=\"\" width=\"1920\" height=\"1080\" \/><\/p><p><strong>UART Clock<\/strong><\/p><p>The<strong>\u00a0clock speed<\/strong>\u00a0of a UART is determined by the baud rate, which specifies the number of bits transmitted per second. For example, a baud rate of 9600 means that\u00a0<strong>9600<\/strong>\u00a0<strong>bits<\/strong>\u00a0are transmitted per second. The clock speed is calculated by dividing the system clock frequency by the baud rate.<\/p><p>Clock speed is important because it affects the reliability and accuracy of data transmission. If the clock speed is too low, the data may be transmitted too slowly, resulting in delays or even data loss. On the other hand, if the clock speed is too high, the data may be transmitted too quickly, leading to errors or data corruption.<\/p><p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-295 size-full\" src=\"http:\/\/localhost\/embeddedwala\/wp-content\/uploads\/2023\/06\/UART-protocal.png\" alt=\"\" width=\"1920\" height=\"1080\" \/><\/p><p>It&#8217;s important to note that the clock speed of the UART must be the same on both the transmitting and receiving devices in order for communication to be successful. This means that both devices must be set to the same baud rate.<\/p><p>In conclusion, UART communication is a widely used protocol in microcontrollers and other embedded systems due to its simplicity and reliability. It allows for serial communication between devices without the need for a clock signal, making it easier to implement in hardware. While USART offers additional features, UART remains a popular choice for many applications due to its simplicity and versatility. Understanding the basics of UART communication is essential for anyone working with microcontrollers and embedded systems.\u00a0<\/p>\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t\t\t\t<\/div>\n\t\t","protected":false},"excerpt":{"rendered":"<p>UART (Universal Asynchronous Receiver\/Transmitter)&nbsp;is a communication protocol commonly used in microcontrollers and other embedded systems&#8230;.<\/p>\n","protected":false},"author":1,"featured_media":299,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[34],"tags":[78,75,77,56],"class_list":["post-291","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-digital-communication","tag-aynchronous","tag-full-duplex","tag-serial-communications","tag-uart"],"acf":[],"views":408,"featured_image_urls":{"full":["https:\/\/embeddedwala.com\/beta\/wp-content\/uploads\/2023\/06\/UART-image.png",520,350,false],"thumbnail":["https:\/\/embeddedwala.com\/beta\/wp-content\/uploads\/2023\/06\/UART-image.png",150,101,false],"medium":["https:\/\/embeddedwala.com\/beta\/wp-content\/uploads\/2023\/06\/UART-image.png",300,202,false],"medium_large":["https:\/\/embeddedwala.com\/beta\/wp-content\/uploads\/2023\/06\/UART-image.png",520,350,false],"large":["https:\/\/embeddedwala.com\/beta\/wp-content\/uploads\/2023\/06\/UART-image.png",520,350,false],"1536x1536":["https:\/\/embeddedwala.com\/beta\/wp-content\/uploads\/2023\/06\/UART-image.png",520,350,false],"2048x2048":["https:\/\/embeddedwala.com\/beta\/wp-content\/uploads\/2023\/06\/UART-image.png",520,350,false],"tp-image-grid":["https:\/\/embeddedwala.com\/beta\/wp-content\/uploads\/2023\/06\/UART-image.png",520,350,false],"covernews-slider-full":["https:\/\/embeddedwala.com\/beta\/wp-content\/uploads\/2023\/06\/UART-image.png",520,350,false],"covernews-slider-center":["https:\/\/embeddedwala.com\/beta\/wp-content\/uploads\/2023\/06\/UART-image.png",520,350,false],"covernews-featured":["https:\/\/embeddedwala.com\/beta\/wp-content\/uploads\/2023\/06\/UART-image.png",520,350,false],"covernews-medium":["https:\/\/embeddedwala.com\/beta\/wp-content\/uploads\/2023\/06\/UART-image.png",505,340,false],"covernews-medium-square":["https:\/\/embeddedwala.com\/beta\/wp-content\/uploads\/2023\/06\/UART-image.png",371,250,false],"_nx_notification_thumb":["https:\/\/embeddedwala.com\/beta\/wp-content\/uploads\/2023\/06\/UART-image.png",100,67,false]},"author_info":{"display_name":"embeddedwala","author_link":"https:\/\/embeddedwala.com\/beta\/author\/embeddedwala\/"},"category_info":"<a href=\"https:\/\/embeddedwala.com\/beta\/category\/blogs\/digital-communication\/\" rel=\"category tag\">Digital Communication<\/a>","tag_info":"Digital Communication","comment_count":"0","_links":{"self":[{"href":"https:\/\/embeddedwala.com\/beta\/wp-json\/wp\/v2\/posts\/291","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/embeddedwala.com\/beta\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/embeddedwala.com\/beta\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/embeddedwala.com\/beta\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/embeddedwala.com\/beta\/wp-json\/wp\/v2\/comments?post=291"}],"version-history":[{"count":5,"href":"https:\/\/embeddedwala.com\/beta\/wp-json\/wp\/v2\/posts\/291\/revisions"}],"predecessor-version":[{"id":300,"href":"https:\/\/embeddedwala.com\/beta\/wp-json\/wp\/v2\/posts\/291\/revisions\/300"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/embeddedwala.com\/beta\/wp-json\/wp\/v2\/media\/299"}],"wp:attachment":[{"href":"https:\/\/embeddedwala.com\/beta\/wp-json\/wp\/v2\/media?parent=291"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/embeddedwala.com\/beta\/wp-json\/wp\/v2\/categories?post=291"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/embeddedwala.com\/beta\/wp-json\/wp\/v2\/tags?post=291"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}