{"id":2231,"date":"2017-07-25T16:53:13","date_gmt":"2017-07-25T15:53:13","guid":{"rendered":"https:\/\/ridgesolutions.ie\/?p=2231"},"modified":"2017-07-26T10:30:34","modified_gmt":"2017-07-26T09:30:34","slug":"i2c1_wr-i2c1_rd-functions-hang-with-mikroc-for-pic","status":"publish","type":"post","link":"https:\/\/www.ridgesolutions.ie\/index.php\/2017\/07\/25\/i2c1_wr-i2c1_rd-functions-hang-with-mikroc-for-pic\/","title":{"rendered":"I2C1_Wr \/ I2C1_Rd functions hang with MikroC for PIC &#8211; Need Timeout"},"content":{"rendered":"<p>In some cases both the <a href=\"https:\/\/www.mikroe.com\/mikroc\/\">MikroC<\/a> i2c functions <a href=\"http:\/\/download.mikroe.com\/documents\/compilers\/mikroc\/pic\/help\/i2c_library.htm#i2c1_wr\">I2C1_Wr()<\/a> and <a href=\"http:\/\/download.mikroe.com\/documents\/compilers\/mikroc\/pic\/help\/i2c_library.htm#i2c1_rd\">I2C1_Rd()<\/a> can hang or lockup indefinitely until the PIC is reset.  This can happen if the I2C bus isn&#8217;t properly terminated, for example if a connection breaks or similar (broken wire or solder joint etc).  Having your PIC lockup during operation is generally not very desirable if your are trying to develop a stable software system &#8211; if for some reason an i2c device hasn&#8217;t been properly connected your system will just lockup for good!<\/p>\n<p>Different posts discuss this problem and its various causes:<\/p>\n<p><a href=\"https:\/\/forum.mikroe.com\/viewtopic.php?f=13&#038;t=21270&#038;sid=f45f0199695794c83516f89919183cbb&#038;start=0\">https:\/\/forum.mikroe.com\/viewtopic.php?f=13&#038;t=21270&#038;sid=f45f0199695794c83516f89919183cbb&#038;start=0<\/a><\/p>\n<p>and<\/p>\n<p><a href=\"https:\/\/forum.mikroe.com\/viewtopic.php?f=88&#038;t=60224\">https:\/\/forum.mikroe.com\/viewtopic.php?f=88&#038;t=60224<\/a><\/p>\n<p>MikroC provided the code to their functions so that software developers (us) could work around the problem,  this library implements versions of I2C1_Wr() and I2C1_Rd() that timeout rather than hang, a timeout values is passed as a parameter:<\/p>\n<p><a href=\"https:\/\/libstock.mikroe.com\/projects\/view\/1052\/i2c-non-blocking\">https:\/\/libstock.mikroe.com\/projects\/view\/1052\/i2c-non-blocking<\/a><\/p>\n<p>The library doesn&#8217;t implement a C version, so inspired by it (thanks <a href=\"https:\/\/libstock.mikroe.com\/users\/view\/5817\">Danny!<\/a>) I have ported the functions into C, and added some comments &#8211; use at your own risk, it works well for me on PIC18F family chips but hasn&#8217;t been exhaustively tested!<\/p>\n<p>I have declared the timeouts as constants rather than allowing the timeout to be passed in as a parameter &#8211; this is so that the functions can be used as drop-in replacements without having to modify client code.<\/p>\n<pre class=\"lang:c decode:true \" >#define I2C_WRITE_TIMEOUT_US 200\r\n\r\nunsigned short tI2C1_Wr(unsigned short d) {\r\n\r\n    const unsigned int delay = 2; \/\/ us\r\n    unsigned int max_retry = I2C_WRITE_TIMEOUT_US \/ delay;\r\n    unsigned int retry;\r\n    \r\n    if (max_retry == 0)\r\n        max_retry = 1;\r\n        \r\n    \/\/ Interrupt Flag bit - Waiting to transmit\/receive\r\n    PIR1.SSP1IF = 0;\r\n    \r\n    \/\/ Set data for transmission\r\n    SSP1BUF = (unsigned char)d;\r\n\r\n    \/\/ Wait for transmission to complete\r\n    \/\/ 1 = Transmit is in progress\r\n    \/\/ 0 = Transmit is not in progress\r\n    \/\/\r\n    retry = max_retry;\r\n    while (SSP1STAT.r_not_w == 1 && --retry > 0)\r\n        delay_us(delay);\r\n\r\n    \/\/ Timed-out stop transfer and return error\r\n    if (SSP1STAT.r_not_w == 1) {\r\n        \/\/ Enable Stop Condition\r\n        SSP1CON2.PEN = 1;\r\n        return 1;\r\n    }\r\n    \r\n    \/\/ Wait for completion\r\n    \/\/ 1 = The transmission\/reception is complete (must be cleared by software)\r\n    \/\/ 0 = Waiting to transmit\/receive\r\n    \/\/\r\n    retry = max_retry;\r\n    while (PIR1.SSP1IF == 0 && --retry > 0)\r\n        delay_us(delay);\r\n\r\n    \/\/ Timed-out stop transfer and return error\r\n    if (PIR1.SSP1IF == 0) {\r\n        \/\/ Enable Stop Condition\r\n        SSP1CON2.PEN = 1;\r\n        return 1;\r\n    }\r\n\r\n    \/\/ Check that we got an ACK\r\n    \/\/ 1 = Acknowledge was not received\r\n    \/\/ 0 = Acknowledge was received\r\n    \/\/\r\n    if (SSP1CON2.ACKSTAT != 0) {\r\n        \/\/ No ACK, abort\r\n        \/\/ Enable Stop Condition\r\n        SSP1CON2.PEN = 1;\r\n        return 1;\r\n    }\r\n\r\n    \/\/ All good...\r\n    return 0;\r\n}\r\n\r\n\r\n<\/pre>\n<p>And to Read:<\/p>\n<pre>\r\n\r\n#define I2C_READ_TIMEOUT_US 200\r\n\r\nunsigned short tI2C1_Rd(unsigned short ack) {\r\n\r\n    unsigned short d = 0;\r\n    const unsigned int delay = 2; \/\/ us\r\n    unsigned int max_retry = I2C_READ_TIMEOUT_US \/ delay;\r\n    unsigned int retry;\r\n\r\n    if (max_retry == 0)\r\n        max_retry = 1;\r\n        \r\n    \/\/ Interrupt Flag bit - Waiting to transmit\/receive\r\n    \/\/ 1 = The transmission\/reception is complete (must be cleared by software)\r\n    \/\/ 0 = Waiting to transmit\/receive\r\n    \/\/\r\n    PIR1.SSP1IF = 0;\r\n\r\n    \/\/ Set receive mode\r\n    \/\/ 1 = Enables Receive mode for I2C\r\n    \/\/ 0 = Receive idle\r\n    \/\/\r\n    SSP1CON2.RCEN = 1;\r\n\r\n    \/\/ Wait for read completion\r\n    \/\/ 1 = The transmission\/reception is complete (must be cleared by software)\r\n    \/\/ 0 = Waiting to transmit\/receive\r\n    \/\/\r\n    retry = max_retry;\r\n    while (PIR1.SSP1IF == 0 && --retry > 0)\r\n        delay_us(delay);\r\n\r\n    \/\/ Still not complete, get out...\r\n    if (PIR1.SSP1IF == 0)\r\n        return 0;\r\n\r\n    \/\/ grab the data\r\n    d = (unsigned short)SSPBUF;\r\n\r\n    \/\/ ACK required?\r\n    if (ack == 0) {\r\n        \/\/ No\r\n        \/\/ 1 = Not Acknowledge\r\n        \/\/ 0 = Acknowledge\r\n        \/\/\r\n        SSP1CON2.ACKDT = 1;\r\n    } else {\r\n        \/\/ Yes\r\n        SSP1CON2.ACKDT = 0;\r\n    }\r\n\r\n    \/\/ Interrupt Flag bit - Waiting to transmit\/receive\r\n    \/\/ 1 = The transmission\/reception is complete (must be cleared by software)\r\n    \/\/ 0 = Waiting to transmit\/receive\r\n    \/\/\r\n    PIR1.SSP1IF = 0;\r\n\r\n    \/\/ Start Ack sequence\r\n    \/\/ 1 = Initiate Acknowledge sequence on SDAx and SCLx pins, and transmit ACKDT data bit. Automatically cleared by hardware.\r\n    \/\/ 0 = Acknowledge sequence idle\r\n    \/\/\r\n    SSP1CON2.ACKEN = 1;\r\n\r\n    \/\/ Wait for completion of ack sequence\r\n    retry = max_retry;\r\n    while (PIR1.SSP1IF == 0 && --retry > 0)\r\n        delay_us(delay);\r\n\r\n    return d;\r\n}\r\n\r\n<\/pre>\n<p>This works for the first i2c device, it is left as an exercise for the reader to convert it for a second i2c device, i.e. I2C2_Wr() and I2C2_Rd()<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In some cases both the MikroC i2c functions I2C1_Wr() and I2C1_Rd() can hang or lockup indefinitely until the PIC is reset. This can happen if the I2C bus isn&#8217;t properly terminated, for example if a connection breaks or similar (broken wire or solder joint etc). Having your PIC lockup during operation is generally not very [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[315,314],"class_list":["post-2231","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-mikroc","tag-pic"],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 5.0.0.1 - aioseo.com -->\n\t<meta name=\"description\" content=\"In some cases both the MikroC i2c functions I2C1_Wr() and I2C1_Rd() can hang or lockup indefinitely until the PIC is reset. This can happen if the I2C bus isn&#039;t properly terminated, for example if a connection breaks or similar (broken wire or solder joint etc). Having your PIC lockup during operation is generally not very\" \/>\n\t<meta name=\"robots\" content=\"max-image-preview:large\" \/>\n\t<meta name=\"author\" content=\"admin\"\/>\n\t<meta name=\"google-site-verification\" content=\"Kyj52YLp6GOPA44PVBffo9fjW8rgWHYYRF0ZYjfy6ss\" \/>\n\t<link rel=\"canonical\" href=\"https:\/\/www.ridgesolutions.ie\/index.php\/2017\/07\/25\/i2c1_wr-i2c1_rd-functions-hang-with-mikroc-for-pic\/\" \/>\n\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 5.0.0.1\" \/>\n\t\t<meta property=\"og:locale\" content=\"en_US\" \/>\n\t\t<meta property=\"og:site_name\" content=\"Systems and Embedded Software Engineering, Ireland. | Some thoughts of a busy Computer Engineer\" \/>\n\t\t<meta property=\"og:type\" content=\"article\" \/>\n\t\t<meta property=\"og:title\" content=\"I2C1_Wr \/ I2C1_Rd functions hang with MikroC for PIC \u2013 Need Timeout\" \/>\n\t\t<meta property=\"og:description\" content=\"In some cases both the MikroC i2c functions I2C1_Wr() and I2C1_Rd() can hang or lockup indefinitely until the PIC is reset. This can happen if the I2C bus isn&#039;t properly terminated, for example if a connection breaks or similar (broken wire or solder joint etc). Having your PIC lockup during operation is generally not very\" \/>\n\t\t<meta property=\"og:url\" content=\"https:\/\/www.ridgesolutions.ie\/index.php\/2017\/07\/25\/i2c1_wr-i2c1_rd-functions-hang-with-mikroc-for-pic\/\" \/>\n\t\t<meta property=\"article:published_time\" content=\"2017-07-25T15:53:13+00:00\" \/>\n\t\t<meta property=\"article:modified_time\" content=\"2017-07-26T09:30:34+00:00\" \/>\n\t\t<meta name=\"twitter:card\" content=\"summary\" \/>\n\t\t<meta name=\"twitter:title\" content=\"I2C1_Wr \/ I2C1_Rd functions hang with MikroC for PIC \u2013 Need Timeout\" \/>\n\t\t<meta name=\"twitter:description\" content=\"In some cases both the MikroC i2c functions I2C1_Wr() and I2C1_Rd() can hang or lockup indefinitely until the PIC is reset. This can happen if the I2C bus isn&#039;t properly terminated, for example if a connection breaks or similar (broken wire or solder joint etc). Having your PIC lockup during operation is generally not very\" \/>\n\t\t<script type=\"application\/ld+json\" class=\"aioseo-schema\">\n\t\t\t{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.ridgesolutions.ie\\\/index.php\\\/2017\\\/07\\\/25\\\/i2c1_wr-i2c1_rd-functions-hang-with-mikroc-for-pic\\\/#article\",\"name\":\"I2C1_Wr \\\/ I2C1_Rd functions hang with MikroC for PIC \\u2013 Need Timeout\",\"headline\":\"I2C1_Wr \\\/ I2C1_Rd functions hang with MikroC for PIC &#8211; Need Timeout\",\"author\":{\"@id\":\"https:\\\/\\\/www.ridgesolutions.ie\\\/index.php\\\/author\\\/admin\\\/#author\"},\"publisher\":{\"@id\":\"https:\\\/\\\/www.ridgesolutions.ie\\\/#organization\"},\"image\":{\"@type\":\"ImageObject\",\"url\":\"https:\\\/\\\/www.ridgesolutions.ie\\\/wp-content\\\/uploads\\\/2013\\\/09\\\/ridge_logo1.jpg\",\"@id\":\"https:\\\/\\\/www.ridgesolutions.ie\\\/#articleImage\",\"width\":400,\"height\":81},\"datePublished\":\"2017-07-25T16:53:13+00:00\",\"dateModified\":\"2017-07-26T10:30:34+00:00\",\"inLanguage\":\"en-US\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.ridgesolutions.ie\\\/index.php\\\/2017\\\/07\\\/25\\\/i2c1_wr-i2c1_rd-functions-hang-with-mikroc-for-pic\\\/#webpage\"},\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.ridgesolutions.ie\\\/index.php\\\/2017\\\/07\\\/25\\\/i2c1_wr-i2c1_rd-functions-hang-with-mikroc-for-pic\\\/#webpage\"},\"articleSection\":\"Uncategorized, mikroc, pic\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.ridgesolutions.ie\\\/index.php\\\/2017\\\/07\\\/25\\\/i2c1_wr-i2c1_rd-functions-hang-with-mikroc-for-pic\\\/#breadcrumblist\",\"itemListElement\":[{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.ridgesolutions.ie#listItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.ridgesolutions.ie\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.ridgesolutions.ie\\\/index.php\\\/category\\\/uncategorized\\\/#listItem\",\"name\":\"Uncategorized\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.ridgesolutions.ie\\\/index.php\\\/category\\\/uncategorized\\\/#listItem\",\"position\":2,\"name\":\"Uncategorized\",\"item\":\"https:\\\/\\\/www.ridgesolutions.ie\\\/index.php\\\/category\\\/uncategorized\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.ridgesolutions.ie\\\/index.php\\\/2017\\\/07\\\/25\\\/i2c1_wr-i2c1_rd-functions-hang-with-mikroc-for-pic\\\/#listItem\",\"name\":\"I2C1_Wr \\\/ I2C1_Rd functions hang with MikroC for PIC &#8211; Need Timeout\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.ridgesolutions.ie#listItem\",\"name\":\"Home\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.ridgesolutions.ie\\\/index.php\\\/2017\\\/07\\\/25\\\/i2c1_wr-i2c1_rd-functions-hang-with-mikroc-for-pic\\\/#listItem\",\"position\":3,\"name\":\"I2C1_Wr \\\/ I2C1_Rd functions hang with MikroC for PIC &#8211; Need Timeout\",\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.ridgesolutions.ie\\\/index.php\\\/category\\\/uncategorized\\\/#listItem\",\"name\":\"Uncategorized\"}}]},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.ridgesolutions.ie\\\/#organization\",\"name\":\"Ridge Solutions, Software Development and Software Engineering, Ireland.\",\"description\":\"Some thoughts of a busy Computer Engineer\",\"url\":\"https:\\\/\\\/www.ridgesolutions.ie\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"url\":\"https:\\\/\\\/www.ridgesolutions.ie\\\/wp-content\\\/uploads\\\/2013\\\/09\\\/ridge_logo1.jpg\",\"@id\":\"https:\\\/\\\/www.ridgesolutions.ie\\\/index.php\\\/2017\\\/07\\\/25\\\/i2c1_wr-i2c1_rd-functions-hang-with-mikroc-for-pic\\\/#organizationLogo\",\"width\":400,\"height\":81},\"image\":{\"@id\":\"https:\\\/\\\/www.ridgesolutions.ie\\\/index.php\\\/2017\\\/07\\\/25\\\/i2c1_wr-i2c1_rd-functions-hang-with-mikroc-for-pic\\\/#organizationLogo\"}},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.ridgesolutions.ie\\\/index.php\\\/author\\\/admin\\\/#author\",\"url\":\"https:\\\/\\\/www.ridgesolutions.ie\\\/index.php\\\/author\\\/admin\\\/\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\\\/\\\/www.ridgesolutions.ie\\\/index.php\\\/2017\\\/07\\\/25\\\/i2c1_wr-i2c1_rd-functions-hang-with-mikroc-for-pic\\\/#authorImage\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/0bcb44e82b647e8707b506ed8100bbeb7e4c9a889f1e6fdd152fce740e3ac9fa?s=96&d=mm&r=g\",\"width\":96,\"height\":96,\"caption\":\"admin\"}},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.ridgesolutions.ie\\\/index.php\\\/2017\\\/07\\\/25\\\/i2c1_wr-i2c1_rd-functions-hang-with-mikroc-for-pic\\\/#webpage\",\"url\":\"https:\\\/\\\/www.ridgesolutions.ie\\\/index.php\\\/2017\\\/07\\\/25\\\/i2c1_wr-i2c1_rd-functions-hang-with-mikroc-for-pic\\\/\",\"name\":\"I2C1_Wr \\\/ I2C1_Rd functions hang with MikroC for PIC \\u2013 Need Timeout\",\"description\":\"In some cases both the MikroC i2c functions I2C1_Wr() and I2C1_Rd() can hang or lockup indefinitely until the PIC is reset. This can happen if the I2C bus isn't properly terminated, for example if a connection breaks or similar (broken wire or solder joint etc). Having your PIC lockup during operation is generally not very\",\"inLanguage\":\"en-US\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.ridgesolutions.ie\\\/#website\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.ridgesolutions.ie\\\/index.php\\\/2017\\\/07\\\/25\\\/i2c1_wr-i2c1_rd-functions-hang-with-mikroc-for-pic\\\/#breadcrumblist\"},\"author\":{\"@id\":\"https:\\\/\\\/www.ridgesolutions.ie\\\/index.php\\\/author\\\/admin\\\/#author\"},\"creator\":{\"@id\":\"https:\\\/\\\/www.ridgesolutions.ie\\\/index.php\\\/author\\\/admin\\\/#author\"},\"datePublished\":\"2017-07-25T16:53:13+00:00\",\"dateModified\":\"2017-07-26T10:30:34+00:00\"},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.ridgesolutions.ie\\\/#website\",\"url\":\"https:\\\/\\\/www.ridgesolutions.ie\\\/\",\"name\":\"Ridge Solutions, Software Development and Software Engineering, Ireland.\",\"description\":\"Some thoughts of a busy Computer Engineer\",\"inLanguage\":\"en-US\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.ridgesolutions.ie\\\/#organization\"}}]}\n\t\t<\/script>\n\t\t<!-- All in One SEO -->\n\n","aioseo_head_json":{"title":"I2C1_Wr \/ I2C1_Rd functions hang with MikroC for PIC \u2013 Need Timeout","description":"In some cases both the MikroC i2c functions I2C1_Wr() and I2C1_Rd() can hang or lockup indefinitely until the PIC is reset. This can happen if the I2C bus isn't properly terminated, for example if a connection breaks or similar (broken wire or solder joint etc). Having your PIC lockup during operation is generally not very","canonical_url":"https:\/\/www.ridgesolutions.ie\/index.php\/2017\/07\/25\/i2c1_wr-i2c1_rd-functions-hang-with-mikroc-for-pic\/","robots":"max-image-preview:large","keywords":"","webmasterTools":{"google-site-verification":"Kyj52YLp6GOPA44PVBffo9fjW8rgWHYYRF0ZYjfy6ss","miscellaneous":""},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.ridgesolutions.ie\/index.php\/2017\/07\/25\/i2c1_wr-i2c1_rd-functions-hang-with-mikroc-for-pic\/#article","name":"I2C1_Wr \/ I2C1_Rd functions hang with MikroC for PIC \u2013 Need Timeout","headline":"I2C1_Wr \/ I2C1_Rd functions hang with MikroC for PIC &#8211; Need Timeout","author":{"@id":"https:\/\/www.ridgesolutions.ie\/index.php\/author\/admin\/#author"},"publisher":{"@id":"https:\/\/www.ridgesolutions.ie\/#organization"},"image":{"@type":"ImageObject","url":"https:\/\/www.ridgesolutions.ie\/wp-content\/uploads\/2013\/09\/ridge_logo1.jpg","@id":"https:\/\/www.ridgesolutions.ie\/#articleImage","width":400,"height":81},"datePublished":"2017-07-25T16:53:13+00:00","dateModified":"2017-07-26T10:30:34+00:00","inLanguage":"en-US","mainEntityOfPage":{"@id":"https:\/\/www.ridgesolutions.ie\/index.php\/2017\/07\/25\/i2c1_wr-i2c1_rd-functions-hang-with-mikroc-for-pic\/#webpage"},"isPartOf":{"@id":"https:\/\/www.ridgesolutions.ie\/index.php\/2017\/07\/25\/i2c1_wr-i2c1_rd-functions-hang-with-mikroc-for-pic\/#webpage"},"articleSection":"Uncategorized, mikroc, pic"},{"@type":"BreadcrumbList","@id":"https:\/\/www.ridgesolutions.ie\/index.php\/2017\/07\/25\/i2c1_wr-i2c1_rd-functions-hang-with-mikroc-for-pic\/#breadcrumblist","itemListElement":[{"@type":"ListItem","@id":"https:\/\/www.ridgesolutions.ie#listItem","position":1,"name":"Home","item":"https:\/\/www.ridgesolutions.ie","nextItem":{"@type":"ListItem","@id":"https:\/\/www.ridgesolutions.ie\/index.php\/category\/uncategorized\/#listItem","name":"Uncategorized"}},{"@type":"ListItem","@id":"https:\/\/www.ridgesolutions.ie\/index.php\/category\/uncategorized\/#listItem","position":2,"name":"Uncategorized","item":"https:\/\/www.ridgesolutions.ie\/index.php\/category\/uncategorized\/","nextItem":{"@type":"ListItem","@id":"https:\/\/www.ridgesolutions.ie\/index.php\/2017\/07\/25\/i2c1_wr-i2c1_rd-functions-hang-with-mikroc-for-pic\/#listItem","name":"I2C1_Wr \/ I2C1_Rd functions hang with MikroC for PIC &#8211; Need Timeout"},"previousItem":{"@type":"ListItem","@id":"https:\/\/www.ridgesolutions.ie#listItem","name":"Home"}},{"@type":"ListItem","@id":"https:\/\/www.ridgesolutions.ie\/index.php\/2017\/07\/25\/i2c1_wr-i2c1_rd-functions-hang-with-mikroc-for-pic\/#listItem","position":3,"name":"I2C1_Wr \/ I2C1_Rd functions hang with MikroC for PIC &#8211; Need Timeout","previousItem":{"@type":"ListItem","@id":"https:\/\/www.ridgesolutions.ie\/index.php\/category\/uncategorized\/#listItem","name":"Uncategorized"}}]},{"@type":"Organization","@id":"https:\/\/www.ridgesolutions.ie\/#organization","name":"Ridge Solutions, Software Development and Software Engineering, Ireland.","description":"Some thoughts of a busy Computer Engineer","url":"https:\/\/www.ridgesolutions.ie\/","logo":{"@type":"ImageObject","url":"https:\/\/www.ridgesolutions.ie\/wp-content\/uploads\/2013\/09\/ridge_logo1.jpg","@id":"https:\/\/www.ridgesolutions.ie\/index.php\/2017\/07\/25\/i2c1_wr-i2c1_rd-functions-hang-with-mikroc-for-pic\/#organizationLogo","width":400,"height":81},"image":{"@id":"https:\/\/www.ridgesolutions.ie\/index.php\/2017\/07\/25\/i2c1_wr-i2c1_rd-functions-hang-with-mikroc-for-pic\/#organizationLogo"}},{"@type":"Person","@id":"https:\/\/www.ridgesolutions.ie\/index.php\/author\/admin\/#author","url":"https:\/\/www.ridgesolutions.ie\/index.php\/author\/admin\/","name":"admin","image":{"@type":"ImageObject","@id":"https:\/\/www.ridgesolutions.ie\/index.php\/2017\/07\/25\/i2c1_wr-i2c1_rd-functions-hang-with-mikroc-for-pic\/#authorImage","url":"https:\/\/secure.gravatar.com\/avatar\/0bcb44e82b647e8707b506ed8100bbeb7e4c9a889f1e6fdd152fce740e3ac9fa?s=96&d=mm&r=g","width":96,"height":96,"caption":"admin"}},{"@type":"WebPage","@id":"https:\/\/www.ridgesolutions.ie\/index.php\/2017\/07\/25\/i2c1_wr-i2c1_rd-functions-hang-with-mikroc-for-pic\/#webpage","url":"https:\/\/www.ridgesolutions.ie\/index.php\/2017\/07\/25\/i2c1_wr-i2c1_rd-functions-hang-with-mikroc-for-pic\/","name":"I2C1_Wr \/ I2C1_Rd functions hang with MikroC for PIC \u2013 Need Timeout","description":"In some cases both the MikroC i2c functions I2C1_Wr() and I2C1_Rd() can hang or lockup indefinitely until the PIC is reset. This can happen if the I2C bus isn't properly terminated, for example if a connection breaks or similar (broken wire or solder joint etc). Having your PIC lockup during operation is generally not very","inLanguage":"en-US","isPartOf":{"@id":"https:\/\/www.ridgesolutions.ie\/#website"},"breadcrumb":{"@id":"https:\/\/www.ridgesolutions.ie\/index.php\/2017\/07\/25\/i2c1_wr-i2c1_rd-functions-hang-with-mikroc-for-pic\/#breadcrumblist"},"author":{"@id":"https:\/\/www.ridgesolutions.ie\/index.php\/author\/admin\/#author"},"creator":{"@id":"https:\/\/www.ridgesolutions.ie\/index.php\/author\/admin\/#author"},"datePublished":"2017-07-25T16:53:13+00:00","dateModified":"2017-07-26T10:30:34+00:00"},{"@type":"WebSite","@id":"https:\/\/www.ridgesolutions.ie\/#website","url":"https:\/\/www.ridgesolutions.ie\/","name":"Ridge Solutions, Software Development and Software Engineering, Ireland.","description":"Some thoughts of a busy Computer Engineer","inLanguage":"en-US","publisher":{"@id":"https:\/\/www.ridgesolutions.ie\/#organization"}}]},"og:locale":"en_US","og:site_name":"Systems and Embedded Software Engineering, Ireland. | Some thoughts of a busy Computer Engineer","og:type":"article","og:title":"I2C1_Wr \/ I2C1_Rd functions hang with MikroC for PIC \u2013 Need Timeout","og:description":"In some cases both the MikroC i2c functions I2C1_Wr() and I2C1_Rd() can hang or lockup indefinitely until the PIC is reset. This can happen if the I2C bus isn't properly terminated, for example if a connection breaks or similar (broken wire or solder joint etc). Having your PIC lockup during operation is generally not very","og:url":"https:\/\/www.ridgesolutions.ie\/index.php\/2017\/07\/25\/i2c1_wr-i2c1_rd-functions-hang-with-mikroc-for-pic\/","article:published_time":"2017-07-25T15:53:13+00:00","article:modified_time":"2017-07-26T09:30:34+00:00","twitter:card":"summary","twitter:title":"I2C1_Wr \/ I2C1_Rd functions hang with MikroC for PIC \u2013 Need Timeout","twitter:description":"In some cases both the MikroC i2c functions I2C1_Wr() and I2C1_Rd() can hang or lockup indefinitely until the PIC is reset. This can happen if the I2C bus isn't properly terminated, for example if a connection breaks or similar (broken wire or solder joint etc). Having your PIC lockup during operation is generally not very"},"aioseo_meta_data":{"post_id":"2231","title":null,"description":null,"keywords":[{"label":"PIC","value":"PIC"},{"label":"I2C","value":"I2C"},{"label":"MikroC","value":"MikroC"},{"label":"Timeout","value":"Timeout"},{"label":"hang","value":"hang"},{"label":"lockup","value":"lockup"}],"keyphrases":null,"primary_term":null,"canonical_url":null,"og_title":null,"og_description":null,"og_object_type":"default","og_image_type":"default","og_image_url":null,"og_image_width":null,"og_image_height":null,"og_image_custom_url":null,"og_image_custom_fields":null,"og_video":null,"og_custom_url":null,"og_article_section":null,"og_article_tags":null,"twitter_use_og":false,"twitter_card":"default","twitter_image_type":"default","twitter_image_url":null,"twitter_image_custom_url":null,"twitter_image_custom_fields":null,"twitter_title":null,"twitter_description":null,"schema":{"blockGraphs":[],"customGraphs":[],"default":{"data":{"Article":[],"Course":[],"Dataset":[],"FAQPage":[],"Movie":[],"Person":[],"Product":[],"ProductReview":[],"Car":[],"Recipe":[],"Service":[],"SoftwareApplication":[],"WebPage":[]},"graphName":"Article","isEnabled":true},"graphs":[]},"schema_type":null,"schema_type_options":null,"pillar_content":false,"robots_default":true,"robots_noindex":false,"robots_noarchive":false,"robots_nosnippet":false,"robots_nofollow":false,"robots_noimageindex":false,"robots_noodp":false,"robots_notranslate":false,"robots_max_snippet":null,"robots_max_videopreview":null,"robots_max_imagepreview":"large","priority":null,"frequency":null,"local_seo":null,"breadcrumb_settings":null,"limit_modified_date":false,"ai":null,"created":"2021-09-13 21:35:44","updated":"2025-07-15 23:19:46","seo_analyzer_scan_date":null,"focus_keyword":null,"additional_keywords":null,"truseo_locale":null},"aioseo_breadcrumb":"<div class=\"aioseo-breadcrumbs\"><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/www.ridgesolutions.ie\" title=\"Home\">Home<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/www.ridgesolutions.ie\/index.php\/category\/uncategorized\/\" title=\"Uncategorized\">Uncategorized<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\tI2C1_Wr \/ I2C1_Rd functions hang with MikroC for PIC \u2013 Need Timeout\n\t\t<\/span><\/div>","aioseo_breadcrumb_json":[{"label":"Home","link":"https:\/\/www.ridgesolutions.ie"},{"label":"Uncategorized","link":"https:\/\/www.ridgesolutions.ie\/index.php\/category\/uncategorized\/"},{"label":"I2C1_Wr \/ I2C1_Rd functions hang with MikroC for PIC &#8211; Need Timeout","link":"https:\/\/www.ridgesolutions.ie\/index.php\/2017\/07\/25\/i2c1_wr-i2c1_rd-functions-hang-with-mikroc-for-pic\/"}],"_links":{"self":[{"href":"https:\/\/www.ridgesolutions.ie\/index.php\/wp-json\/wp\/v2\/posts\/2231","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.ridgesolutions.ie\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.ridgesolutions.ie\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.ridgesolutions.ie\/index.php\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ridgesolutions.ie\/index.php\/wp-json\/wp\/v2\/comments?post=2231"}],"version-history":[{"count":0,"href":"https:\/\/www.ridgesolutions.ie\/index.php\/wp-json\/wp\/v2\/posts\/2231\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.ridgesolutions.ie\/index.php\/wp-json\/wp\/v2\/media?parent=2231"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ridgesolutions.ie\/index.php\/wp-json\/wp\/v2\/categories?post=2231"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ridgesolutions.ie\/index.php\/wp-json\/wp\/v2\/tags?post=2231"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}