Menu

HPWM not working

Help
Zack
2012-05-14
2013-05-30
  • Zack

    Zack - 2012-05-14

    OK, it's probably me, but I can't get the Hardware PWM to work on a 16F690 Chip. I've tried several PICs. Here's my code…**

    ;Chip Settings
    #chip 16F690,4
    #config OSC=INTRC_OSC_CLKOUT

    ;Defines (Constants)
    #define PWM_Freq 1
    #define PWM_Duty 80

    Wait 1 s
    PWMOn
    Set PortB.6 On
    **

    The chip does function because PortB.6 does come on. What am I missing? Thanks!

     
  • Nobody/Anonymous

    The PWM pin isn't automatically set up as an output pin so you might need to add -

    dir PORTC.5 out
    
     
  • Nobody/Anonymous

    Missing is the actual HPWM command itself.  Check the Help file in the GCBasic folder, or online help from the web page.  There is a perfectly good example in the command reference.

     
  • Zack

    Zack - 2012-05-15

    Ah, thank you all. I needed to do both it seems. What threw me for a loop was I looked only at the PWMOn and PWMOff Help files. Here's what PWMOn States…

    Syntax:   
        PWMOn

    Explanation:
    This command will enable the output of the PWM module on the PIC chip.

    Example:
        'This program will enable a 76 Khz PWM signal, with a duty cycle
        'of 80%. It will emit the signal for 10 seconds, then stop.
        #define PWM_Freq 76    'Set frequency in KHz
        #define PWM_Duty 80    'Set duty cycle to 80 %
        PWMOn                'Turn on the PWM
        WAIT 10 s            'Wait 10 seconds
        PWMOff            'Turn off the PWM

    For more help, see:
    PWMOff

    No mention of HPWM there. Not very obvious (to me) only looking at that. Need to do more reading here on this end. Always learning.

    Thanks again!

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.