Author | Stef Mientki, Copyright (C) 2002-2006, all rights reserved. |
Adapted-by | Sebastien Lelong, Rob Hamerling. |
Compiler | 2.4l |
Performs PWM operations on the CCP1 module. This file is automatically included by pwm_hardware.jal when the target PIC has a CCP1 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*4 _ccp1con_shadow_ccp1m at _ccp1con_shadow : 0
var byte _ccpr1l_shadow = 0
var bit*2 _ccp1con_shadow_dc1b at _ccp1con_shadow : 4
var byte _ccp1con_shadow = 0b0000_0000
pwm1_set_percent_dutycycle(byte in percent)
pwm1_on()
pwm1_off()
pwm1_set_dutycycle_lowres(byte in duty)
pwm1_set_dutycycle_highres(word in duty)
pwm1_set_dutycycle(byte in duty)
var bit*4 _ccp1con_shadow_ccp1m at _ccp1con_shadow : 0
mode pattern
var byte _ccpr1l_shadow = 0
8 MSbits of duty cycle
var bit*2 _ccp1con_shadow_dc1b at _ccp1con_shadow : 4
2 LSbits of duty cycle
var byte _ccp1con_shadow = 0b0000_0000
shadow
pwm1_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_CCP1_direction should be set to output!
pwm1_on()
PWM mode on Restore duty cycle from shadow registers Note: pin_CCP1_direction should be set to output!
pwm1_off()
PWM mode off retain duty cycle setting in shadow registers
pwm1_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!
pwm1_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_CCP1_direction should be set to output!
pwm1_set_dutycycle(byte in duty)
Set dutycycle for 10-bits resolution but allowing only 255 PWM steps. This procedure is equivalent to pwm1_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_CCP1_direction should be set to output!