Can't get 100% duty cycle from PWM

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

I'm having trouble getting 100% duty cycle from the PWM. 0-99% works great but I always get a small negative pulse at 100%. I'm using the LHL_CLK to get a 1 kHz signal. I'm trying to get 100% by calling:

pwm_transitionToSubstituteValues(PWM1, 895, 895);

Is there anyway to get 100%?

0 Likes
1 Solution
asridharan
Employee
Employee
10 comments on KBA 5 comments on KBA First comment on KBA

You cannot have init value == toggle value. The HW uses a counter that controls the output level and it cannot be both high and low at the same time. If you want the output to be always on or always off, just drive the output using gpio_configurePin().

View solution in original post

2 Replies
asridharan
Employee
Employee
10 comments on KBA 5 comments on KBA First comment on KBA

You cannot have init value == toggle value. The HW uses a counter that controls the output level and it cannot be both high and low at the same time. If you want the output to be always on or always off, just drive the output using gpio_configurePin().

Anonymous
Not applicable

So I need to special case 100%? Seems rather clunky I'm not sure on the order of operations here. I've tried disabling the PWM at 100% and calling gpio_configurePin but this is unrealiable; the pin goes low sometimes even though I set it high. Then when transitioning back below 100%, the duty cycle sometimes gets inverted. Do I need to reset the PWM perhaps?

0 Likes