Author | Stef Mientki, Copyright (C) 2002-2006, all rights reserved. |
Adapted-by | Sebastien Lelong |
Compiler | >=2.4g |
this lib handles generic operation on PWM, whatever the channel number, etc... It's aimed to be used with pwm_{register} lib (eg. pwm_ccp1.jal, ...)
this is a heavy refactoring of the original pwm_hardware.jal Stef's lib
No dependency found
var volatile dword _pr2_1
Stores computed PR2 value when prescaler value is 1 Used to compute accurate frequency
var volatile dword _pr2_16
Stores computed PR2 value when prescaler value is 16 Used to compute accurate frequency
var volatile dword _pr2_4
Stores computed PR2 value when prescaler value is 4 Used to compute accurate frequency
pwm_max_resolution(byte in prescaler)
initializes the PWM for high resolution (10 bits) and starts the PWM While setting high resolution, prescaler can be used to adjust frequency. The parameter corresponds to the prescaler value, and can be either: * 1 : high frequency * 4 : medium frequency * 16: low frequency Not all frequencies are available, you'll need the datasheet to actually compute the computed frequency according to the clock speed. FYI, here's a table showing frequency for common clock speed: ||*prescaler/clock* || *4MHz* || *8MHz* || *10MHz* || *20MHz* || || 1 || 3.90kHz || 7.81kHz || 9.77kHz || 19.43kHz || || 4 || 976Hz || 1.95kHz || 2.44kHz || 4.88kHz || || 16 || 244Hz || 488Hz || 610Hz || 1.22kHz ||
pwm_set_frequency(dword in freq)
Initializes the PWM for accurate frequency and starts the PWM