Hello Ashok
There is a stopwatch in the uTasker project (also works on FRDM-KL43Z).
I have attached a video showing it operating in the uTasker FRDM-KL43Z simulator and also a binary file that can be loaded to the board. The second button is used to freeze the time and when pressed again it allows the counter to be shown again (lap timing)
It runs in the 10ms tick interrupt and the code is as below (it does minimum switch de-bouncing and the generic SLCD interface [for all Kinetsi boards with SLCD] is fnTimeDisplay()).
Regards
Mark
extern void fnStopWatchApplication(void)
{
static int iTimerState = 0;
static unsigned char ulCount_ms = 0;
static unsigned char ulCount_s = 0;
int iStopKeyState = (_READ_PORT_MASK(A, SWITCH_1) == 0);
if (_READ_PORT_MASK(C, SWITCH_3) == 0) {
if (1 != iTimerState) {
ulCount_ms = ulCount_s = 0;
iTimerState = 1;
}
}
switch (iTimerState) {
case 0:
break;
case 4:
if (0 == iStopKeyState) {
iTimerState = 1;
}
case 1:
fnTimeDisplay(ulCount_s, ulCount_ms, 0);
if ((1 == iTimerState) && (1 == iStopKeyState)) {
iTimerState = 2;
}
case 2:
if ((2 == iTimerState) && (0 == iStopKeyState)) {
iTimerState = 3;
}
case 3:
if ((3 == iTimerState) && (0 != iStopKeyState)) {
iTimerState = 4;
}
if (++ulCount_ms > 99) {
ulCount_ms = 0;
if (++ulCount_s > 99) {
iTimerState = 2;
}
}
break;
}
}
Kinetis: http://www.utasker.com/kinetis.html
Kinetis KL43:
- http://www.utasker.com/kinetis/FRDM-KL43Z.html
- http://www.utasker.com/kinetis/TWR-KL43Z48M.html
SLCD: http://www.utasker.com/docs/uTasker/uTasker_SLCD.pdf
Free Open Source solution: https://github.com/uTasker/uTasker-Kinetis
Working project in 15 minutes video: https://youtu.be/K8ScSgpgQ6M
Professional Kinetis support, one-on-one training and complete fast-track project solutions: http://www.utasker.com/support.html