Systick Inaccuracy

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 15, 2016 by lpcware
Content originally posted in LPCWare by nelmak on Fri Apr 13 07:51:32 MST 2012

I am having problems with getting accurate readings using the Systick timer. I am trying to measure the time intervals between pulses. These pulses have the same geometry from a function generator.

My Systick is ticking at every 1ms.

Below is the simple code i am using,

        adcval = ADCRead(0);

        if ((oldadcval > 200) && (adcval < 200))
            printf("%d ms\n", msTicks);
            msTicks = 0;

        oldadcval = adcval;

When I run a 2.5Hz pulse into AD0, it gives me a reading of 310ms or approximately 3.2Hz. Which is wrong. How would i be able to get an accurate reading? Would using a timer increase the accuracy?