Page 1 of 1

PWM ChangePeriod Macro not working PIC18F14K50

Posted: Mon Jul 02, 2012 5:48 am
by dproffer
Hello,

Can someone advise me as to what I am doing incorrect in the attached Flowcode 5.2 code. The objective is to start the single PWM of the PIC18F14K50 at one PWM period, halt the PWM disable it, change the PWM period to a different value and restart the PWM.

The only PWM period setting that seems to take in Flowcode are those set using the Ext Properties of the PWM Panel, using the ChangePeriod() macro does not seem to work.

Also the displayed values for the PWM Period both in the Component Properties and Simulation display do show the same values and both values shown appear to not match the actual PWM period.

Thanks in advance,

Dave

Re: PWM ChangePeriod Macro not working PIC18F14K50

Posted: Mon Jul 02, 2012 9:41 am
by Benj
Hello Dave,

It looks like the original property settings are used when enabling the PWM channel. Is it possible for you to edit the settings without first disabling the PWM output as I believe this should work. If not then let me know and I will show you how to get around this bug.

Re: PWM ChangePeriod Macro not working PIC18F14K50

Posted: Mon Jul 02, 2012 10:10 am
by dazz
Hi Dave
not sure if this will work but ive slightly changed your flow code so rather than disable and reenable pwm it sets to 0

Regards
Dazz
simple_pwm.fcf
(11.5 KiB) Downloaded 408 times

Re: PWM ChangePeriod Macro not working PIC18F14K50

Posted: Tue Jul 03, 2012 7:34 am
by dproffer
Hi Dazz,


Thank you very much for your reply and code review! I did a quick test of what you uploaded and it appears to work, moving the PWM from 48kHz to 64kHz. My quick review of your code, and I will do a more in-depth in the morning is that you physically change the PWM period to zeros rather than my disable/enable step. Sure did not find any documentation from Matrix on this procedure, that's weak.

Thanks again,

Dave Proffer