I can set period and duty on PWM 6 and PWM 7, independent from a main clock, but for PWM 1 trough 5 it does not work. If I have main clock at 8 MHz and set:
HPWM 1, 10, PWM_Bright_B - period will be close to 10 KHz (9.921 KHz)
If main clock set to 16 MHz - period jumps to doble, close to 20 KHz.
Is there any possibility to set timer and period independent from main clock?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I found and fixed the problem. In pwm.h there is a line:
define PWM_Freq 38 'Frequency of PWM in KHz
This makes period dependent on clock frequency. If this line is commented out, application program can specify period and it will be clock independent.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
OK. If that works for you. You should read the Help to understand what you are updating. Seems odd to me but if it works - great.
Advice. Do not change the installed .h files. Simply define your user specific constants in the user program. This approach minimises the impact of upgrading your installation
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I can set period and duty on PWM 6 and PWM 7, independent from a main clock, but for PWM 1 trough 5 it does not work. If I have main clock at 8 MHz and set:
HPWM 1, 10, PWM_Bright_B - period will be close to 10 KHz (9.921 KHz)
If main clock set to 16 MHz - period jumps to doble, close to 20 KHz.
Is there any possibility to set timer and period independent from main clock?
That does not sound right.
Are you saying that things work correctly for 6 and 7 and not 1 through 5? What is the version of the pwm.h or date of pwm.h?
pwm.h as of 24th of October
PWM 6 and 7 are PWM channels.
PWM 1 thru 5 are CCP/PWM channels.
Recommend a scan of the datasheet to understand the differences but essentially the timers for 1 thru 5 cannot be set as you desire.
As with all that I write... I am sure there are ways - but, I do not know (at the moment) a method to make this happen for you. Ready to learn!!
Ok, I can not change the timer and it is timer 2 by default, but if I set 10 KHz period - it should be 10 Khz for all main clock frequencies!
Somehow it works for 6 and 7, but not for 1 trough 5.
I found and fixed the problem. In pwm.h there is a line:
define PWM_Freq 38 'Frequency of PWM in KHz
This makes period dependent on clock frequency. If this line is commented out, application program can specify period and it will be clock independent.
OK. If that works for you. You should read the Help to understand what you are updating. Seems odd to me but if it works - great.
Advice. Do not change the installed .h files. Simply define your user specific constants in the user program. This approach minimises the impact of upgrading your installation