Time measurement unit.

This forum is dedicated to feedback, discussions about ongoing or future developments, ideas and suggestions regarding the ChibiOS projects are welcome. This forum is NOT for support.
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: Time measurement unit.

Post 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
Jevermeister
Posts: 13
Joined: Sun Nov 11, 2012 8:19 pm

Re: Time measurement unit.

Post 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?
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: Time measurement unit.

Post 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
Post Reply