Author | Stef Mientki, Copyright (C) 2002-2006, all rights reserved. |
Adapted-by | Sebastien Lelong, Rob Hamerling. |
Compiler | 2.4l |
Performs PWM operations on the CCP4 module. This file is automatically included by pwm_hardware.jal when the target PIC has a CCP4 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 byte _ccp4con_shadow = 0b0000_0000 -- shadow
var bit*2 _ccp4con_shadow_dc4b at _ccp4con_shadow : 4 -- 2 LSbits of duty cycle
var byte _ccpr4l_shadow = 0 -- 8 MSbits of duty cycle
var bit*4 _ccp4con_shadow_ccp4m at _ccp4con_shadow : 0 -- mode pattern
pwm4_set_dutycycle_lowres(byte in duty)
pwm4_off()
pwm4_on()
pwm4_set_percent_dutycycle(byte in percent)
pwm4_set_dutycycle(byte in duty)
pwm4_set_dutycycle_highres(word in duty)
var byte _ccp4con_shadow = 0b0000_0000 -- shadow
No documentation found
var bit*2 _ccp4con_shadow_dc4b at _ccp4con_shadow : 4 -- 2 LSbits of duty cycle
No documentation found
var byte _ccpr4l_shadow = 0 -- 8 MSbits of duty cycle
No documentation found
var bit*4 _ccp4con_shadow_ccp4m at _ccp4con_shadow : 0 -- mode pattern
No documentation found
pwm4_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!
pwm4_off()
PWM mode off retain duty cycle setting in shadow registers
pwm4_on()
PWM mode on Restore duty cycle from shadow registers Note: pin_CCP4_direction should be set to output!
pwm4_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_CCP4_direction should be set to output!
pwm4_set_dutycycle(byte in duty)
Set dutycycle for 10-bits resolution but allowing only 255 PWM steps. This procedure is equivalent to pwm4_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_CCP4_direction should be set to output!
pwm4_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_CCP4_direction should be set to output!