Cypress Perform

Home > Design Support > Cypress Developer CommunityTM > Cypress Forums > PSoC® 3 > PWM Question

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



PWM Question
Moderator:
RKRM

Post Reply
Follow this topic



PWM Question

ImperfectSeven posted on 20 Jun 2012 1:34 PM PST
Top Contributor
77 Forum Posts

The data sheet on the PWM block says that the PWM_ReadCompare() can return either a uint8 or uint16. I can only get it to return a uint8 value, but I need it to returna uint16, how can I do this?

The PWM is set as a 16-bit UDB




Re: PWM Question

danaaknight posted on 20 Jun 2012 02:08 PM PST
Top Contributor
1773 Forum Posts

There is some verbiage in DS, under "Block Diagram and Configuration" that implies generated

API's return correct vaule. Same in descriptions of API call.

 

Quick test of compiler, return to an 8 bit variable, it should complain.

 

Regards, Dana.



Re: PWM Question

ImperfectSeven posted on 20 Jun 2012 02:34 PM PST
Top Contributor
77 Forum Posts

Ok so it was a stupid problem. I was reading the data to an 8 bit variable. I guess I just assumed it was a 16 bit.

Thanks for the help though, it may have taken me a bit to find that if i wasn't going to go change it to an 8-bit. However it never threw any errors reading to an 8 bit. Is that a problem?




Re: PWM Question

ImperfectSeven posted on 20 Jun 2012 02:57 PM PST
Top Contributor
77 Forum Posts

Is there any reason that changing the compare value and period value of a PWM block in code will cause the period to spike before reaching the desired value?



Re: PWM Question

danaaknight posted on 20 Jun 2012 03:59 PM PST
Top Contributor
1773 Forum Posts

Trust me, we still do not know why E = I x R, why that is physically true. And can be no other solution.

 

We do not know why the universe's rate of expansion is away from the mass that coeleseces it. We think it

is dark matter, a convienent term to describe a prtoblem we do not understand.

 

The compiler. if it is good, issues a warning, not an error. Sometimes the difference escapes me.

 

Change to reg writes, period and compare, the API descriptions do not show any side effects......? Not sure whats

actually happening.

 

Regards, Dana.

 



Re: PWM Question

hli posted on 21 Jun 2012 12:23 AM PST
Top Contributor
675 Forum Posts

Changing the compare value can immediately affect the state of the compare output (this is also stated in the data sheet), when the current PWM counter is above the new compare value (depending on the configuration). It might also be, in that case, that the comparision doesn't trigger, and the PWM counter runs for the full period, starts again and only then triggers the compare. CHanging the period value should not affect the output, as it is used only when the PWM counter reaches the terminal count.



Re: PWM Question

ImperfectSeven posted on 21 Jun 2012 06:22 AM PST
Top Contributor
77 Forum Posts

I figured it might have been something like if I increase the compare value mid run, since it updates immediately, it would just add on to my signal that was already high. I only see that spike when I increase so that makes sense. Would there be a way to make sure I only update my compare and period values at the end of a pulse. I guess I could use an interrupt and a flag

 



Re: PWM Question

ImperfectSeven posted on 21 Jun 2012 06:30 AM PST
Top Contributor
77 Forum Posts

Although I forgot I'm looking at the output through a NOT gate so that means my spike is really a long low time from the PWM block. But the problem remains the same, that is I'm resetting my compare and period values before they completed the previous iteration.






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