I am seeing fluctuation in frequency while generating PWM using k20d72m board, how can I resolve it .
I am attaching my code below
is there any problem with my code . I am using CodeWarrior Development Studio
Original Attachment has been moved to: New-Text-Document-(2).txt.zip
Hi josephxavier,
Please also attach the picture of your fluctuation PWM wave, this will help us to identify the root problem.
Waiting for your reply!
Best Regards,
Jingjing
could verify the code attached in my previous post and suggest any correction if any .
how can I attach the image of fluctuating PWM ?
the PWM generated shows a fluctuation of
4Hz at 2kHz
40Hz at 5kHz
200Hz at 13kHz
I hope the above data is sufficient .
Hi josephxavier,
Thank you for your more details.
I check your attachment, and find you said" I am reading this PWM frequency using interrupt on rising edge and calculating the time between two successive rising edges
"
Could you tell me, how did you find your PWM is the fluctation in frequency? Through the OSCILLOSCOPE or just through the rising edge caculation?
We should make sure it is caused by the PWM or the rising edge capture error, you can just define the fixed PWM frequent , don't change it with function void Engine_speed_PWMOUT(unsigned int FMOD_regVal), then test it, whether it will have the fluctuation.
Besides, please send the whole project to me, I would like to help you to check it on my side.
Wish it helps you!
If you still have question, please contact with me!
Have a great day,
Jingjing
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
The fluctuations posted in my earlier post were observed on my CRO (it will not have any effect of my PWM frequency reading error (if any)).I hope I have shared my files related to my PWM generation.
Hi josephxavier,
The attached PWM project is for K20DX256VLL7, I already test it on our TWR-K20D72M board, and it works ok, without the fluctuations.
The project is the Codewarrior project, please refer to that code, the PWM wave can generated in PTC1 and PTC2 pin.
Wish it helps you!
If you still have question, please contact with me!
Have a great day,
Jingjing
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------