Author | Stef Mientki, Copyright © 2002..2022, all rights reserved. |
Adapted-by | Sebastien Lelong, Rob Hamerling, Rob Jansen |
Compiler | 2.5r6 |
This lib handles common operations on PWM, regardless the channel number. It is used in combination with one or more pwm_ccplibraries (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.
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. --------------------------------------------------------------------------
No dependency found
var volatile word _pr2_shadow_plus1 = 256
Shadow of PR2 (value incremented by 1, i.e. value in range 1..256) Set to maximum value by default for maximum resolution.
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.
pwm_get_resolution() return word
Purpose: Obtain actuial number of PWM steps Arguments: (none) Returns: word = actual number of PWM steps