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
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Dear all great GC users.
Does anyone know if and how to get 10bit resolution on the HPWM??
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
Thank you, could you please make an example in code?