{"id":1464,"date":"2023-09-18T19:04:04","date_gmt":"2023-09-18T18:04:04","guid":{"rendered":"https:\/\/ibex.tech\/embedded\/?p=1464"},"modified":"2023-09-20T10:38:22","modified_gmt":"2023-09-20T09:38:22","slug":"core-timer","status":"publish","type":"post","link":"https:\/\/ibex.tech\/embedded\/microchip\/pic32\/xc32\/timers-and-delays-xc32\/core-timer","title":{"rendered":"Core Timer"},"content":{"rendered":"\n<h4 class=\"wp-block-heading\">Using core timer<\/h4>\n\n\n\n<p>You can enable core timer functionality in MCC, which will generate code and give you these 2 functions:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\tCORETIMER_DelayMs(delay_ms);\t\t\/\/uint32_t\n\n\tCORETIMER_DelayUs(delay_us);\t\t\/\/uint32_t<\/code><\/pre>\n\n\n\n<h5 class=\"wp-block-heading\">Here&#8217;s an example of the code it generates for them<\/h5>\n\n\n\n<pre class=\"wp-block-code\"><code>void CORETIMER_DelayMs ( uint32_t delay_ms)\r\n{\r\n    uint32_t startCount, endCount;\r\n\r\n    \/* Calculate the end count for the given delay *\/\r\n    endCount=(CORE_TIMER_FREQUENCY \/ 1000U) * delay_ms;\r\n\r\n    startCount=_CP0_GET_COUNT();\r\n    while((_CP0_GET_COUNT() - startCount) &lt; endCount)\r\n    {\r\n        \/* Wait for compare match *\/\r\n    }\r\n}\r\n\r\nvoid CORETIMER_DelayUs ( uint32_t delay_us)\r\n{\r\n    uint32_t startCount, endCount;\r\n\r\n    \/* Calculate the end count for the given delay *\/\r\n    endCount=(CORE_TIMER_FREQUENCY \/ 1000000U) * delay_us;\r\n\r\n    startCount=_CP0_GET_COUNT();\r\n    while((_CP0_GET_COUNT() - startCount) &lt; endCount)\r\n    {\r\n        \/* Wait for compare match *\/\r\n    }\r\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Using core timer You can enable core timer functionality in MCC, which will generate code and give you these 2 functions: Here&#8217;s an example of the code it generates for them<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[111],"tags":[],"class_list":["post-1464","post","type-post","status-publish","format-standard","hentry","category-timers-and-delays-xc32"],"_links":{"self":[{"href":"https:\/\/ibex.tech\/embedded\/wp-json\/wp\/v2\/posts\/1464","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=1464"}],"version-history":[{"count":3,"href":"https:\/\/ibex.tech\/embedded\/wp-json\/wp\/v2\/posts\/1464\/revisions"}],"predecessor-version":[{"id":1469,"href":"https:\/\/ibex.tech\/embedded\/wp-json\/wp\/v2\/posts\/1464\/revisions\/1469"}],"wp:attachment":[{"href":"https:\/\/ibex.tech\/embedded\/wp-json\/wp\/v2\/media?parent=1464"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ibex.tech\/embedded\/wp-json\/wp\/v2\/categories?post=1464"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ibex.tech\/embedded\/wp-json\/wp\/v2\/tags?post=1464"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}