Real-time clock, Example code 6.1 – Wavetronix Click 500 (programmable controller) (CLK-500) - Developer Guide User Manual
Page 64
CHAPTER 6 • TIMERS AND CLOCKS 63
pressed because the total delay will be 20 seconds.
Real-time Clock
The ClickUtilTimer objects are helpful for creating non-blocking delays. However, they do
have certain limitations. These timers will fire every 47 days if they are not reset. Consider
using the real time clock to schedule events that are far into the future. The real-time clock
is accurate until the year 2047.
Example Code 6.1
The example below can be found in the Examples directory and is named “ExampleCode6.1.c.”
This example shows the advantages of cooperative multitasking using non-blocking delay
timers and it also shows how to register a callback interrupt service routine.
By pressing the push-button, you can pause and resume play of the progress indication bar.
However, you can only use the push-button after an initial startup time. The red LEDs will
turn off when the initial startup time expires.
///////////////////////////////////////////////////////////////
// ExampleCode6.1.C
///////////////////////////////////////////////////////////////
#use click500menu.lib
#use click500timer.lib
#define PROGRESS_STATE_PLAY
0
#define PROGRESS_STATE_PAUSE
1
void Mode1( void );
void Mode2( void );
void Setup( void );
void ProgressTimerISR( void );
void PlayPauseBtnCheck( void );
void UpdateProgress( void );
char ProgressState;
char ProgressStateRead;
char PlayPauseState;
ClickUtilTimer WaitTimer;