Thank you Everybody. Bruce, I did the CCP1CON = 0 thing in place of my "zero frequency" command and it works like a charm.
Thank you Everybody. Bruce, I did the CCP1CON = 0 thing in place of my "zero frequency" command and it works like a charm.
Bruce's approach sounds better to me.
It probably uses less code than issuing the HPWM command again also.
Cheers.
---> picnaut
Here's a simple test to show the effects of disabling the hardware PWM module, or using a zero duty-cycle or freq with HPWM.
Hook an LED up to your CCP out pin.
CCP output pin ---|>|----/\/\/\/\----GND
On a 16F876A, the LED never toggles with HPWM 1,0,0. It does once the hardware PWM module is disabled with CCP1CON = 0. I'm curious if it works either way on other PIC's.Code:SYMBOL PIN = PORTC.2 ' Define whatever pin on your PIC is CCP out here HPWM 1,127,2000 PAUSE 8000 CCP1CON = 0 ' Test once with this, then comment it out 'HPWM 1,0,0 ' Now test with this un-commented WAITUP: HIGH PIN PAUSE 500 LOW PIN PAUSE 500 GOTO WAITUP
Hi Bruce,
Try it again, but this time leave the frequency at 2000 (only the duty cycle is 0). See if it toggles then.
I'm curious (and no where near a PIC right now).
Cheers!
---> picnaut
Hi Bruce,
Also, maybe put a 500ms delay right after the "WAITUP" label. Otherwise, if PIN goes low, it will immediately go high again and you won't catch it.
Cheers!
---> picnaut
Works the same until CCP1CON = 0.
Another delay isn't really necessary since it never toggles the LED to begin with.
I find that setting duty to 0 allows the pin to float
and that can cause a fet to turn on.
I add a weak pull down resistor to the pin used
or set the output to low when duty=0
Bookmarks