{"id":156,"date":"2012-05-29T07:55:10","date_gmt":"2012-05-29T07:55:10","guid":{"rendered":"http:\/\/www.electronic-products-development.com\/?p=156"},"modified":"2022-02-18T15:37:50","modified_gmt":"2022-02-18T15:37:50","slug":"pwm","status":"publish","type":"post","link":"https:\/\/ibex.tech\/embedded\/microchip\/pic24\/c30-compiler\/pwm","title":{"rendered":"PWM"},"content":{"rendered":"<h4>PIC24FJ256GB106<\/h4>\n<pre><code>\r\n\t\/\/----- SETUP TIMER 2 -----\r\n\t\/\/Used for: PWM\r\n\tT2CON = 0x0000;\t\t\t\/\/16 bit, 1:1 prescale\r\n\tTMR2 = 0;\r\n\tPR2 = 0x0fff;\t\t\t\/\/&lt;This sets the PWM resolution\r\n\r\n\t\/\/----- OC1 -----\r\n\t\/\/Used for: Intensity PWM\r\n\tOC1CON1 = 0x0000;\t\t\t\t\/\/Turn off Output Compare 1 Module\r\n\tOC1R = 0x0000;\t\t\t\t\t\/\/Initial PWM period\r\n\tOC1RS = 0x0000;\t\t\t\t\t\/\/Set PWM period\r\n\tOC1CON1 = 0x0007;\t\t\t\t\/\/Timer 2, no fault pin, centre aligned\r\n\tT2CONbits.TON = 1;\r\n\r\n\t\/\/OC1RS = 0x0000;\t\t\t\t\/\/&lt;&lt;&lt; Load this with the required PWM value, 0 - PR2\r\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>PIC24FJ256GB106 \/\/&#8212;&#8211; SETUP TIMER 2 &#8212;&#8211; \/\/Used for: PWM T2CON = 0x0000; \/\/16 bit, 1:1 prescale TMR2 = 0; PR2 = 0x0fff; \/\/&lt;This sets the PWM resolution \/\/&#8212;&#8211; OC1 &#8212;&#8211; \/\/Used for: Intensity PWM OC1CON1 = 0x0000; \/\/Turn off Output Compare 1 Module OC1R = 0x0000; \/\/Initial PWM period OC1RS = 0x0000; \/\/Set PWM period [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[17],"tags":[],"class_list":["post-156","post","type-post","status-publish","format-standard","hentry","category-c30-compiler"],"_links":{"self":[{"href":"https:\/\/ibex.tech\/embedded\/wp-json\/wp\/v2\/posts\/156","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=156"}],"version-history":[{"count":3,"href":"https:\/\/ibex.tech\/embedded\/wp-json\/wp\/v2\/posts\/156\/revisions"}],"predecessor-version":[{"id":540,"href":"https:\/\/ibex.tech\/embedded\/wp-json\/wp\/v2\/posts\/156\/revisions\/540"}],"wp:attachment":[{"href":"https:\/\/ibex.tech\/embedded\/wp-json\/wp\/v2\/media?parent=156"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ibex.tech\/embedded\/wp-json\/wp\/v2\/categories?post=156"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ibex.tech\/embedded\/wp-json\/wp\/v2\/tags?post=156"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}