2009-09-24 08:44:00 Setting & Retrieving of Timer pulse Width & Period in BF527
John Peter (INDIA)
I am trying to use the timer in PWM mode in BF527. I will need to change the Pulse width & time period many times. So I will need to retrive the value of these registers every time. Currently trying to use the gptimers.c & gptimers.h API's for setting & getting the pulse width & time period values.
I am facing a problem like when the timer is in enabled state I am setting a pulse width & when I immediately retriev the pulse width value from the corresponding register , it is showing the previous pulse width value only.
When I referred to the Hardware reference manual of BF527, I was able to see the below statement
"When a timer is enabled and running, and the software writes new values to the timer period register and the timer pulse width register,the writes are buffered and do not update the registers until the end of the current period (when the timer counter register equals the timer period register). "
Can anyone suggest me on how to handle this problem.
I am currently using uClinux-dist-2009R1-RC1 distribution
Thanks in advance.
2009-09-24 11:12:28 Re: Setting & Retrieving of Timer pulse Width & Period in BF527
Frank Van Hooft (CANADA)
A couple of suggestions.
1) It's generally easier & faster to keep a local variable containing your registers, rather than trying to read those register values each time you want to know what you previously wrote. As the documentation states, those registers are buffered so you might not always read what you expected.
2) If you're saying that you want to change values in mid-period, I think you're going to have to disable the timer, change the register settings, then re-enable the timer.