Redefining HPWM as output


Closed Thread
Results 1 to 14 of 14

Hybrid View

  1. #1


    Did you find this post helpful? Yes | No

    Default

    Thank you Everybody. Bruce, I did the CCP1CON = 0 thing in place of my "zero frequency" command and it works like a charm.

  2. #2


    Did you find this post helpful? Yes | No

    Talking

    Bruce's approach sounds better to me.
    It probably uses less code than issuing the HPWM command again also.

    Cheers.
    ---> picnaut

  3. #3
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    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
    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
    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.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  4. #4


    Did you find this post helpful? Yes | No

    Default

    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

  5. #5


    Did you find this post helpful? Yes | No

    Default

    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

  6. #6
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    Works the same until CCP1CON = 0.

    Another delay isn't really necessary since it never toggles the LED to begin with.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  7. #7
    Stump's Avatar
    Stump Guest


    Did you find this post helpful? Yes | No

    Default hpwm

    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

Similar Threads

  1. Bit Banging input to output on PIC16F876A
    By Bronurstomp in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 26th June 2008, 19:50
  2. Multiple HPWM question
    By Johan in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 17th October 2007, 13:00
  3. Serious Serial Situation Setbacks...
    By Dansdog in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 7th February 2007, 03:46
  4. sound command & music
    By trying in forum mel PIC BASIC Pro
    Replies: 14
    Last Post: - 26th May 2006, 14:14
  5. 3 HPWM channels
    By docwisdom in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 4th April 2006, 02:43

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts