Menu

10bit PWM resolution

Help
2011-03-02
2013-05-30
  • Nobody/Anonymous

    Dear all great GC users.

    Does anyone know if and how to get 10bit resolution on the HPWM??

     
  • Nobody/Anonymous

    The predefined HPWM module is expressed as max duty cycle of 255 (i.e. 8 bits) as defined in the Help file.

    The hardware PWM module is easy to set it up manually, one just needs to follow the data sheet instructions.  Whether 10 bits can be accomplished, will depend on the clock source and desired PWM frequency, it's probably going to be less than 20khz.

    For a 16f877a the main steps to setting the HPWM would be:
    1.  Make the CCPx pin an output.
    2.  Set PR2, which is the TMR2 period value
    3.  Set the duty cycle with CCPRxL (8 msbs) and  CCPxCON<4:5> (2 lsbs)
    4.  Set TMR2 prescale/postscale and turn on TMR2 in the T2CON register
    5.  Set CCPxCON in PWM mode
    Congrats, you are now running the HPWM module!

    Kent

     
  • Nobody/Anonymous

    Thank you, could you please make an example in code?

     

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.