pwm_common

Hardware PWM control, common procedures

Author Stef Mientki, Copyright © 2002..2022, all rights reserved.
Adapted-by Sebastien Lelong, Rob Hamerling, Rob Jansen
Compiler 2.5r6

Description

This lib handles common operations on PWM, regardless the channel number.
It is used in combination with one or more pwm_ccp libraries
(eg. pwm_ccp1.jal, pwm_ccp2.jal, etc.). These libraries are included
automatically dependent of the configuration of the target PIC.
.
Oscillator refequency, PWM frequency and PWM resolution are a tighly coupled
set of parameters. Refer to the PWM section in the datasheets how these are related.


Notes

This is a heavy refactoring of the original pwm_hardware.jal (Stef's lib).
.
Changes dd October 2012:
- Added function pwm_get_resolution() returning the actual resolution in PWM steps.


--------------------------------------------------------------------------


Dependencies

No dependency found



Summary

Global variables/contants

Procedures

Functions


API details

Global variables/contants

Procedures

  • pwm_max_resolution(byte in prescaler)

    Set the prescaler value for Timer 2. If succesfull then Timer 2 will be 
    running. 
    
    

  • pwm_set_frequency(dword in freq)

    Purpose:   Set all(!) CCP modules for a specific PWM frequency.
    Arguments: Input:  dword - PWM frequency
    Output: none
    Notes:     - User may check bit TIMER2_TMR2ON to see if call successful
    TRUE:  Timer2 ON, PWM frequency set
    FALSE: Timer2 OFF, no PWM signal (frequency too high or too low
    with current Fosc)
    The minimum and maximum allowed PWM frequencies depend on the clock speed.
    When specifying a value beyond the limits PWM will not be enabled.
    .
    The chosen frequency may enforce a limit on the PWM resolution (number of steps).
    The application program should not specify a higher value for the duty cycle
    than this limit. When exceeding this limit the dutycycle will probably result
    in a 'weird' value.
    Use the procedures pwm?_set_dutycycle_percent() and pwm?_set_dutycycle_ratio()
    to set the desired duty cycle.
    
    

Functions


Related samples

No sample found