MOD5213 16-bit PWM

Discussion to talk about software related topics only.
Post Reply
e.dinu
Posts: 3
Joined: Thu Dec 06, 2012 9:49 am

MOD5213 16-bit PWM

Post by e.dinu »

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.
Attachments
main.cpp
(11.03 KiB) Downloaded 229 times
e.dinu
Posts: 3
Joined: Thu Dec 06, 2012 9:49 am

Re: MOD5213 16-bit PWM

Post by e.dinu »

Is the PWM timer capable of sending IRQ in 16-bit mode?
Post Reply