{"id":622,"date":"2015-05-07T17:03:26","date_gmt":"2015-05-07T17:03:26","guid":{"rendered":"https:\/\/ibex.tech\/embedded\/?p=622"},"modified":"2022-02-18T15:37:49","modified_gmt":"2022-02-18T15:37:49","slug":"pwm-output","status":"publish","type":"post","link":"https:\/\/ibex.tech\/embedded\/microchip\/pic32\/xc32-v2-old\/output-compare\/pwm-output","title":{"rendered":"PWM Output"},"content":{"rendered":"<h4>\nSimple PWM Ouptut<br \/>\n<\/h4>\n<p>\n\u200bSetup timer 2 or 3 to be the timebase. &nbsp;The PR value used for the timer will be the total PWM period:\n<\/p>\n<pre>\r\n<code>\r\n\t\/\/----- SETUP TIMER 2 -----\r\n\t\/\/Used for: PWM\r\n\tOpenTimer2((T2_ON | T2_IDLE_CON | T2_GATE_OFF | T2_PS_1_1 | T2_SOURCE_INT), 5000);\r\n<\/code><\/pre>\n<p>\nTurn on the PWM output. &nbsp;The OCxRS value will be the duty cycle of the PWM signal (e.g. if set to 50% of the timers&nbsp;PR value&nbsp;you&#39;ll get a 50:50 PWM signal):\n<\/p>\n<pre>\r\n<code>\r\n\t\/\/OC2CON\r\n\t\/\/Used for: Piezo\r\n\tOpenOC2((OC_ON | OC_TIMER2_SRC | OC_PWM_FAULT_PIN_DISABLE), 2500, 0);\t\t\/\/ Config, OCxRS(the PWM duity cycle to use), OCxR\r\n<\/code><\/pre>\n<p>\n(Note that the OCxR value gets loaded from the OCxRS when the timer next rolls over).\n<\/p>\n<p>\nSet a new PWM duty cycle:\n<\/p>\n<pre>\r\n<code>\r\n\tOC2RS = 1250;\r\n<\/code><\/pre>\n<p>\n&nbsp;\n<\/p>\n<p>\n&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Simple PWM Ouptut \u200bSetup timer 2 or 3 to be the timebase. &nbsp;The PR value used for the timer will be the total PWM period: \/\/&#8212;&#8211; SETUP TIMER 2 &#8212;&#8211; \/\/Used for: PWM OpenTimer2((T2_ON | T2_IDLE_CON | T2_GATE_OFF | T2_PS_1_1 | T2_SOURCE_INT), 5000); Turn on the PWM output. &nbsp;The OCxRS value will be the duty [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[60],"tags":[],"class_list":["post-622","post","type-post","status-publish","format-standard","hentry","category-output-compare"],"_links":{"self":[{"href":"https:\/\/ibex.tech\/embedded\/wp-json\/wp\/v2\/posts\/622","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=622"}],"version-history":[{"count":2,"href":"https:\/\/ibex.tech\/embedded\/wp-json\/wp\/v2\/posts\/622\/revisions"}],"predecessor-version":[{"id":624,"href":"https:\/\/ibex.tech\/embedded\/wp-json\/wp\/v2\/posts\/622\/revisions\/624"}],"wp:attachment":[{"href":"https:\/\/ibex.tech\/embedded\/wp-json\/wp\/v2\/media?parent=622"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ibex.tech\/embedded\/wp-json\/wp\/v2\/categories?post=622"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ibex.tech\/embedded\/wp-json\/wp\/v2\/tags?post=622"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}