Page 2 of 2

Re: Time measurement unit.

Posted: Fri Mar 08, 2013 3:49 pm
by Giovanni
It is possible you problem is external, try to rewite the task as follow:

Code: Select all

    while (TRUE) {
             chBSemWait(&semaphore);
            tmStartMeasurement(&TimeMonitor);
            doStuff();
            chThdSleepMicroseconds(5000);
            tmStopMeasurement(&TimeMonitor);
    }


Also note that the measurement has 3 distinct outputs: last, worst, best.

Giovanni

Re: Time measurement unit.

Posted: Fri Mar 08, 2013 4:07 pm
by Jevermeister
Okay, now at least the measurement seems to be correct.
Needed to change CH_FREQUENCY back to 100 as otherwise my periodic CAN output status would sweep between +- 1ms delay.

Without any delay the thread runtime is stable at ~1350us. I just look at the last value. If i add 2000us delay, my measurement sweeps between 2300 and 3400 us. Is this caused by the decreased CH_FREQUENCY?

Re: Time measurement unit.

Posted: Fri Mar 08, 2013 4:12 pm
by Giovanni
Probably not, it is possible your task is not waked up with the interval you think or you have threads at higher priority interfering with the measurement or some other external condition, The measurement unit itself is extremely simple and I don't see obvious problems with it.

Giovanni