From baf2c2098e5cd7f2b4f982b1228bd8f03d2486c4 Mon Sep 17 00:00:00 2001
From: Gregory Nutt System Timer
In most implementations, system time is provided by a timer interrupt.
- That timer interrupt runs at rate determined by System Timer Accuracy
- On many system, the exact timer interval specified by make.
CONFIG_MSEC_PER_TICKS (default 10 or 100Hz).
- The timer generates an interrupt each CONFIG_MSEC_PER_TICKS milliseconds and increments a counter called g_system_timer.
- g_system_timer then provides a time-base for calculating up-time and elapsed time intervals in units of CONFIG_MSEC_PER_TICKS.
+ That timer interrupt runs at rate determined by CONFIG_USEC_PER_TICKS (default 10000 microseconds or 100Hz. If CONFIG_SCHED_TICKLESS is selected, the default is 100 microseconds).
+ The timer generates an interrupt each CONFIG_USEC_PER_TICKS microseconds and increments a counter called g_system_timer.
+ g_system_timer then provides a time-base for calculating up-time and elapsed time intervals in units of CONFIG_USEC_PER_TICKS.
The range of g_system_timer is, by default, 32-bits.
However, if the MCU supports type long long and CONFIG_SYSTEM_TIME16 is selected,
a 64-bit system timer will be supported instead.
CONFIG_MSEC_PER_TICKS cannot be achieved due to limitations in frequencies or in dividers.
- As a result, the time interval specified by CONFIG_MSEC_PER_TICKS may only be approximate and there may be small errors in the apparent up-time time.
+ On many system, the exact timer interval specified by CONFIG_USEC_PER_TICKS cannot be achieved due to limitations in frequencies or in dividers.
+ As a result, the time interval specified by CONFIG_USEC_PER_TICKS may only be approximate and there may be small errors in the apparent up-time time.
These small errors, however, will accumulate over time and after a long period of time may have an unacceptably large error in the apparent up-time of the MCU.
CONFIG_MSEC_PER_TICKS and if there you require accurate up-time for the MCU, then there are measures that you can take:
+ If the timer tick period generated by the hardware is not exactly CONFIG_USEC_PER_TICKS and if there you require accurate up-time for the MCU, then there are measures that you can take:
CONFIG_MSEC_PER_TICKS to a different value so that an exactly CONFIG_MSEC_PER_TICKS can be accomplished.
+ Perhaps you can adjust CONFIG_USEC_PER_TICKS to a different value so that an exactly CONFIG_USEC_PER_TICKS can be realized.
make.
Consider this case: The system timer is a count-up timer driven at 32.768KHz.
There are dividers that can be used, but a divider of one yields the highest accuracy.
This counter counts up until the count equals a match value, then a timer interrupt is generated.
- The desire frequency is 100Hz (CONFIG_MSEC_PER_TICKS is 10).
+ The desire frequency is 100Hz (CONFIG_USEC_PER_TICKS is 10000).
This exact frequency of 100Hz cannot be obtained in this case.