Using v0.98.nn as the baseline I have updated CCP/PWM support to minimise the program size for CCP/PWM support. This is a PIC microcontroller change only. This does not apply to AVR microcontrollers.
As an example: Using the revised method for CCP3/PWM uses 21 words, then adding CCP4/PWM take 5 words + 5 words per channel on top of the first channel. This compares to the 368 words required using the existing method.
The revised method only supports CCP/PWM for fixed frequency and fixed duty across the 5 CCP/PWM channels. This is clearly a trade off for flexibility is memory… the trade off for fixed mode is that you cannot change frequency or duty 'on the fly'. But.... you can always use the flexible method of HPWM ( 3, 38, 127).
Anyone willing to test this revised library? You need to be using v0.98.nn.
'Code example
#define PWM_Freq 38 'Frequency of PWM in KHz
#define PWM_Duty 50 'Duty cycle of PWM (%)
' HPWM 3, 38, 127 'Existing method
CCP_PWM_1_On 'Start of revised methods
wait 10 ms
CCP_PWM_2_On
wait 10 ms
CCP_PWM_3_On
wait 10 ms
CCP_PWM_4_On
wait 10 ms
CCP_PWM_5_On
wait 10 ms
CCP_PWM_1_Off
wait 10 ms
CCP_PWM_2_Off
wait 10 ms
CCP_PWM_3_Off
wait 10 ms
CCP_PWM_4_Off
wait 10 ms
CCP_PWM_5_Off
wait 10 ms
Do
Loop
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Using v0.98.nn as the baseline I have updated CCP/PWM support to minimise the program size for CCP/PWM support. This is a PIC microcontroller change only. This does not apply to AVR microcontrollers.
As an example: Using the revised method for CCP3/PWM uses 21 words, then adding CCP4/PWM take 5 words + 5 words per channel on top of the first channel. This compares to the 368 words required using the existing method.
The revised method only supports CCP/PWM for fixed frequency and fixed duty across the 5 CCP/PWM channels. This is clearly a trade off for flexibility is memory… the trade off for fixed mode is that you cannot change frequency or duty 'on the fly'. But.... you can always use the flexible method of HPWM ( 3, 38, 127).
Anyone willing to test this revised library? You need to be using v0.98.nn.