PWM in output. not working correct. (fixed (my fault))

Moderator: Benj

Post Reply
chad
Posts: 198
Joined: Sun Nov 04, 2018 7:13 pm
Has thanked: 27 times
Been thanked: 33 times
Contact:

PWM in output. not working correct. (fixed (my fault))

Post by chad »

The timing is off but I knew to expect that, but the SetDutyCycle(either) doesn't function correctly.

thanks,
Chad
PWM test.fcfx
(7.42 KiB) Downloaded 197 times
Last edited by chad on Mon Dec 03, 2018 7:05 pm, edited 1 time in total.

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times
Contact:

Re: PWM in output. not working correct.

Post by LeighM »

Hi Chad,
The SetDutyCycle() parameter is limited to 8 bits, so best to use the SetDuty10Bit() for ARM
SetDuty10Bit() actually takes a 16 bit parameter
(The naming is historic, as 32 bit processors are more recent)
Using the numbers in your attached program I would expect the duty ratio to be 128/6400 and 512/6400
Is that not what you get?
Leigh

chad
Posts: 198
Joined: Sun Nov 04, 2018 7:13 pm
Has thanked: 27 times
Been thanked: 33 times
Contact:

Re: PWM in output. not working correct.

Post by chad »

Ok, I get it now. I was trying to use a 16 bit number (in the 10 bit). I thought it was expecting a 16 bit number whole not the #/6400.

If I use 3200/6400 I get the expected 50% duty.. My goal was to make a ~10khz base freq then change the duty to modulate a led...

My error thanks!

chad

Post Reply