Cypress Perform

Home > Cypress Developer Community > Blog Posts > Dave's Corner: The Dave Van Ess Blog > Self Dithering PWM


Self Dithering PWM
Feb 19, 2013
By

 Our standard PWMs are made by continuously decrementing a register in a datapath (A0).  The compare register is used to detect when the count is below some compare value (D1) and set an output high.  For a 256 count PWM it can be implemented with a single instruction register of the datapath.  For a compare value of 50, the periodic output stream would be 206 low, followed by 50 high.  The frequency would by clock / 256.

 If the output frequency is too low and you can t increase the clock, then convert to a self dithering PWM.  If instead I change the datapath to continuously subtract 3 from the A0 and keep the same compare value of 50, the periodic output stream is:

69 low, 17 high, 68 low, 17 high, 69 low, 16 high

The output frequency is 3 * clock / 256.

 

Changing to subtracting 5 while keeping the same compare value, gives the periodic output stream:

42low, 10high, 41low, 10high, 41low, 10high, 41low, 10high, 41low, 10 high

The output frequency is 5 * clock / 256.

 

And so on.  If the value n is a relative prime to 256 (odd) and less than 128 is continuously subtracted from a register, the stream has n pulses and an output frequency of n * clock / 256.

 

This will also work from 16, 24, and 32 bit PWMs.  A 16bit PWM with a 24MHz clock has an output frequency of 366Hz.  Change it to a self dithering PWM with  n = 137 and you have an output frequency of 50.2kHz, but keeps a dithering resolution of 16 bits.

 

I never would have figured this out if datapaths didn't make it easy to build and try out.

See full blog


Comments:
hli wrote:
So basically you build a NCO (numerically controlled oscillator) and use it as PWM source? I think the main disadvantage is that the PWM frequency keeps changing all the time. It might be better, to get a higher PWM resolution, to change the compare value with each run. The existing PWM component can do this only with a fixed value (you choose one of 4 different schemes for changing the compare value, enhancing the resolution by 2 bits), but together with a LUT one can do this automatically.
Wed Feb 20 07:56:47 AM
You must be logged in to leave a comment. Login / Register
Like this item? Spread the news:  
Post this story on Digg.com Digg this   Share this on Facebook.com Facebook   Post this story on Digg.com LinkedIN   Add to Twitter Twitter  
ALL CONTENT AND MATERIALS ON THIS SITE ARE PROVIDED "AS IS". CYPRESS SEMICONDUCTOR AND ITS RESPECTIVE SUPPLIERS MAKE NO REPRESENTATIONS ABOUT THE SUITABILITY OF THESE MATERIALS FOR ANY PURPOSE AND DISCLAIM ALL WARRANTIES AND CONDITIONS WITH REGARD TO THESE MATERIALS, INCLUDING BUT NOT LIMITED TO, ALL IMPLIED WARRANTIES AND CONDITIONS OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT OF ANY THIRD PARTY INTELLECTUAL PROPERTY RIGHT. NO LICENSE, EITHER EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, IS GRANTED BY CYPRESS SEMICONDUCTOR. USE OF THE INFORMATION ON THIS SITE MAY REQUIRE A LICENSE FROM A THIRD PARTY, OR A LICENSE FROM CYPRESS SEMICONDUCTOR.

Content on this site may contain or be subject to specific guidelines or limitations on use. All postings and use of the content on this site are subject to the Terms and Conditions of the site; third parties using this content agree to abide by any limitations or guidelines and to comply with the Terms and Conditions of this site. Cypress Semiconductor and its suppliers reserve the right to make corrections, deletions, modifications, enhancements, improvements and other changes to the content and materials, its products, programs and services at any time or to move or discontinue any content, products, programs, or services without notice.

Spec No: None; Sunset Owner: DWV; Secondary Owner: JMAL; Sunset Date: 06/15/20