From c1603e96719150625a8f53748703dd83e9681ede Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Thu, 7 Aug 2014 13:42:47 -0600 Subject: Change CONFIG_MSEC_PER_TICK to CONFIG_USEC_PER_TICK. This gives more options for system timers in general, but more importantly, let's us realize higher resolution for the case of CONFIG_SCHED_TICKLESS=y -- of course, at the risk of some new interger overvflow problems --- nuttx/Documentation/NuttxPortingGuide.html | 16 ++++----- nuttx/arch/avr/src/at32uc3/at32uc3_timerisr.c | 10 +++--- nuttx/arch/avr/src/at90usb/at90usb_timerisr.c | 2 +- nuttx/arch/avr/src/atmega/atmega_timerisr.c | 2 +- nuttx/arch/rgmp/src/rgmp.c | 6 ++-- nuttx/configs/16z/nsh/defconfig | 2 +- nuttx/configs/amber/hello/defconfig | 2 +- nuttx/configs/arduino-due/nsh/defconfig | 2 +- nuttx/configs/avr32dev1/nsh/defconfig | 2 +- nuttx/configs/avr32dev1/ostest/defconfig | 2 +- nuttx/configs/c5471evm/httpd/defconfig | 2 +- nuttx/configs/c5471evm/nettest/defconfig | 2 +- nuttx/configs/c5471evm/nsh/defconfig | 2 +- nuttx/configs/cloudctrl/nsh/defconfig | 2 +- nuttx/configs/compal_e86/nsh_highram/defconfig | 2 +- nuttx/configs/compal_e88/nsh_highram/defconfig | 2 +- nuttx/configs/compal_e99/nsh_compalram/defconfig | 2 +- nuttx/configs/compal_e99/nsh_highram/defconfig | 2 +- nuttx/configs/demo9s12ne64/ostest/defconfig | 2 +- nuttx/configs/ea3131/nsh/defconfig | 2 +- nuttx/configs/ea3131/pgnsh/defconfig | 2 +- nuttx/configs/ea3131/usbserial/defconfig | 2 +- nuttx/configs/ea3152/ostest/defconfig | 2 +- nuttx/configs/eagle100/httpd/defconfig | 2 +- nuttx/configs/eagle100/nettest/defconfig | 2 +- nuttx/configs/eagle100/nsh/defconfig | 2 +- nuttx/configs/eagle100/nxflat/defconfig | 2 +- nuttx/configs/eagle100/thttpd/defconfig | 2 +- nuttx/configs/ekk-lm3s9b96/nsh/defconfig | 2 +- nuttx/configs/ez80f910200kitg/ostest/defconfig | 2 +- nuttx/configs/ez80f910200zco/dhcpd/defconfig | 2 +- nuttx/configs/ez80f910200zco/httpd/defconfig | 2 +- nuttx/configs/ez80f910200zco/nettest/defconfig | 2 +- nuttx/configs/ez80f910200zco/nsh/defconfig | 2 +- nuttx/configs/ez80f910200zco/poll/defconfig | 2 +- nuttx/configs/fire-stm32v2/nsh/defconfig | 2 +- nuttx/configs/freedom-kl25z/minnsh/defconfig | 2 +- nuttx/configs/freedom-kl25z/nsh/defconfig | 2 +- nuttx/configs/hymini-stm32v/buttons/defconfig | 2 +- nuttx/configs/hymini-stm32v/nsh/defconfig | 2 +- nuttx/configs/hymini-stm32v/nsh2/defconfig | 2 +- nuttx/configs/hymini-stm32v/usbmsc/defconfig | 2 +- nuttx/configs/hymini-stm32v/usbnsh/defconfig | 2 +- nuttx/configs/hymini-stm32v/usbserial/defconfig | 2 +- nuttx/configs/kwikstik-k40/ostest/defconfig | 2 +- nuttx/configs/lincoln60/nsh/defconfig | 2 +- nuttx/configs/lm3s6432-s2e/nsh/defconfig | 2 +- nuttx/configs/lm3s6965-ek/discover/defconfig | 2 +- nuttx/configs/lm3s6965-ek/nsh/defconfig | 2 +- nuttx/configs/lm3s6965-ek/nx/defconfig | 2 +- nuttx/configs/lm3s6965-ek/tcpecho/defconfig | 2 +- nuttx/configs/lm3s8962-ek/nsh/defconfig | 2 +- nuttx/configs/lm3s8962-ek/nx/defconfig | 2 +- nuttx/configs/lm4f120-launchpad/nsh/defconfig | 2 +- nuttx/configs/lpc4330-xplorer/nsh/defconfig | 2 +- nuttx/configs/lpcxpresso-lpc1768/dhcpd/defconfig | 2 +- nuttx/configs/lpcxpresso-lpc1768/nsh/defconfig | 2 +- nuttx/configs/lpcxpresso-lpc1768/nx/defconfig | 2 +- nuttx/configs/lpcxpresso-lpc1768/thttpd/defconfig | 2 +- nuttx/configs/lpcxpresso-lpc1768/usbmsc/defconfig | 2 +- nuttx/configs/maple/nsh/defconfig | 2 +- nuttx/configs/maple/nx/defconfig | 2 +- nuttx/configs/maple/usbnsh/defconfig | 2 +- nuttx/configs/mbed/hidkbd/defconfig | 2 +- nuttx/configs/mbed/nsh/defconfig | 2 +- nuttx/configs/mcu123-lpc214x/composite/defconfig | 2 +- nuttx/configs/mcu123-lpc214x/nsh/defconfig | 2 +- nuttx/configs/mcu123-lpc214x/usbmsc/defconfig | 2 +- nuttx/configs/mcu123-lpc214x/usbserial/defconfig | 2 +- nuttx/configs/micropendous3/hello/defconfig | 2 +- nuttx/configs/mikroe-stm32f4/fulldemo/defconfig | 2 +- nuttx/configs/mikroe-stm32f4/kostest/defconfig | 2 +- nuttx/configs/mikroe-stm32f4/nsh/defconfig | 2 +- nuttx/configs/mikroe-stm32f4/nx/defconfig | 2 +- nuttx/configs/mikroe-stm32f4/nxlines/defconfig | 2 +- nuttx/configs/mikroe-stm32f4/nxtext/defconfig | 2 +- nuttx/configs/mikroe-stm32f4/usbnsh/defconfig | 2 +- nuttx/configs/mirtoo/nsh/defconfig | 2 +- nuttx/configs/mirtoo/nxffs/defconfig | 2 +- nuttx/configs/mx1ads/ostest/defconfig | 2 +- nuttx/configs/ne64badge/ostest/defconfig | 2 +- nuttx/configs/ntosd-dm320/nettest/defconfig | 2 +- nuttx/configs/ntosd-dm320/nsh/defconfig | 2 +- nuttx/configs/ntosd-dm320/poll/defconfig | 2 +- nuttx/configs/ntosd-dm320/thttpd/defconfig | 2 +- nuttx/configs/ntosd-dm320/udp/defconfig | 2 +- nuttx/configs/ntosd-dm320/webserver/defconfig | 2 +- nuttx/configs/nucleo-f401re/nsh/defconfig | 2 +- nuttx/configs/nucleus2g/nsh/defconfig | 2 +- nuttx/configs/nucleus2g/usbmsc/defconfig | 2 +- nuttx/configs/nucleus2g/usbserial/defconfig | 2 +- nuttx/configs/nutiny-nuc120/nsh/defconfig | 2 +- nuttx/configs/olimex-lpc-h3131/nsh/defconfig | 2 +- nuttx/configs/olimex-lpc1766stk/ftpc/defconfig | 2 +- nuttx/configs/olimex-lpc1766stk/hidkbd/defconfig | 2 +- nuttx/configs/olimex-lpc1766stk/hidmouse/defconfig | 2 +- nuttx/configs/olimex-lpc1766stk/nettest/defconfig | 2 +- nuttx/configs/olimex-lpc1766stk/nsh/defconfig | 2 +- nuttx/configs/olimex-lpc1766stk/nx/defconfig | 2 +- .../configs/olimex-lpc1766stk/slip-httpd/defconfig | 2 +- nuttx/configs/olimex-lpc1766stk/thttpd/defconfig | 2 +- nuttx/configs/olimex-lpc1766stk/usbmsc/defconfig | 2 +- .../configs/olimex-lpc1766stk/usbserial/defconfig | 2 +- nuttx/configs/olimex-lpc1766stk/zmodem/defconfig | 2 +- nuttx/configs/olimex-lpc2378/nsh/defconfig | 2 +- nuttx/configs/olimex-stm32-h405/nshusb/defconfig | 2 +- nuttx/configs/olimex-stm32-p107/nsh/defconfig | 2 +- nuttx/configs/olimex-stm32-p207/nsh/defconfig | 2 +- nuttx/configs/olimex-strp711/nettest/defconfig | 2 +- nuttx/configs/olimex-strp711/nsh/defconfig | 2 +- nuttx/configs/open1788/knsh/defconfig | 2 +- nuttx/configs/open1788/nsh/defconfig | 2 +- nuttx/configs/open1788/nxlines/defconfig | 2 +- nuttx/configs/p112/ostest/defconfig | 2 +- nuttx/configs/pcblogic-pic32mx/nsh/defconfig | 2 +- nuttx/configs/pcduino-a10/nsh/defconfig | 2 +- nuttx/configs/pic32-starterkit/nsh/defconfig | 2 +- nuttx/configs/pic32-starterkit/nsh2/defconfig | 2 +- nuttx/configs/pic32mx7mmb/nsh/defconfig | 2 +- nuttx/configs/pirelli_dpl10/nsh_highram/defconfig | 2 +- nuttx/configs/pjrc-8051/defconfig | 2 +- nuttx/configs/px4fmu-v2_upstream/nsh/defconfig | 2 +- nuttx/configs/qemu-i486/nsh/defconfig | 2 +- nuttx/configs/qemu-i486/ostest/defconfig | 2 +- nuttx/configs/rgmp/arm/default/defconfig | 2 +- nuttx/configs/rgmp/arm/nsh/defconfig | 2 +- nuttx/configs/rgmp/x86/cxxtest/defconfig | 2 +- nuttx/configs/rgmp/x86/default/defconfig | 2 +- nuttx/configs/rgmp/x86/helloxx/defconfig | 2 +- nuttx/configs/rgmp/x86/nsh/defconfig | 2 +- nuttx/configs/sam3u-ek/knsh/defconfig | 2 +- nuttx/configs/sam3u-ek/nsh/defconfig | 2 +- nuttx/configs/sam3u-ek/nx/defconfig | 2 +- nuttx/configs/sam3u-ek/nxwm/defconfig | 2 +- nuttx/configs/sam4e-ek/nsh/defconfig | 2 +- nuttx/configs/sam4e-ek/usbnsh/defconfig | 2 +- nuttx/configs/sam4l-xplained/nsh/defconfig | 2 +- nuttx/configs/sam4s-xplained-pro/nsh/defconfig | 2 +- nuttx/configs/sam4s-xplained/nsh/defconfig | 2 +- nuttx/configs/sama5d3-xplained/nsh/defconfig | 2 +- nuttx/configs/sama5d3x-ek/demo/defconfig | 2 +- nuttx/configs/sama5d3x-ek/hello/defconfig | 2 +- nuttx/configs/sama5d3x-ek/norboot/defconfig | 2 +- nuttx/configs/sama5d3x-ek/nsh/defconfig | 2 +- nuttx/configs/sama5d3x-ek/nx/defconfig | 2 +- nuttx/configs/sama5d3x-ek/nxplayer/defconfig | 2 +- nuttx/configs/sama5d3x-ek/nxwm/defconfig | 2 +- nuttx/configs/sama5d3x-ek/ov2640/defconfig | 2 +- nuttx/configs/sama5d4-ek/at25boot/defconfig | 2 +- nuttx/configs/sama5d4-ek/dramboot/defconfig | 2 +- nuttx/configs/sama5d4-ek/nsh/defconfig | 2 +- nuttx/configs/sama5d4-ek/nxwm/defconfig | 2 +- nuttx/configs/sama5d4-ek/ramtest/defconfig | 2 +- nuttx/configs/samd20-xplained/nsh/defconfig | 2 +- nuttx/configs/shenzhou/nsh/defconfig | 2 +- nuttx/configs/shenzhou/nxwm/defconfig | 2 +- nuttx/configs/shenzhou/thttpd/defconfig | 2 +- nuttx/configs/sim/configdata/defconfig | 2 +- nuttx/configs/sim/cxxtest/defconfig | 2 +- nuttx/configs/sim/mount/defconfig | 2 +- nuttx/configs/sim/mtdpart/defconfig | 2 +- nuttx/configs/sim/nettest/defconfig | 2 +- nuttx/configs/sim/nsh/defconfig | 2 +- nuttx/configs/sim/nsh2/defconfig | 2 +- nuttx/configs/sim/nx/defconfig | 2 +- nuttx/configs/sim/nx11/defconfig | 2 +- nuttx/configs/sim/nxffs/defconfig | 2 +- nuttx/configs/sim/nxlines/defconfig | 2 +- nuttx/configs/sim/nxwm/defconfig | 2 +- nuttx/configs/sim/ostest/defconfig | 2 +- nuttx/configs/sim/pashello/defconfig | 2 +- nuttx/configs/sim/touchscreen/defconfig | 2 +- nuttx/configs/skp16c26/ostest/defconfig | 2 +- nuttx/configs/spark/composite/defconfig | 2 +- nuttx/configs/spark/nsh/defconfig | 2 +- nuttx/configs/spark/usbmsc/defconfig | 2 +- nuttx/configs/spark/usbnsh/defconfig | 2 +- nuttx/configs/spark/usbserial/defconfig | 2 +- nuttx/configs/stm3210e-eval/buttons/defconfig | 2 +- nuttx/configs/stm3210e-eval/composite/defconfig | 2 +- nuttx/configs/stm3210e-eval/nsh/defconfig | 2 +- nuttx/configs/stm3210e-eval/nsh2/defconfig | 2 +- nuttx/configs/stm3210e-eval/nx/defconfig | 2 +- nuttx/configs/stm3210e-eval/nxconsole/defconfig | 2 +- nuttx/configs/stm3210e-eval/pm/defconfig | 2 +- nuttx/configs/stm3210e-eval/usbmsc/defconfig | 2 +- nuttx/configs/stm3210e-eval/usbserial/defconfig | 2 +- nuttx/configs/stm3220g-eval/dhcpd/defconfig | 2 +- nuttx/configs/stm3220g-eval/nettest/defconfig | 2 +- nuttx/configs/stm3220g-eval/nsh/defconfig | 2 +- nuttx/configs/stm3220g-eval/nsh2/defconfig | 2 +- nuttx/configs/stm3220g-eval/nxwm/defconfig | 2 +- nuttx/configs/stm3220g-eval/telnetd/defconfig | 2 +- nuttx/configs/stm3240g-eval/dhcpd/defconfig | 2 +- nuttx/configs/stm3240g-eval/discover/defconfig | 2 +- nuttx/configs/stm3240g-eval/knxwm/defconfig | 2 +- nuttx/configs/stm3240g-eval/nettest/defconfig | 2 +- nuttx/configs/stm3240g-eval/nsh/defconfig | 2 +- nuttx/configs/stm3240g-eval/nsh2/defconfig | 2 +- nuttx/configs/stm3240g-eval/nxconsole/defconfig | 2 +- nuttx/configs/stm3240g-eval/nxwm/defconfig | 2 +- nuttx/configs/stm3240g-eval/telnetd/defconfig | 2 +- nuttx/configs/stm3240g-eval/webserver/defconfig | 2 +- nuttx/configs/stm3240g-eval/xmlrpc/defconfig | 2 +- nuttx/configs/stm32_tiny/nsh/defconfig | 2 +- nuttx/configs/stm32_tiny/usbnsh/defconfig | 2 +- nuttx/configs/stm32f100rc_generic/nsh/defconfig | 2 +- nuttx/configs/stm32f3discovery/nsh/defconfig | 2 +- nuttx/configs/stm32f3discovery/usbnsh/defconfig | 2 +- nuttx/configs/stm32f429i-disco/extflash/defconfig | 2 +- nuttx/configs/stm32f429i-disco/nsh/defconfig | 2 +- nuttx/configs/stm32f429i-disco/usbmsc/defconfig | 2 +- nuttx/configs/stm32f429i-disco/usbnsh/defconfig | 2 +- nuttx/configs/stm32f4discovery/cxxtest/defconfig | 2 +- nuttx/configs/stm32f4discovery/elf/defconfig | 2 +- nuttx/configs/stm32f4discovery/kostest/defconfig | 2 +- nuttx/configs/stm32f4discovery/nsh/defconfig | 2 +- nuttx/configs/stm32f4discovery/nxlines/defconfig | 2 +- nuttx/configs/stm32f4discovery/pm/defconfig | 2 +- .../configs/stm32f4discovery/posix_spawn/defconfig | 2 +- nuttx/configs/stm32f4discovery/usbnsh/defconfig | 2 +- nuttx/configs/stm32f4discovery/winbuild/defconfig | 2 +- nuttx/configs/stm32ldiscovery/nsh/defconfig | 2 +- nuttx/configs/stm32vldiscovery/nsh/defconfig | 2 +- nuttx/configs/sure-pic32mx/nsh/defconfig | 2 +- nuttx/configs/sure-pic32mx/usbnsh/defconfig | 2 +- nuttx/configs/teensy/hello/defconfig | 2 +- nuttx/configs/teensy/nsh/defconfig | 2 +- nuttx/configs/teensy/usbmsc/defconfig | 2 +- nuttx/configs/tm4c123g-launchpad/nsh/defconfig | 2 +- nuttx/configs/twr-k60n512/nsh/defconfig | 2 +- nuttx/configs/ubw32/nsh/defconfig | 2 +- nuttx/configs/us7032evb1/nsh/defconfig | 2 +- nuttx/configs/us7032evb1/ostest/defconfig | 2 +- nuttx/configs/viewtool-stm32f107/highpri/defconfig | 2 +- nuttx/configs/viewtool-stm32f107/netnsh/defconfig | 2 +- nuttx/configs/viewtool-stm32f107/nsh/defconfig | 2 +- nuttx/configs/vsn/nsh/defconfig | 2 +- nuttx/configs/xtrs/nsh/defconfig | 2 +- nuttx/configs/xtrs/ostest/defconfig | 2 +- nuttx/configs/xtrs/pashello/defconfig | 2 +- nuttx/configs/z16f2800100zcog/nsh/defconfig | 2 +- nuttx/configs/z16f2800100zcog/ostest/defconfig | 2 +- nuttx/configs/z16f2800100zcog/pashello/defconfig | 2 +- nuttx/configs/z80sim/nsh/defconfig | 2 +- nuttx/configs/z80sim/ostest/defconfig | 2 +- nuttx/configs/z80sim/pashello/defconfig | 2 +- nuttx/configs/z8encore000zco/ostest/defconfig | 2 +- nuttx/configs/z8f64200100kit/ostest/defconfig | 2 +- nuttx/configs/zkit-arm-1769/hello/defconfig | 2 +- nuttx/configs/zkit-arm-1769/nsh/defconfig | 2 +- nuttx/configs/zkit-arm-1769/nxhello/defconfig | 2 +- nuttx/configs/zkit-arm-1769/thttpd/defconfig | 2 +- nuttx/configs/zp214xpa/nsh/defconfig | 2 +- nuttx/configs/zp214xpa/nxlines/defconfig | 2 +- nuttx/include/limits.h | 17 +++++----- nuttx/include/nuttx/clock.h | 39 +++++++++++++++------- nuttx/include/time.h | 8 ++--- nuttx/sched/Kconfig | 32 ++++++++++++------ 259 files changed, 331 insertions(+), 301 deletions(-) diff --git a/nuttx/Documentation/NuttxPortingGuide.html b/nuttx/Documentation/NuttxPortingGuide.html index 0f54a3e87..8eb13e297 100644 --- a/nuttx/Documentation/NuttxPortingGuide.html +++ b/nuttx/Documentation/NuttxPortingGuide.html @@ -2220,23 +2220,23 @@ The system can be re-made subsequently by just typing make.

System Timer In most implementations, system time is provided by a timer interrupt. - That timer interrupt runs at rate determined by 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.

System Timer Accuracy - On many system, the exact timer interval specified by 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.

- If the timer tick period generated by the hardware is not exactly 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: