Cypress Perform

Home > Design Support > Cypress Developer CommunityTM > Cypress Forums > PSoC® 5 > How to change PWM duty cycle in code...

Bookmark and Share
Cypress Developer CommunityTM
Forums | Videos | Blogs | Training | Rewards Program | Community Components



How to change PWM duty cycle in code...
Moderator:
ANCY

Post Reply
Follow this topic



How to change PWM duty cycle in code...

dtvonly posted on 01 Feb 2013 9:51 AM PST

1 Forum Post

Hi.  I looked at the API's explanation but don't really understand how to update my PWM duty cycle.  Please provide sample code for PSoC5 (fixed) 8/16 bit PWM duty cycle update (in code).  thanks.




Re: How to change PWM duty cycle in code...

danaaknight posted on 01 Feb 2013 10:38 AM PST
Top Contributor
1773 Forum Posts

The compare value register is what controls duty cycle.

 

PWM_WriteCompare() (for a one output PWM)

 

For 8 bit part it can range from 0 to 255, 0 produces a DC value of 0%, 255 100%,

and in between the DC ranges from 0+ - 100- %.

 

The PWM output is driven by the compare logic, as PWM counter is running, the compare

register values is compared to the period counter value, and depending on the compare type,

" less than", "less than or equal"..... it sets or resets the PWM output terminal, there by

controling the duty cycle.

 

Regards, Dana.






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: GRAA; Secondary Owner: RAIK; Sunset Date: 01/01/20