// Setup peripherals
setup_adc_ports(AN0_TO_AN4);
setup_adc(ADC_CLOCK_DIV_32); // ADC clock must be set such to ensure TAD=1.6us minimum (TOSC = 0.05us @ 20MHz)
//---------------------------------------------------------------------------------------------------------------
// MAIN routine
//---------------------------------------------------------------------------------------------------------------
pwm_duty_cycle=20; // trying to set the duty cycle to control actuators
led_off_led0();
}
It is a PIC18F4620 @32MHz, TImer3 is 16bit
so after my calculation
it overflows every 65.5ms
(4/32E6 * 65535 *8=65.5ms)
and if I want a frequency of 20kHz (50us period) of my PWM
.....(4/32E6 * x *8=50us) => x=50 counts in timer3
my problem is that I can not change the fraction of high to low states of the pwm...
Are my calculations correct? Is it very unelegant to do PWM this way/are there mistakes?
Did I enable the Interrupts correctly...?
I'm stuck on this topic for quite a while now...
Thank you very much!
(Youre saving my life)
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum