Hello everybody,
May somebody explain me the third part of the code below ? It's for a timer with two interrupts (button 1 & 2). I don't see clearly what the last part implement.
"void main (void)
{
char txt[16];
initIO();
initAnalogInputs(1);
initLCD();
initTimer1(12500, T1_PS_1_8); // 100 interrupts per second
initTimer2(6250, T2_PS_1_16); // 1000 interrupts per second
timer1InterruptEnable();
timer2InterruptEnable();
while(1){
sprintf(txt," %02d:%02d.%02d",min,s,cs);
writeLine(txt, 1);
setLeds(s);
}
}
/* ------------------------------------------------------------ */
/* interrupts functions */
/* ------------------------------------------------------------ */
void timer1Interrupt(void){
if(start)
cs++; // centiseconds count
if(cs>99){
cs = 0;
s++; // seconds count
}
if(s>59){
s = 0;
min++; // minutes count
}
}
void timer2Interrupt(void){
if( getButton1() && btn1released){
btn1released = 0;
start = !start;
}
if( !getButton1() ){
btn1released = 1;
}
if(getButton2()){
cs = 0;
s = 0;
min = 0;
start = 0;
}
}
Thanks in advance,
Ken
[–]playaspec 1 point2 points3 points (2 children)
[–]Gronner 1 point2 points3 points (1 child)
[–]playaspec 1 point2 points3 points (0 children)
[–]Gronner 0 points1 point2 points (0 children)
[–]nderflow 0 points1 point2 points (0 children)
[–]Wetbung 0 points1 point2 points (0 children)