Improved calibration procedure.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@13367 27425a3e-05d8-49a3-a47f-9c15f0e5edd8
This commit is contained in:
parent
9590773bc5
commit
a5e60e7a66
|
@ -34,6 +34,13 @@
|
||||||
/* Module local definitions. */
|
/* Module local definitions. */
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Number of iterations in the calibration loop.
|
||||||
|
* @note This is required in order to assess the best result in
|
||||||
|
* architectures with instruction cache.
|
||||||
|
*/
|
||||||
|
#define TM_CALIBRATION_LOOP 4U
|
||||||
|
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
/* Module exported variables. */
|
/* Module exported variables. */
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
@ -76,15 +83,20 @@ static inline void tm_stop(time_measurement_t *tmp,
|
||||||
*/
|
*/
|
||||||
void _tm_init(void) {
|
void _tm_init(void) {
|
||||||
time_measurement_t tm;
|
time_measurement_t tm;
|
||||||
|
unsigned i;
|
||||||
|
|
||||||
/* Time Measurement subsystem calibration, it does a null measurement
|
/* Time Measurement subsystem calibration, it does a null measurement
|
||||||
and calculates the call overhead which is subtracted to real
|
and calculates the call overhead which is subtracted to real
|
||||||
measurements.*/
|
measurements.*/
|
||||||
ch.tm.offset = (rtcnt_t)0;
|
ch.tm.offset = (rtcnt_t)0;
|
||||||
chTMObjectInit(&tm);
|
chTMObjectInit(&tm);
|
||||||
|
i = TM_CALIBRATION_LOOP;
|
||||||
|
do {
|
||||||
chTMStartMeasurementX(&tm);
|
chTMStartMeasurementX(&tm);
|
||||||
chTMStopMeasurementX(&tm);
|
chTMStopMeasurementX(&tm);
|
||||||
ch.tm.offset = tm.last;
|
i--;
|
||||||
|
} while (i > 0U);
|
||||||
|
ch.tm.offset = tm.best;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue