Author | Stef Mientki, Copyright (C) 2002-2006, all rights reserved. |
Adapted-by | Sebastien Lelong, Rob Hamerling. |
Compiler | 2.4l |
Performs PWM operations on the CCP3 module. This file is automatically included by pwm_hardware.jal when the target PIC has a CCP3 module.
1. This is a heavy refactoring of the original pwm_hardware.jal (Stef's lib) 2. Partly rewritten for JalV2 version 2.4l and Jallib revision 1171. Reduced memory occupation. Added procedure for lowres PWM.
No dependency found
var bit*2 _ccp3con_shadow_dc3b at _ccp3con_shadow : 4
var bit*4 _ccp3con_shadow_ccp3m at _ccp3con_shadow : 0
var byte _ccp3con_shadow = 0b0000_0000
var byte _ccpr3l_shadow = 0
pwm3_on()
pwm3_set_dutycycle(byte in duty)
pwm3_set_dutycycle_lowres(byte in duty)
pwm3_set_dutycycle_highres(word in duty)
pwm3_set_percent_dutycycle(byte in percent)
pwm3_off()
var bit*2 _ccp3con_shadow_dc3b at _ccp3con_shadow : 4
2 LSbits of duty cycle
var bit*4 _ccp3con_shadow_ccp3m at _ccp3con_shadow : 0
mode pattern
var byte _ccp3con_shadow = 0b0000_0000
shadow
var byte _ccpr3l_shadow = 0
8 MSbits of duty cycle
pwm3_on()
PWM mode on Restore duty cycle from shadow registers Note: pin_CCP3_direction should be set to output!
pwm3_set_dutycycle(byte in duty)
Set dutycycle for 10-bits resolution but allowing only 255 PWM steps. This procedure is equivalent to pwm3_set_dutycycle_highres(), but the low order 2 bits of the 10-bits duty cycle are set to 0. This means that only every 4th of the available 1023 steps can be selected and consequently max 255 PWM steps are available. This procedure is for user convenience, allowing to specify an 8 bits value for the duty cycle is for many applications satisfactory. Calling this procedure will also activate PWM. Note: pin_CCP3_direction should be set to output!
pwm3_set_dutycycle_lowres(byte in duty)
Set dutycycle with 8-bits resolution allowing 255 PWM steps. The 'duty' argument is the 8-bits absolute value for the duty cycle: * duty<1:0> are the 2 LSbits * duty<7:2> are the 6 MSbits Allowed range: 0..255 Beware that steps 256..1023 are not available. In other words the available PWM range is 25% of the highres procedure. This procedure is particularly suitable with higher frequencies whereby the PWM resolution is limited to 256 steps or less!
pwm3_set_dutycycle_highres(word in duty)
Set dutycycle with 10-bits resolution, allowing 1024 PWM steps. The 'duty' argument is a (max) 10-bits absolute value for the duty cycle: * duty<1:0> are the 2 LSbits * duty<9:2> are the 8 MSbits Allowed range: 0..1023 Note: pin_CCP3_direction should be set to output!
pwm3_set_percent_dutycycle(byte in percent)
Set a percentage duty cycle, allowing max 100 PWM steps. Allowed range: 0..100 The duty cycle will be set to the specified percentage of the maximum for the current PWM frequency. Note: The number of available PWM steps can be lower than 100 with (very) high PWM frequencies. Note: pin_CCP3_direction should be set to output!
pwm3_off()
PWM mode off retain duty cycle setting in shadow registers