{"id":206,"date":"2013-05-11T19:32:24","date_gmt":"2013-05-11T19:32:24","guid":{"rendered":"http:\/\/mitat.tuu.fi\/?p=206"},"modified":"2014-02-08T09:47:42","modified_gmt":"2014-02-08T09:47:42","slug":"pin-interrupts-on-atmega-168-328-arduino","status":"publish","type":"post","link":"http:\/\/mitat.tuu.fi\/?p=206","title":{"rendered":"Pin interrupts on Atmega 168 + 328 (Arduino)"},"content":{"rendered":"<p>From <a href=\"http:\/\/arduino.cc\/forum\/index.php?topic=80928.0\">http:\/\/arduino.cc\/forum\/index.php?topic=80928.0<\/a><\/p>\n<p>From http:\/\/arduino.cc\/forum\/index.php?topic=80928.0<\/p>\n<pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\r\n\/*\r\n* Theory: all IO pins on Atmega168 are covered by Pin Change Interrupts.\r\n* The PCINT corresponding to the pin must be enabled and masked, and\r\n* an ISR routine provided. Since PCINTs are per port, not per pin, the ISR\r\n* must use some logic to actually implement a per-pin interrupt service.\r\n*\/\r\n\r\n\/* Pin to interrupt map:\r\n* D0-D7 = PCINT 16-23 = PCIR2 = PD = PCIE2 = pcmsk2\r\n* D8-D13 = PCINT 0-5 = PCIR0 = PB = PCIE0 = pcmsk0\r\n* A0-A5 (D14-D19) = PCINT 8-13 = PCIR1 = PC = PCIE1 = pcmsk1\r\n*\/\r\n\r\nSetup:\r\n\r\nPCMSK2 |= (1&lt;&lt;PCINT23);\r\nPCICR |= (1 &lt;&lt; PCIE2);\r\nPCMSK0 |= (1&lt;&lt;PCINT0);\r\nPCICR |= (1 &lt;&lt; PCIE0);\r\nISR(PCINT2_vect)\r\n\r\n\r\n\r\n\r\nISR(PCINT0_vect)\r\n{\r\ncode here\r\n}\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>From http:\/\/arduino.cc\/forum\/index.php?topic=80928.0 From http:\/\/arduino.cc\/forum\/index.php?topic=80928.0<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,11],"tags":[],"class_list":["post-206","post","type-post","status-publish","format-standard","hentry","category-code","category-snippet"],"_links":{"self":[{"href":"http:\/\/mitat.tuu.fi\/index.php?rest_route=\/wp\/v2\/posts\/206","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/mitat.tuu.fi\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/mitat.tuu.fi\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/mitat.tuu.fi\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/mitat.tuu.fi\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=206"}],"version-history":[{"count":6,"href":"http:\/\/mitat.tuu.fi\/index.php?rest_route=\/wp\/v2\/posts\/206\/revisions"}],"predecessor-version":[{"id":246,"href":"http:\/\/mitat.tuu.fi\/index.php?rest_route=\/wp\/v2\/posts\/206\/revisions\/246"}],"wp:attachment":[{"href":"http:\/\/mitat.tuu.fi\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=206"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/mitat.tuu.fi\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=206"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/mitat.tuu.fi\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=206"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}