AnsweredAssumed Answered

Sin wave generation problem using TIM1 & PWM

Question asked by davidson.ralph on Mar 2, 2016
Latest reply on Mar 5, 2016 by davidson.ralph
I am a student from University of Cairo Iam trying to  generate a 50 hz sinusoidal using my stm32f4 discovery board. I am running my timer in 10khz (switching freq = 10khz) and I am using a lookup table (generated from excel) in order to get new compare values for my pwm => lookup table of 200 points. The discovery board and my timer 1 are running on 168Mhz. My timer is in up-down count mode with period = 8400 - 1 . The new compare value is obtained on overflow and updated. But its effect takes place on next underflow because of shadowing . I am able to get 50hz but it is not a pure 50hz. It has other frequency components which makes it moving around as can be seen in attachment. I have an RC filter placed on channel 1 of timer 1 on PE9 to make the sin wave visible. 

What is the reason of not getting a pure 50hz although my sin table is pure 50hz? I attach my code for you to take a look please.

Thank you for your help!