{"id":1300,"date":"2023-06-06T11:10:56","date_gmt":"2023-06-06T10:10:56","guid":{"rendered":"https:\/\/ibex.tech\/embedded\/?p=1300"},"modified":"2023-06-06T11:13:21","modified_gmt":"2023-06-06T10:13:21","slug":"i2c-general","status":"publish","type":"post","link":"https:\/\/ibex.tech\/embedded\/microchip\/pic12\/xc8-compiler-pic12\/i2c-xc8-compiler-pic12\/i2c-general","title":{"rendered":"I2C General"},"content":{"rendered":"\n<h4 class=\"wp-block-heading\">Config I2C<\/h4>\n\n\n\n<p>Use MCC<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">I2C Addresses<\/h4>\n\n\n\n<p>You need to use addresses with the R\/W bit removed, so Bits 7:1 are in bits 6:0<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#define\tMY_DEVICE_I2C_BASE_ADDRESS\t\t\t\t(0x18 &gt;&gt; 1)<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">I2C Read<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>\tuint8_t Data&#91;2];\n\n\n\t\n\tI2C_ReadNBytes(MY_DEVICE_I2C_BASE_ADDRESS, &amp;Data&#91;0], 2);<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">I2C Write<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>\tuint8_t Data&#91;3];\n\n\tData&#91;0] = 0b00110001;\n\tData&#91;1] = 0x55;\n\tData&#91;2] = 0xaa;\n\tI2C_WriteNBytes(MY_DEVICE_I2C_BASE_ADDRESS, &amp;Data&#91;0], 3);<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Config I2C Use MCC I2C Addresses You need to use addresses with the R\/W bit removed, so Bits 7:1 are in bits 6:0 I2C Read I2C Write<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[104],"tags":[],"class_list":["post-1300","post","type-post","status-publish","format-standard","hentry","category-i2c-xc8-compiler-pic12"],"_links":{"self":[{"href":"https:\/\/ibex.tech\/embedded\/wp-json\/wp\/v2\/posts\/1300","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ibex.tech\/embedded\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ibex.tech\/embedded\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ibex.tech\/embedded\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ibex.tech\/embedded\/wp-json\/wp\/v2\/comments?post=1300"}],"version-history":[{"count":3,"href":"https:\/\/ibex.tech\/embedded\/wp-json\/wp\/v2\/posts\/1300\/revisions"}],"predecessor-version":[{"id":1304,"href":"https:\/\/ibex.tech\/embedded\/wp-json\/wp\/v2\/posts\/1300\/revisions\/1304"}],"wp:attachment":[{"href":"https:\/\/ibex.tech\/embedded\/wp-json\/wp\/v2\/media?parent=1300"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ibex.tech\/embedded\/wp-json\/wp\/v2\/categories?post=1300"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ibex.tech\/embedded\/wp-json\/wp\/v2\/tags?post=1300"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}