All right. Thank you very much.
Hi again,
I changed my sine entries to 72 samples from 0 to 350 in steps of 5. According to calculations above, TMR0 interrupt is generated every 141us (88*1.6us) so for 142 samples the frequency is 50 Hz (1/0.02 s). However, I am getting at the output 40 Hz sine wave! What I am doing wrong ? I used 72 samples instead of 142 also as it is one complete sine wave but I still get 40 Hz!
In the first post, the sine table had 19 entries from 270 - 90 in steps 10 and I was getting 50 Hz sine wave.
I am simulating my program on Proteus 7.5.
Thanks
What do you get with a timer reload value of 65,362?
Is your ADC=200?
How many entries do you have in the new table?
My ADC value is 200 (50 Hz) and my new table has 72 entries from 0 to 350 in steps of 5.
If you haven't changed the prescaler it should work according to your equation.timer0 reload value = FFFFh - 5Mhz / (36*(8/4)(200)) = 65535 - 347 = 65188
5MHz/(72*(8/4)*(200)) = 5MHz/28,800=173.6
65,535-173=65,362!
If you go by equation 3 in AN900 it would be around 65,447 for a reload value.
Bookmarks