Hi, I am working on ADC/TMR2 with PWM.
Ok.. I want to sample ADC at 8Khz and at the same time, generate PWM signal (which will pass through low pass filter of Fc of 4kHz) to display out the input signal. In another words, the ADC sampled values will become the PWM's duty cycle.
There are 2 methods i have in mind to do that. BTW, I am using PIC18F4620 at 40MHz.
First method:
Prescale = 1:1, Postscale = 1:10 & PR2 = 124 which will generate 8kHz accurately
Since PWM also use the same PR2 and Prescale values, the PWM frequency is 80kHz which means that for every duty cycle, there will be 10 pulses.
Second method:
Prescale = 1:16, Postscale = 1:1, PR2 = 77 which will generate 8.013kHz (which is not 8kHz).
The same values will also generate PWM frequency of 8.013kHz which will generate 1 pulse per duty cycle.
Hmm.. my question is, which method should I use..? The first one will generate a much smoother signal i think but after passing through the low pass filter (using opamp), the output won't be defferent much from the second mathod right..?
Any suggestion ..?
Ok.. I want to sample ADC at 8Khz and at the same time, generate PWM signal (which will pass through low pass filter of Fc of 4kHz) to display out the input signal. In another words, the ADC sampled values will become the PWM's duty cycle.
There are 2 methods i have in mind to do that. BTW, I am using PIC18F4620 at 40MHz.
First method:
Prescale = 1:1, Postscale = 1:10 & PR2 = 124 which will generate 8kHz accurately
Since PWM also use the same PR2 and Prescale values, the PWM frequency is 80kHz which means that for every duty cycle, there will be 10 pulses.
Second method:
Prescale = 1:16, Postscale = 1:1, PR2 = 77 which will generate 8.013kHz (which is not 8kHz).
The same values will also generate PWM frequency of 8.013kHz which will generate 1 pulse per duty cycle.
Hmm.. my question is, which method should I use..? The first one will generate a much smoother signal i think but after passing through the low pass filter (using opamp), the output won't be defferent much from the second mathod right..?
Any suggestion ..?