Is it possible to use a timer in a 5502 to measure the period of square wave on one of then TIMx pins? I can't find any reference to it in the docs or work it out. I may have missed something or not thought of a method.
TIA
Christian
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Is it possible to use a timer in a 5502 to measure the period of square wave on one of then TIMx pins? I can't find any reference to it in the docs or work it out. I may have missed something or not thought of a method.
TIA
Christian
Hi Christian,
You can measure the period of your square wave with two timers: TIMER 0 that
acts as a counter and TIMER 1 that acts as a GPIO input on the TIM1 pin. You
can configure the GPIO input to interrupt on the rising edge of an external
signal (your square wave). (See 3.11
Timer Operation in the GPIO Mode in the VC5501/5502 DSP Timers
Reference Guide)
When the timer pin sees a rising edge, an interrupt will fire. Inside of the interrupt service routine (ISR), you can calculate the time elapsed since the previous rising edge by subtracting the values of the TIMER 0 counter read during the previous ISR from the value read during the current ISR. (See 3.11.3 Timer Pin Used as Input to Source the Interrupt and 3.12.7 Reading the Counter Registers in the VC5501/5502 DSP Timers Reference Guide)
The time elapsed between rising edges is the period of your
external signal. You may want to average several period measurements to account
for jitter.
For precision, you should set up TIMER 0 to increment its counter at a rate
much faster than the frequency of the external signal.
The voltage of external signal needs to be within the
recommended operating conditions for the device. (See 5.3 Recommended Operating Conditions in the VC5502 Datasheet)
Don’t forget to configure the Timer Signal Selection Register (TSSR) to use the
TIM1 pin as the timer input pin. (See 3.5.3
Timer Signal Selection Register (TSSR) in the VC5502 Datasheet)
Hope this helps,
Mark