{"id":1198,"date":"2020-11-27T17:15:18","date_gmt":"2020-11-27T17:15:18","guid":{"rendered":"https:\/\/ibex.tech\/embedded\/?p=1198"},"modified":"2024-07-18T15:39:48","modified_gmt":"2024-07-18T14:39:48","slug":"adc-using-mcc","status":"publish","type":"post","link":"https:\/\/ibex.tech\/embedded\/microchip\/pic12\/xc8-compiler-pic12\/atod\/adc-using-mcc","title":{"rendered":"ADC (using MCC)"},"content":{"rendered":"\n<h4 class=\"wp-block-heading\">ADC Settings<\/h4>\n\n\n\n<h5 class=\"wp-block-heading\">FRC<\/h5>\n\n\n\n<p>Does your uC have a FRC to use as the clock source?  Nice and simple if it does. <\/p>\n\n\n\n<h5 class=\"wp-block-heading\">FVR<\/h5>\n\n\n\n<p>Does your uC have a FVR to use as the reference voltage?  Useful if you want an accurate reference, but not useful it you want your analog readings referenced to the uC power rail of course.<\/p>\n\n\n\n<p>You need to add it as a separate peripheral and select its multiplier to give the reference voltage you want <\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Using in your code<\/h4>\n\n\n\n<p><em>NOTE: May be &#8220;ADC_&#8221; or &#8220;ADC1_&#8221; depending on PIC device<\/em><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#include \"mcc_generated_files\/adc.h\"\n\n\/\/INITIALISE\n\t\/\/Start AtoD Conversion\r\n\tADC_SelectChannel(channel_AN1);\r\n\tADC_StartConversion();\n\n\n\/\/PROCESS ATOD\n\tuint16_t atod_result = 0;\n\n\t\/\/----- CHECK FOR ANALOG CONVERSION COMPLETE -----\r\n\t\/\/Exit if last conversion is not complete\r\n\tif (ADC_IsConversionDone())\r\n\t{\r\n\t\t\/\/Get result of last conversion\r\n\t\tatod_result = (uint16_t)ADC_GetConversionResult();\r\n\r\n\t\t\/\/Start next measurement\r\n\t\tADC_SelectChannel(channel_AN1);\r\n\t\tADC_StartConversion();\r\n\t}<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">An example function to handle AtoD measurements<\/h4>\n\n\n\n<p>See PIC18 page<\/p>\n","protected":false},"excerpt":{"rendered":"<p>ADC Settings FRC Does your uC have a FRC to use as the clock source? Nice and simple if it does. FVR Does your uC have a FVR to use as the reference voltage? Useful if you want an accurate reference, but not useful it you want your analog readings referenced to the uC power [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[128,129],"tags":[],"class_list":["post-1198","post","type-post","status-publish","format-standard","hentry","category-atod","category-pic12-peripherals"],"_links":{"self":[{"href":"https:\/\/ibex.tech\/embedded\/wp-json\/wp\/v2\/posts\/1198","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=1198"}],"version-history":[{"count":3,"href":"https:\/\/ibex.tech\/embedded\/wp-json\/wp\/v2\/posts\/1198\/revisions"}],"predecessor-version":[{"id":1556,"href":"https:\/\/ibex.tech\/embedded\/wp-json\/wp\/v2\/posts\/1198\/revisions\/1556"}],"wp:attachment":[{"href":"https:\/\/ibex.tech\/embedded\/wp-json\/wp\/v2\/media?parent=1198"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ibex.tech\/embedded\/wp-json\/wp\/v2\/categories?post=1198"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ibex.tech\/embedded\/wp-json\/wp\/v2\/tags?post=1198"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}