- Name:
- enabletime
- Syntax:
-
ENABLETIME
- Description:
-
Enable the elapsed time counter.
The M2 series have an internal elapsed time counter. This is a word variable called 'time' which increments once per second (at 4 or 16MHz operation). The time variable is designed as an approximate elapsed seconds counter, it is not a real time clock. This seconds counter starts automatically on a power-on reset, but can also be enabled/disabled by the disabletime / enabletime commands.
Note that the background internal timer used to count seconds is also used by several other commands such as servo. Therefore when re-enabling the time variable incrementing function with enabletime (after a disabletime command has previously been used) the first tick could happen any time during that initial one second time period. When the time function is disabled the time variable may be altered safely with a command such as 'let time = 0'.
The 'time' variable will not increment while a sleep command is executing.
Effect of increased clock speed
The time function will increment every second at 4 MHz or 16 MHz. At 2 MHz and 8 MHz the interval will be 2s, at 32 MHz the time interval will be 0.5s.
- Applies To:
- 08M2, 14M2, 18M2, 20M2
- See Also:
- Related Create:
-
Time example
Demonstrate use of enabletime and disabletime.
- Code Example:
-
main: pause 5000 disabletime ; disable time pause 5000 ; wait 5 seconds enabletime ; enable time debug ; display time value goto main ; loop back to start
Copy Code Submit an Example
Submit Your Own Code!
You must be logged in to submit code examples. Login now.