Frequency Counter (Update)
Spend some time this weekend and now have the display timer update callback working. I originally set it up to read from a queue, but that did work like I expected. To clarify, the callback worked well, since it was only pulling the data out of the queue. The issue came from putting the data in the queue.
Capturing frequency is really the counts per time period. To do this we tie a counter to an external pin and we see how many counts is has after a time period has expired. The software architecture would typically be to use a timer peripheral setup to fire an interrupt service routine (ISR) when the timer expires.
The process typically looks like this:
- Setup the timer so that the expiration period is the gate time.
- Clear the counter value.
- Enable the timer.
When the gate timer expires the ISR gets called and does the following:
- Stop the counter.
- Clear the interrupt flag.
- Calculate the frequency. (This may be done later)
So everything was going fine, until I tried to put a new entry in the queue.
Seems FreeRTOS compares the priority of the interrupt that is called to the ISR that is used for the system tick of the RTOS.
Now to figure out whether to continue down the path of using the queue, or to switch to just using a global variable.
I put the code on GitHub here.