<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	
	>
<channel>
	<title>
	Comments on: Generating an Arduino 16-bit PWM	</title>
	<atom:link href="https://www.teachmemicro.com/generate-arduino-16-bit-pwm/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.teachmemicro.com/generate-arduino-16-bit-pwm/</link>
	<description>Microcontroller Tutorials and Resources</description>
	<lastBuildDate>Tue, 10 Oct 2023 23:41:17 +0000</lastBuildDate>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.1.3</generator>
	<item>
		<title>
		By: Donald Wright		</title>
		<link>https://www.teachmemicro.com/generate-arduino-16-bit-pwm/#comment-264315</link>

		<dc:creator><![CDATA[Donald Wright]]></dc:creator>
		<pubDate>Wed, 29 Dec 2021 03:49:06 +0000</pubDate>
		<guid isPermaLink="false">https://www.teachmemicro.com/?p=3990#comment-264315</guid>

					<description><![CDATA[This was a very interesting blog. It help me a lot to understand on how the µC works. 

I have made a few modifications to be use on the MEGA 2560 board and that might help other people.
The modifications also consisted on fixing the frequency to 20 kHz outputs on OC1A and OC1B. To arrive at this, ICR1 = 0x190 and not 0xFFFF. A few tests later and reading on an oscilloscope confirmed that accuracy of the frequency and duty cycle of the PWM outpout on header pins 12 and 11 are accurate. The big inconvenient is that the PWM granularity has a maximum of 400 (0x190 = 110010000) steps, which gives an almost full 9-bit resolutions, where 9 bit resolution is 0x1ff. The next project will be to use the 10 bit resolutions (mode operation 4 of table 13-4 above from other of blog)

void setup() {
  Serial.begin(9600);
  pinMode(11, OUTPUT);
  pinMode(12, OUTPUT);
  TCCR1A = (TCCR1A &#038; B00001100) &#124; B10100010;   //Phase and frequency correct, Non-inverting mode, TOP defined by ICR1
  TCCR1B = (TCCR1B &#038; B11100000) &#124; B00010001;    //Prescale set to 1 or none
  ICR1 = 0x190; // Set frequency at 20 kHz, 0x190 = d400 (0xFFFF; // 65535) 
}
 
void loop() {

// 0x190 = 400 decimal = maximum value for duty cycle = 100% duty cycle. Setting OCR1A and OCR1B above this ICR1 value of 0x190 will not generate any PWM
//pwm_16(0xc8); // 0xc8 = 200 dec = 50% Duty Cycle
//pwm_16(0x02); // 0x02 = 2 dec = 0.5% Duty Cycle
pwm_16_1A (0xAE); // 0xAE = 174 déc = 43.5% Duty Cycle
pwm_16_1B (0x10C); // 0x10C = 268 = Duty cycle 68%
}
 
void pwm_16_1A(int val){
  OCR1A = val;    //Set PWM duty of TIMER 1, channel A
}

void pwm_16_1B(int val){
  OCR1B = val;     //Set PWM duty of TIMER 1, channel B
}]]></description>
			<content:encoded><![CDATA[<p>This was a very interesting blog. It help me a lot to understand on how the µC works. </p>
<p>I have made a few modifications to be use on the MEGA 2560 board and that might help other people.<br />
The modifications also consisted on fixing the frequency to 20 kHz outputs on OC1A and OC1B. To arrive at this, ICR1 = 0x190 and not 0xFFFF. A few tests later and reading on an oscilloscope confirmed that accuracy of the frequency and duty cycle of the PWM outpout on header pins 12 and 11 are accurate. The big inconvenient is that the PWM granularity has a maximum of 400 (0x190 = 110010000) steps, which gives an almost full 9-bit resolutions, where 9 bit resolution is 0x1ff. The next project will be to use the 10 bit resolutions (mode operation 4 of table 13-4 above from other of blog)</p>
<p>void setup() {<br />
  Serial.begin(9600);<br />
  pinMode(11, OUTPUT);<br />
  pinMode(12, OUTPUT);<br />
  TCCR1A = (TCCR1A &amp; B00001100) | B10100010;   //Phase and frequency correct, Non-inverting mode, TOP defined by ICR1<br />
  TCCR1B = (TCCR1B &amp; B11100000) | B00010001;    //Prescale set to 1 or none<br />
  ICR1 = 0x190; // Set frequency at 20 kHz, 0x190 = d400 (0xFFFF; // 65535)<br />
}</p>
<p>void loop() {</p>
<p>// 0x190 = 400 decimal = maximum value for duty cycle = 100% duty cycle. Setting OCR1A and OCR1B above this ICR1 value of 0x190 will not generate any PWM<br />
//pwm_16(0xc8); // 0xc8 = 200 dec = 50% Duty Cycle<br />
//pwm_16(0x02); // 0x02 = 2 dec = 0.5% Duty Cycle<br />
pwm_16_1A (0xAE); // 0xAE = 174 déc = 43.5% Duty Cycle<br />
pwm_16_1B (0x10C); // 0x10C = 268 = Duty cycle 68%<br />
}</p>
<p>void pwm_16_1A(int val){<br />
  OCR1A = val;    //Set PWM duty of TIMER 1, channel A<br />
}</p>
<p>void pwm_16_1B(int val){<br />
  OCR1B = val;     //Set PWM duty of TIMER 1, channel B<br />
}</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Pranay Jagtap		</title>
		<link>https://www.teachmemicro.com/generate-arduino-16-bit-pwm/#comment-92883</link>

		<dc:creator><![CDATA[Pranay Jagtap]]></dc:creator>
		<pubDate>Sat, 12 Sep 2020 10:25:38 +0000</pubDate>
		<guid isPermaLink="false">https://www.teachmemicro.com/?p=3990#comment-92883</guid>

					<description><![CDATA[Do you have any YouTube channel? If not then you must create one!]]></description>
			<content:encoded><![CDATA[<p>Do you have any YouTube channel? If not then you must create one!</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Jeff		</title>
		<link>https://www.teachmemicro.com/generate-arduino-16-bit-pwm/#comment-64001</link>

		<dc:creator><![CDATA[Jeff]]></dc:creator>
		<pubDate>Fri, 28 Feb 2020 18:43:51 +0000</pubDate>
		<guid isPermaLink="false">https://www.teachmemicro.com/?p=3990#comment-64001</guid>

					<description><![CDATA[Wow.. seriously.. super explication. I haven&#039;t catch all, but for sure this page is saved and you are fully bookmarked. Thanks]]></description>
			<content:encoded><![CDATA[<p>Wow.. seriously.. super explication. I haven't catch all, but for sure this page is saved and you are fully bookmarked. Thanks</p>
]]></content:encoded>
		
			</item>
	</channel>
</rss>

<!--
Performance optimized by W3 Total Cache. Learn more: https://www.boldgrid.com/w3-total-cache/?utm_source=w3tc&utm_medium=footer_comment&utm_campaign=free_plugin

Page Caching using Disk: Enhanced 

Served from: www.teachmemicro.com @ 2026-10-27 22:15:34 by W3 Total Cache
-->