Professional Documents
Culture Documents
TL1
TH0
TL0
TIMER1 COUNTER
TIMER0 COUNTER
IE REG: TO ENABLE DIFFERENT INTERRUPTS
EA
-ET2
ES
ET1
EX1
ET0
VECTOR
0023
001B
0013
000B
LOCATION
EX0
0003
Normal Mode
Program the Timer using TMOD
Load Required Count value in
THx-TLx
Start Timer
Monitor Timer by Checking TFx
Stop Timer
Reset TFx
1
2
3
4
1.
Interrupt Mode
Program the Timer using TMOD
Load Required Count value in
THx-TLx
Start Timer
Continue the Main Program
:
Timer ISR
Stop Timer
Continue ISR
:
Return from ISR
/*main*/
#define Ms_INIT 63535
void main (void)
int count_millsec = 0;
Configure Timer Mode
Set Cnt to Ms_INIT
Wait a random time
Turn on indicator light
start timer
while (user not pushed
reaction button)
{
if (top)
{
stop timer
reset top
count_millsec++;
set count to Ms_INIT
start timer
}
}
Turn off indicator light
printf (time: %i ms,
count_millsec);
main()
{
wait until card inserted
call watchdog_reset routine
while(trans. In progress){
if(button pressed){
perform corresponding action
call watchdog_reset_ routine}
/* if watchdog_reset_routine not
Called every<2min,
int_service_routine is called*/
}
watchdog_reset_routine(){