MOD5213 16-bit PWM
Posted: Mon Jul 01, 2013 8:19 am
Hi,
My baseclock is 4 Mhz, I send an Interrupt Request using PIT 1 with a frequency of 400 Mhz. On each interrupt I change the duty of the PWM channels concatenated in 16-bit mode. The period is 2.5 ms(400Hz) and the duty is loaded on each interrupt from a 7200 elements array. The array contains a sinewave from -5184 to 5184 so the duty will vary from 0 to 10368 ticks of 4Mhz, so from 0 to period(2.5ms, 400Hz). I am modifiyng the frequency of the sinewave by jumping through the array with a different stepsize. My problem is that after I filter the signal with a low pass filter(cuttoff frequency of 100Hz) I get a nice sinusoidal shape but when I do an FFT of the signal I get a quite big second harmonic. I can not find an explanation for it. It is scaling with the frequency, so at 1 Hz is quite small, at 40Hz is quite big. If I increase the baseclock to 32Mhz the effect is scaling, so I get the same kind of second harmonic for 32Hz that I was getting for 4Hz with a baseclock of 4Mhz.
I hope somedy who is not a newbie like me will have an idea of why this is happening and what am I doing wrong.
Thanks a lot in advance.
My baseclock is 4 Mhz, I send an Interrupt Request using PIT 1 with a frequency of 400 Mhz. On each interrupt I change the duty of the PWM channels concatenated in 16-bit mode. The period is 2.5 ms(400Hz) and the duty is loaded on each interrupt from a 7200 elements array. The array contains a sinewave from -5184 to 5184 so the duty will vary from 0 to 10368 ticks of 4Mhz, so from 0 to period(2.5ms, 400Hz). I am modifiyng the frequency of the sinewave by jumping through the array with a different stepsize. My problem is that after I filter the signal with a low pass filter(cuttoff frequency of 100Hz) I get a nice sinusoidal shape but when I do an FFT of the signal I get a quite big second harmonic. I can not find an explanation for it. It is scaling with the frequency, so at 1 Hz is quite small, at 40Hz is quite big. If I increase the baseclock to 32Mhz the effect is scaling, so I get the same kind of second harmonic for 32Hz that I was getting for 4Hz with a baseclock of 4Mhz.
I hope somedy who is not a newbie like me will have an idea of why this is happening and what am I doing wrong.
Thanks a lot in advance.