Menu

hardware pwm needs to be slower

Help
2009-04-22
2013-05-30
  • Nobody/Anonymous

    what changes do I need to make to the pwm.h file to get the hardware pwm to operate in hz instead of khz, ex: 10-20 hz

     
    • kent_twt4

      kent_twt4 - 2009-04-22

      Nothing, because the HPWM won't go that low in frequency.  Instead, one would use the Compare part of the CCPx module(i.e. the hardware PWM).

      Haven't used the comparator this way personally.  Set up Timer1 using an oscillator and prescaler that meets your needs per http://sourceforge.net/forum/forum.php?thread_id=2061852&forum_id=579125
      Presumably, the setting and clearing of the CCP1 pin is kept track of in the interrupt routine by writing to the CCP1CON register per the data sheet.  Also you would need to preload the TMR1H and TMR1L registers again to match your calculated frequency per the example.

       
    • Nobody/Anonymous

      can I run the soft pwm as slow as 10 hz and if so how?

       
    • Nobody/Anonymous

      I implemented a 30 Hz PWM using an interrrupt with the PIC12 series chip.  The advantage is other things can be done, instead of being blocked by a software PWM.  Getting the interrrupt to work properly on some PIC's has a couple issues, depending on the PIC, that are not handled by GCBasic.

      In your interrrupt routine, just toggle the output bit.

       
    • smartroad

      smartroad - 2009-04-26

      A little off topic (sorry) but to the person who implemented an interrupt PWM would you be willing to share the code. I really need a PWM routine that doesn't hold up the program, but can also run on a PIC without a hardware PWM

      Cheers!

       
    • Nobody/Anonymous

      See the contributors sections for an example interrupt based PWM

       

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.