{"id":125,"date":"2012-05-24T09:00:19","date_gmt":"2012-05-24T09:00:19","guid":{"rendered":"http:\/\/www.electronic-products-development.com\/?p=125"},"modified":"2022-02-18T15:37:50","modified_gmt":"2022-02-18T15:37:50","slug":"i2c","status":"publish","type":"post","link":"https:\/\/ibex.tech\/embedded\/microchip\/pic18\/c18-compiler\/i2c","title":{"rendered":"I2C"},"content":{"rendered":"<pre><code>\r\n\/\/----- SETUP SSP AS I2C -----\r\n\/\/I2C requirements:- 100kHz clock high time 4.0uS, clock low time 4.7uS, 400kHz clock high time 0.6uS, clock low time 1.3uS\r\n\/\/The PIC18 does not fully conform to the 400kHz I2C spec (which applies to all rates &gt;100kHz) but may be used with care\r\n\/\/where higher rates are required.\r\n\/\/Lower 7 bits of SSPADD are the baud rate.  ((Tcycle \/ 2) * SSPADD * 2) = time per bit.  1 \/ time per bit = frequency.\r\n\/\/400kHz @ 40MHz OSC = SSPADD 25\r\n\/\/100kHz @ 40MHz OSC = SSPADD 100\r\n\/\/100kHz @ 32MHz OSC = SSPADD 80\r\n\/\/100kHz @ 4MHz OSC = SSPADD 10\r\nSSPADD = 100; \/\/setup i2c clk speed\r\nOpenI2C(MASTER, SLEW_OFF); \/\/Slew rate control should be on for 400KHz, off for 100KHz & 1MHz\r\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\/\/&#8212;&#8211; SETUP SSP AS I2C &#8212;&#8211; \/\/I2C requirements:- 100kHz clock high time 4.0uS, clock low time 4.7uS, 400kHz clock high time 0.6uS, clock low time 1.3uS \/\/The PIC18 does not fully conform to the 400kHz I2C spec (which applies to all rates &gt;100kHz) but may be used with care \/\/where higher rates are required. \/\/Lower [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[21],"tags":[],"class_list":["post-125","post","type-post","status-publish","format-standard","hentry","category-c18-compiler"],"_links":{"self":[{"href":"https:\/\/ibex.tech\/embedded\/wp-json\/wp\/v2\/posts\/125","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=125"}],"version-history":[{"count":2,"href":"https:\/\/ibex.tech\/embedded\/wp-json\/wp\/v2\/posts\/125\/revisions"}],"predecessor-version":[{"id":544,"href":"https:\/\/ibex.tech\/embedded\/wp-json\/wp\/v2\/posts\/125\/revisions\/544"}],"wp:attachment":[{"href":"https:\/\/ibex.tech\/embedded\/wp-json\/wp\/v2\/media?parent=125"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ibex.tech\/embedded\/wp-json\/wp\/v2\/categories?post=125"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ibex.tech\/embedded\/wp-json\/wp\/v2\/tags?post=125"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}