Page 1 of 1

PWM behaviour for 0% and 100%

Posted: Thu May 19, 2016 1:34 pm
by sdalu
I'm wondering what should be the PWM driver behaviour for 0% and 100% duty cycle.
If enabled, should we have a channel notification for every cycle, or no notification at all?

Thanks

Re: PWM behaviour for 0% and 100%

Posted: Thu May 19, 2016 2:49 pm
by Giovanni
It should give a channel notification because the channel is active.

Giovanni

Re: PWM behaviour for 0% and 100%

Posted: Sun Jun 12, 2016 11:10 pm
by Angel
Hello, I got the PWM channel working on three channels in a 103RB, but when I use this:

pwmEnableChannel(&PWMD1, 0, PWM_PERCENTAGE_TO_WIDTH(&PWMD1, 7500));

for percentage values of 12% (value set at 1200) or below this value, the duty cycle rises up to 60% an continue increasing as I set lower percentage values. in this way, the duty cycle does not get zero or even get close of it with a 0 percentage value.

I tried to get more information by comparing the program with the sample programs, but actually those does not cover such low percentage values.
also I cheked that the higher the PWM frequency, the bigger is this behavior,

I appreciate you could give me a solution or opinion about it.

Re: PWM behaviour for 0% and 100%

Posted: Mon Jun 13, 2016 8:04 am
by Giovanni
Hi,

You should post your PWM settings.

Giovanni

Re: PWM behaviour for 0% and 100%

Posted: Mon Jun 13, 2016 3:39 pm
by Angel
thank you for answering, here they are:

static PWMConfig pwmcfg = {
200000,
10,
pwmpcb,
{
{PWM_OUTPUT_ACTIVE_HIGH, pwmc1cb},
{PWM_OUTPUT_ACTIVE_HIGH, pwmc1cb1},
{PWM_OUTPUT_ACTIVE_HIGH, pwmc1cb2},
{PWM_OUTPUT_DISABLED, NULL}
},
0,
0,
};

I tried to solve it by modifying the first two parameters (20000, 1)but then the PWM did not work at all

Re: PWM behaviour for 0% and 100%

Posted: Mon Jun 13, 2016 4:20 pm
by Giovanni
That "10" means that your PWM has only 10 discrete duty cycle settings because the counter goes from 0 to 9 then it is reset.

You need to define the input clock and the period value accordingly to your requirements.

Giovanni

Re: PWM behaviour for 0% and 100%

Posted: Mon Jun 13, 2016 5:37 pm
by Angel
I tried some usefull frequency combinations for my application, in some I got this effect reduced, but none of them achieved a zero duty cycle; anyway, I think I will cut off this last sampling segment by software and set the zero value in the output

thank you very much, the best

Re: PWM behaviour for 0% and 100%

Posted: Mon Jun 13, 2016 5:42 pm
by Giovanni
Try setting the duty cycle at 0 without using the macro, do you get a continuous level? 0% and 100% should have no fronts.

Giovanni

Re: PWM behaviour for 0% and 100%

Posted: Mon Jun 13, 2016 6:51 pm
by Angel
yes, I will set to zero that part in that way, thank you for your suggestion.

also yes, by using the macro in some setting configurations, the level of this effect is continuous , overall, in the low frequency configurations