Timer Counter Accuracy

Discussion around product based on ARM Cortex M3 core.
This forum will be discontinued soon.

Moderators: nferre, ncollot

dougcl
Posts: 10
Joined: Tue Nov 04, 2014 5:09 pm

Timer Counter Accuracy

Tue Jan 31, 2017 1:34 am

Hi folks,
I am trying to accurately measure audio rate square waves using the TC module of the SAM3S. I am finding that the actual counts coming back between ra and rb are about 1.1% off, varying depending on the freq if the square wave. I need 0.27% accuracy.

I have a SAM3S4A with an external 12Mhz crystal 403C35E12M00000 and 22pf caps. This device has a 30ppm tolerance. Am I expecting too much?

Meanwhile, I have swtiched the slow clock to XTAL32 and measured main clock. I get 12001280Hz, so if that measurement process is reliable, then it appears the 1.1% error is elsewhere. Could it be introduced in PLLA? Is there a way to use the slow clock to measure the actual MCK value? Or is the error within the TC module itself? Is the loading of ra and rb subject to error on the order of 1%?

Note the signal is not perfect, and ra and rb do jump around, but the variation there is around 0.25%, which is great. It really seems like the whole process is shifted either by a MCK inaccuracy, or something systemically wrong in the ra and rb acquisition.

Thanks
Doug
dougcl
Posts: 10
Joined: Tue Nov 04, 2014 5:09 pm

Re: Timer Counter Accuracy

Sat Apr 08, 2017 10:43 am

The problem was that I was using rb-ra to get a half wave count. Of course the wave is not perfectly symmetric, in fact there is about a 1.1% symmetry error in the signal. So the answer was to configure the clock to start on a falling edge. Load ra on rising, rb on falling, and trigger an interrupt on rb load. Disable the interrupt and the clock in the interrupt, and then take rb as the full cycle count (falling edge to falling edge).

Doug

Return to “SAM3 Cortex-M3 MCU”

Who is online

Users browsing this forum: No registered users and 1 guest