{"id":151,"date":"2011-12-29T20:05:24","date_gmt":"2011-12-29T20:05:24","guid":{"rendered":"http:\/\/mitat.tuu.fi\/?p=151"},"modified":"2012-01-12T19:21:12","modified_gmt":"2012-01-12T19:21:12","slug":"external-interrupts-on-atmega-328","status":"publish","type":"post","link":"http:\/\/mitat.tuu.fi\/?p=151","title":{"rendered":"External interrupts on Atmega 328"},"content":{"rendered":"<p>It&#8217;s this simple:<\/p>\n<p>&#8212;<br \/>\n<code>pinMode(5,INPUT);<br \/>\nPCMSK2 |= (1<<PCINT21); \/\/PCINT21 = PD5 = Digital Input5\nPCICR |= (1 << PCIE2);    \/\/ set PCIE2 to PCMSK2 scan\n<\/code><br \/>\n--<br \/>\nCatch the interrupts (default when signal goes up OR down)<\/p>\n<p><code>ISR(PCINT2_vect)<br \/>\n{<br \/>\n \/\/ code here..<br \/>\n}<br \/>\n<\/code><\/p>\n<p>PCINT?_vect vectors are always used for Pin Change Interrupt Request Interrupts (see<a href=\"http:\/\/www.nongnu.org\/avr-libc\/user-manual\/group__avr__interrupts.html\"> http:\/\/www.nongnu.org\/avr-libc\/user-manual\/group__avr__interrupts.html<\/a>)<\/p>\n<p>--<br \/>\nRemember:<\/p>\n<p>PCINT0..7 are asscociated with the 8 pins in PORTA and trigger the PCINT0_vect interrupt<br \/>\nPCINT8..15 are asscociated with the 8 pins in PORTB and trigger the PCINT1_vect interrupt<br \/>\nPCINT16..23 are asscociated with the 8 pins in PORTC and trigger the PCINT2_vect interrupt<br \/>\nPCINT24..31 are asscociated with the 8 pins in PORTD and trigger the PCINT3_vect interrupt <\/p>\n","protected":false},"excerpt":{"rendered":"<p>It&#8217;s this simple: &#8212; pinMode(5,INPUT); PCMSK2 |= (1<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7,8,11],"tags":[],"class_list":["post-151","post","type-post","status-publish","format-standard","hentry","category-electronics","category-measured","category-snippet"],"_links":{"self":[{"href":"http:\/\/mitat.tuu.fi\/index.php?rest_route=\/wp\/v2\/posts\/151","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=151"}],"version-history":[{"count":8,"href":"http:\/\/mitat.tuu.fi\/index.php?rest_route=\/wp\/v2\/posts\/151\/revisions"}],"predecessor-version":[{"id":164,"href":"http:\/\/mitat.tuu.fi\/index.php?rest_route=\/wp\/v2\/posts\/151\/revisions\/164"}],"wp:attachment":[{"href":"http:\/\/mitat.tuu.fi\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=151"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/mitat.tuu.fi\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=151"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/mitat.tuu.fi\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=151"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}