Menu

HPWM

Help
2015-08-07
2015-08-12
  • David Stephenson

    I'm looking at the help files for PWM using the CCP module.
    It is a bit confusing as to which of two methods to use and I am unsure whether DUTY is a percent or from 0 to 255.

    Do I define frequency and duty cycle using

    HPWM, channel,freq,duty (where duty runs from 0 to 255)
    Then can I use PWMon and PWMoff to toggle?

    or do I use

    #define PWM_freq
    #define PWM_duty (as a percent)
    

    the second method does not seem to offer a channel selection

     

    Last edit: David Stephenson 2015-08-07
  • David Stephenson

    I think I've got this sorted now. I used HPWM 1,200,128
    to get a 50% duty cycle on channel 1 at 200 kHz.
    Then PWMoff to stop.

     
  • Anobium

    Anobium - 2015-08-12

    Yes. That is the correct method. I am not sure what level of accurancy you need but on my scope here with 16MHz internal oscillator .... if you really needed 200 khz I needed to use HPWM 1,205,128 gives 50% duty cycle. HPWM 1,200,128 gave 191khz and 53% duty cycle.

     
  • Anobium

    Anobium - 2015-08-12

    And.... you could use the following to give you 199.5khz at 50%

    define PWM_freq 205

    define PWM_duty 50

    PWMOn

     

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.