what about if you place a LOW PORTB.2 after the last HPWM line???
EDIT: i think i need to sleep.. See Alain solution...
what about if you place a LOW PORTB.2 after the last HPWM line???
EDIT: i think i need to sleep.. See Alain solution...
Last edited by mister_e; - 19th September 2005 at 15:48.
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
Hi, Peterdeco
Melabs says : to stop HPWM : HPWM 1, 0, xxxx ( duty cycle to zero ! )
That's all !!!
Now, if you can decently explain what PBP does when you ask for 0 Hz freq ...
you could also disable the CCP1 module ... but why ???
Alain
Last edited by Acetronics2; - 19th September 2005 at 15:33.
************************************************** ***********************
Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
************************************************** ***********************
IF there is the word "Problem" in your question ...
certainly the answer is " RTFM " or " RTFDataSheet " !!!
*****************************************
Hi,
Do you have to change the frequency to zero?
I wouldn't.
Anything below the minimum allowed frequency can cause strange results with the HPWM command.
I think if you simply issue the command at the frequency you've been using, but at a 0% duty cycle, it will be solid OFF. If you issue the command with a 100% duty cycle (255 if 8-bit) it will be solid ON.
Does anybody see any problem with this approach?
Regards,
---> picnaut
Can't say... i never use HPWM. Still prefer to write directly to the internal register. BUT, as Alain said and AS per the bookOriginally Posted by Picnaut
Originally Posted by TFM
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
If you want to turn OFF hardware PWM & have a solid logic output on the CCP pin, don't rely on using the HPWM command with a zero duty-cycle. Just use CCP1CON = 0 to disable the PWM module, then set/clear the pin as required.
After clearing CCP1CON, you can simply issue the HPWM command again, and PBP will automatically configure CCP1CON for PWM mode.
Some I/O-pins are multiplexed with peripherals. When these peripherals are enabled, they may "override" the TRIS bit for a pin. Even though the HPWM command does leave the TRIS bit set to output, and it leaves a zero in the output latch, if the PWM module is still enabled, and not outputting a PWM signal, you'll see a high impedance on the CCP output pin.
Hi, PicnautOriginally Posted by picnaut
this approach runs perfectly well, and it is recommended by Melabs itself ...as I use HPWM for R/C E-motors , I just clear CCP1CON when I'm not really really sure a glitch could give a false value to duty cycle. ( never saw it ...but i'm sure !!! )
Alain
************************************************** ***********************
Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
************************************************** ***********************
IF there is the word "Problem" in your question ...
certainly the answer is " RTFM " or " RTFDataSheet " !!!
*****************************************
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
Bookmarks