{"id":574,"date":"2014-09-30T20:22:48","date_gmt":"2014-09-30T20:22:48","guid":{"rendered":"https:\/\/ibex.tech\/embedded\/?p=574"},"modified":"2022-02-18T15:37:49","modified_gmt":"2022-02-18T15:37:49","slug":"non-irq-timer","status":"publish","type":"post","link":"https:\/\/ibex.tech\/embedded\/microchip\/pic32\/xc32-v2-old\/timers-and-delays\/non-irq-timer","title":{"rendered":"Non IRQ timer"},"content":{"rendered":"<h5>Using a Timer Without An IRQ<\/h5>\n<pre><code>\r\n\t\/\/Setup the timer\r\n\tOpenTimer2((T2_ON | T2_IDLE_CON | T2_GATE_OFF | T2_PS_1_1 | T2_32BIT_MODE_OFF | T2_SOURCE_INT), 100);\r\n\r\n\tINTClearFlag(INT_T2);\r\n\t\r\n\t\/\/Wait for timer to loop\r\n\twhile (!INTGetFlag(INT_T2))\r\n\t\t;\r\n\tINTClearFlag(INT_T2);\r\n<\/code><\/pre>\n<p>&nbsp;<\/p>\n<h5>Faster Bit Test Of IRQ Flag<\/h5>\n<p>The INTGetFlag() function is not particuarly fast. \u00a0If you want very tight timing then do a bit test instead:<\/p>\n<pre><code>\r\n\t\/\/Wait for timer to loop\r\n\t\/\/while (!INTGetFlag(INT_T2))\r\n\t\/\/\t;\r\n\t\/\/T2 is IFS0&lt;8&gt;\r\n\twhile (!(IFS0 &amp; 0x0100))\r\n\t\t;\r\n<\/code><\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Using a Timer Without An IRQ \/\/Setup the timer OpenTimer2((T2_ON | T2_IDLE_CON | T2_GATE_OFF | T2_PS_1_1 | T2_32BIT_MODE_OFF | T2_SOURCE_INT), 100); INTClearFlag(INT_T2); \/\/Wait for timer to loop while (!INTGetFlag(INT_T2)) ; INTClearFlag(INT_T2); &nbsp; Faster Bit Test Of IRQ Flag The INTGetFlag() function is not particuarly fast. \u00a0If you want very tight timing then do a bit [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[41],"tags":[],"class_list":["post-574","post","type-post","status-publish","format-standard","hentry","category-timers-and-delays"],"_links":{"self":[{"href":"https:\/\/ibex.tech\/embedded\/wp-json\/wp\/v2\/posts\/574","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=574"}],"version-history":[{"count":3,"href":"https:\/\/ibex.tech\/embedded\/wp-json\/wp\/v2\/posts\/574\/revisions"}],"predecessor-version":[{"id":577,"href":"https:\/\/ibex.tech\/embedded\/wp-json\/wp\/v2\/posts\/574\/revisions\/577"}],"wp:attachment":[{"href":"https:\/\/ibex.tech\/embedded\/wp-json\/wp\/v2\/media?parent=574"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ibex.tech\/embedded\/wp-json\/wp\/v2\/categories?post=574"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ibex.tech\/embedded\/wp-json\/wp\/v2\/tags?post=574"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}