{"id":326,"date":"2023-06-28T09:45:32","date_gmt":"2023-06-28T09:45:32","guid":{"rendered":"http:\/\/localhost\/embeddedwala\/?p=326"},"modified":"2023-07-27T04:13:34","modified_gmt":"2023-07-27T04:13:34","slug":"getting-started-with-i2c-what-is-clock-stretching","status":"publish","type":"post","link":"https:\/\/embeddedwala.com\/beta\/blogs\/digital-communication\/getting-started-with-i2c-what-is-clock-stretching\/","title":{"rendered":"Getting Started with I2C:What is Clock Stretching"},"content":{"rendered":"\t\t<div data-elementor-type=\"wp-post\" data-elementor-id=\"326\" class=\"elementor elementor-326\" 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-3eeb114 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"3eeb114\" 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-50b82ee\" data-id=\"50b82ee\" 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-a0bb9b6 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"a0bb9b6\" 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-d4febe5\" data-id=\"d4febe5\" 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-305d7f8 elementor-widget elementor-widget-text-editor\" data-id=\"305d7f8\" 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<div class=\"post-title\"><h2><span class=\"ez-toc-section\" id=\"1-What-is-I2C\"><\/span><span data-contrast=\"auto\"><strong>1. What is I2C?<\/strong><\/span><span class=\"ez-toc-section-end\"><\/span><\/h2><p><span data-contrast=\"auto\"><strong>I2C (Inter-Integrated Circuit)<\/strong>\u00a0is a popular communication protocol used to connect\u00a0<strong>microcontrollers<\/strong>\u00a0and other\u00a0<strong>integrated circuits<\/strong>. It is widely used in embedded systems to enable communication between different components in a system.\u00a0<\/span>It requires two wires, typically labeled\u00a0<strong>SDA<\/strong>\u00a0(Serial Data) and\u00a0<strong>SCL<\/strong>\u00a0(Serial Clock), which are used for bidirectional data transfer and clock synchronization, respectively. Each I2C device on the bus must also have a unique address assigned to it, which is used to identify it during communication. Finally, pull-up resistors must be used on both the SDA and SCL lines to ensure proper signal levels and reduce noise on the bus. The value of the pull-up resistors depends on the capacitance of the bus and the desired clock speed, and should be chosen carefully to ensure reliable communication.<\/p><div id=\"ez-toc-container\" class=\"ez-toc-v2_0_51_1 ez-toc-wrap-left counter-hierarchy ez-toc-counter ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title ez-toc-toggle\" style=\"cursor: pointer\">Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\" role=\"button\"><label for=\"item-69d27181a8744\" ><span class=\"\"><span style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #337ab7;color:#337ab7\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #337ab7;color:#337ab7\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/label><input aria-label=\"Toggle\" aria-label=\"item-69d27181a8744\"  type=\"checkbox\" id=\"item-69d27181a8744\"><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/embeddedwala.com\/beta\/blogs\/digital-communication\/getting-started-with-i2c-what-is-clock-stretching\/#1-What-is-I2C\" title=\"1. What is I2C?\">1. What is I2C?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/embeddedwala.com\/beta\/blogs\/digital-communication\/getting-started-with-i2c-what-is-clock-stretching\/#2-What-is-I2C-protocol-clock-stretching\" title=\"2. What is I2C protocol clock stretching?\">2. What is I2C protocol clock stretching?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/embeddedwala.com\/beta\/blogs\/digital-communication\/getting-started-with-i2c-what-is-clock-stretching\/#3-Conclusion\" title=\"3. Conclusion\">3. Conclusion<\/a><\/li><\/ul><\/nav><\/div>\n<h2><span class=\"ez-toc-section\" id=\"2-What-is-I2C-protocol-clock-stretching\"><\/span><span data-contrast=\"auto\">2. What is I2C protocol clock stretching?<\/span><span class=\"ez-toc-section-end\"><\/span><\/h2><p><span data-contrast=\"auto\">One of the important features of I2C protocol is\u00a0<strong>clock stretching<\/strong>,\u00a0<strong>which is used to temporarily halt the master&#8217;s clock signal by a slave device until it&#8217;s ready to continue with the transmission. Clock stretching allows the slave device to have control over the timing of the communication and enables it to request more time to complete its operation.<\/strong><\/span><\/p><p><span data-contrast=\"auto\">In I2C communication, the master device generates the clock signal which is used to synchronize the communication between the devices. The master device controls the data transmission by sending the start and stop signals, and it determines the clock frequency for the communication. The slave devices, on the other hand, respond to the master&#8217;s commands by sending or receiving data on the data lines.<\/span>\u00a0<\/p><\/div><p>\u00a0<\/p><div class=\"post-title\"><p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-329\" src=\"http:\/\/localhost\/embeddedwala\/wp-content\/uploads\/2023\/06\/i2c-frame-image-clock.png\" alt=\"\" width=\"1920\" height=\"1080\" \/><\/p><p><span data-contrast=\"auto\">When a slave device needs more time to process the data or is not ready to send data, it can hold the clock signal low, which is known as clock stretching. In this case, the slave device holds the SCL (Serial Clock) line low while keeping the SDA (Serial Data) line high. The master device detects this condition and waits for the slave device to release the clock signal before continuing with the communication.<\/span>\u00a0<\/p><\/div><p>\u00a0<\/p><div class=\"post-title\"><p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-328\" src=\"http:\/\/localhost\/embeddedwala\/wp-content\/uploads\/2023\/06\/i2c-clock-blog.png\" alt=\"\" width=\"1920\" height=\"1080\" \/><\/p><p><span data-contrast=\"auto\">The\u00a0<strong>clock stretching<\/strong>\u00a0technique allows slave devices to\u00a0<strong>slow down the communication speed<\/strong>\u00a0and\u00a0<strong>temporarily suspend the communication<\/strong>\u00a0with the master device. This can be useful in scenarios where the slave device needs more time to complete its operation or if there is a delay in the response due to some external factors. Clock stretching is an essential feature in I2C communication, especially in scenarios where different devices have varying processing speeds or when one device is slower than the other.<\/span>\u00a0<\/p><p><span data-contrast=\"auto\">However, clock stretching can cause problems in some cases, especially when the master device is not designed to handle the clock stretching. If the master device does not detect the clock stretching condition, it may continue to transmit data, leading to\u00a0<strong>communication errors<\/strong>\u00a0or\u00a0<strong>data loss<\/strong>. Therefore, it is essential to design the master device with the clock stretching feature in mind, and the device should be able to detect the clock stretching condition and handle it appropriately.<\/span>\u00a0<\/p><h2><span class=\"ez-toc-section\" id=\"3-Conclusion\"><\/span>3. Conclusion<span class=\"ez-toc-section-end\"><\/span><\/h2><p><span data-contrast=\"auto\">In conclusion, clock stretching is an important feature of the I2C communication protocol that enables the slave devices to control the timing of the communication. It allows the slave device to temporarily halt the clock signal to request more time to complete its operation. However, it can also cause problems if the master device is not designed to handle the clock stretching condition. Therefore, it is essential to design the master device with the clock stretching feature in mind and ensure that it can handle the clock stretching condition to ensure reliable communication between the devices.<\/span>\u00a0<\/p><\/div>\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>1. What is I2C? I2C (Inter-Integrated Circuit)&nbsp;is a popular communication protocol used to connect&nbsp;microcontrollers&nbsp;and other&nbsp;integrated&#8230;<\/p>\n","protected":false},"author":1,"featured_media":327,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[34],"tags":[85,86,54,73],"class_list":["post-326","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-digital-communication","tag-clock-stretching","tag-digital-communications","tag-i2c","tag-serial-communication"],"acf":[],"views":477,"featured_image_urls":{"full":["https:\/\/embeddedwala.com\/beta\/wp-content\/uploads\/2023\/06\/I2c-clock-straching-blog-image.png",1920,1080,false],"thumbnail":["https:\/\/embeddedwala.com\/beta\/wp-content\/uploads\/2023\/06\/I2c-clock-straching-blog-image.png",150,84,false],"medium":["https:\/\/embeddedwala.com\/beta\/wp-content\/uploads\/2023\/06\/I2c-clock-straching-blog-image.png",300,169,false],"medium_large":["https:\/\/embeddedwala.com\/beta\/wp-content\/uploads\/2023\/06\/I2c-clock-straching-blog-image.png",640,360,false],"large":["https:\/\/embeddedwala.com\/beta\/wp-content\/uploads\/2023\/06\/I2c-clock-straching-blog-image.png",640,360,false],"1536x1536":["https:\/\/embeddedwala.com\/beta\/wp-content\/uploads\/2023\/06\/I2c-clock-straching-blog-image.png",1536,864,false],"2048x2048":["https:\/\/embeddedwala.com\/beta\/wp-content\/uploads\/2023\/06\/I2c-clock-straching-blog-image.png",1920,1080,false],"tp-image-grid":["https:\/\/embeddedwala.com\/beta\/wp-content\/uploads\/2023\/06\/I2c-clock-straching-blog-image.png",700,394,false],"covernews-slider-full":["https:\/\/embeddedwala.com\/beta\/wp-content\/uploads\/2023\/06\/I2c-clock-straching-blog-image.png",1115,627,false],"covernews-slider-center":["https:\/\/embeddedwala.com\/beta\/wp-content\/uploads\/2023\/06\/I2c-clock-straching-blog-image.png",800,450,false],"covernews-featured":["https:\/\/embeddedwala.com\/beta\/wp-content\/uploads\/2023\/06\/I2c-clock-straching-blog-image.png",1024,576,false],"covernews-medium":["https:\/\/embeddedwala.com\/beta\/wp-content\/uploads\/2023\/06\/I2c-clock-straching-blog-image.png",540,304,false],"covernews-medium-square":["https:\/\/embeddedwala.com\/beta\/wp-content\/uploads\/2023\/06\/I2c-clock-straching-blog-image.png",400,225,false],"_nx_notification_thumb":["https:\/\/embeddedwala.com\/beta\/wp-content\/uploads\/2023\/06\/I2c-clock-straching-blog-image.png",100,56,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\/326","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=326"}],"version-history":[{"count":6,"href":"https:\/\/embeddedwala.com\/beta\/wp-json\/wp\/v2\/posts\/326\/revisions"}],"predecessor-version":[{"id":6201,"href":"https:\/\/embeddedwala.com\/beta\/wp-json\/wp\/v2\/posts\/326\/revisions\/6201"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/embeddedwala.com\/beta\/wp-json\/wp\/v2\/media\/327"}],"wp:attachment":[{"href":"https:\/\/embeddedwala.com\/beta\/wp-json\/wp\/v2\/media?parent=326"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/embeddedwala.com\/beta\/wp-json\/wp\/v2\/categories?post=326"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/embeddedwala.com\/beta\/wp-json\/wp\/v2\/tags?post=326"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}