Content-Type: Multipart/Alternative; boundary="------------Boundary-00=_4DGBLVC0000000000000" --------------Boundary-00=_4DGBLVC0000000000000 Content-Type: Text/Plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable =0D Set up an interrupt that interrupts every millisec or so....=0D =0D In the IRS routine... increment a 2, 3 or 4 byte counter (an=0D up-counter)....=0D =0D Then check to see if your counter is zero in all bytes...=0D =0D If so, set a flag.=0D =0D In your main program code... check the flag..=0D =0D If set, 30+ secs (or whatever) have passed.=0D =0D Below is a ASM IRS routine that is incrementing=0D two, two-byte up counters and setting a flag...=0D =0D Remember, these are up counters so your start value=0D is complemented.=0D =0D Hope this helps,=0D =0D Bill KA8VIT=0D =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=0D =0D TIMER1_INT:=0D CLR TR1 ;TURN OFF TIMER=0D CLR TF1 ;CLEAR INTERRUPT FLAG=0D MOV TL1,#LOW(-HEARTBEAT) ;RELOAD TIMER VALUES=0D MOV TH1,#HIGH(-HEARTBEAT)=0D SETB TR1 ;RE-START THE TIMER=0D PUSH ACC ;SAVE ACC CAUSE WERE GONNA USE IT=0D JNB COUNTER0FLG,TIMER1_INT_A ;SKIP IF NOT USING COUNTER ZERO=0D ;RIGHT NOW=0D INC COUNTER0L ;INCREMENT COUNTER ZERO LOW BYTE=0D MOV A,COUNTER0L ;NOW FETCH IT=0D JNZ TIMER1_INT_A ;IF NOT ZERO THEN NO ROLLOVER=0D INC COUNTER0H ;INCRMENT COUNTER ZERO HIGH BYTE=0D MOV A,COUNTER0H ;NOW FETCH IT=0D JNZ TIMER1_INT_A ;IF NOT ZERO THEN NO ROLLOVER=0D SETB COUNTER0OVR ;SET THE COUNTER OVERFLOW FLAG=0D CLR COUNTER0FLG ;CLEAR THE COUNTER IN-USE FLAG=0D =0D TIMER1_INT_A: =0D JNB COUNTER1FLG,TIMER1_INT_X ;SKIP IF NOT USING COUNTER ONE=0D ;RIGHT NOW=0D INC COUNTER1L ;INCREMENT COUNTER ONE LOW BYTE=0D MOV A,COUNTER1L ;NOW FETCH IT=0D JNZ TIMER1_INT_X ;IF NOT ZERO THEN NO ROLLOVER=0D INC COUNTER1H ;INCRMENT COUNTER ONE HIGH BYTE=0D MOV A,COUNTER1H ;NOW FETCH IT=0D JNZ TIMER1_INT_X ;IF NOT ZERO THEN NO ROLLOVER=0D SETB COUNTER1OVR ;SET THE COUNTER OVERFLOW FLAG=0D CLR COUNTER1FLG ;CLEAR THE COUNTER IN-USE FLAG=0D =0D TIMER1_INT_X:=0D POP ACC ;RESTORE THE ACC=0D RETI=0D =0D =0D -------Original Message-------=0D =0D From: sdcc-user@lists.sourceforge.net=0D Date: Tuesday, March 25, 2003 12:34:42 PM=0D To: sdcc-user@lists.sourceforge.net=0D Subject: [Sdcc-user] help with timer=0D =0D Hi all I would like to know if some one could help me. I am working with = a home alarm system and I need to run a function for 30 sec to check if the right code has been inputed. I am using AT89C52 with 11.059 crystal. I am programming in c.=0D =0D =0D =0D =0D Do you Yahoo!?=0D Yahoo! Platinum - Watch CBS' NCAA March Madness, live on your desktop!=20= --------------Boundary-00=_4DGBLVC0000000000000 Content-Type: Text/HTML; charset="us-ascii" Content-Transfer-Encoding: quoted-printable =0D =0A
 
Set up an interrupt that interrupts every millisec or so....
 
In the IRS routine... increment a 2, 3 or 4 byte counter (an
up-counter)....
 
Then check to see if your counter is zero in all bytes...
 
If so, set a flag.
 
In your main program code...  check the flag..
 
If set, 30+ secs (or whatever) have passed.
 
Below is a ASM IRS routine that is incrementing
two,  two-byte up counters  and setting a flag...
 
Remember, these are up counters so your start value
is complemented.
 
Hope this helps,
 
Bill  KA8VIT
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
 
TIMER1_INT:
    CLR    =20 TR1          &nbs= p;         =20 ;TURN OFF TIMER
    CLR    =20 TF1          &nbs= p;         =20 ;CLEAR INTERRUPT FLAG
    MOV   &n= bsp;=20 TL1,#LOW(-HEARTBEAT)   ;RELOAD TIMER=20 VALUES
    MOV    =20 TH1,#HIGH(-HEARTBEAT)
    SETB   =20 TR1          &nbs= p;         =20 ;RE-START THE TIMER
    PUSH   =20 ACC          &nbs= p;         =20 ;SAVE ACC CAUSE WERE GONNA USE IT
   =20 JNB     COUNTER0FLG,TIMER1_INT_A  &nb= sp;=20 ;SKIP IF NOT USING COUNTER=20 ZERO
          = ;            =             &= nbsp;    =20 ;RIGHT NOW
    INC    =20 COUNTER0L         &nbs= p;    =20 ;INCREMENT COUNTER ZERO LOW BYTE
   =20 MOV    =20 A,COUNTER0L         &n= bsp;  =20 ;NOW FETCH IT
    JNZ    =20 TIMER1_INT_A         &= nbsp; =20 ;IF NOT ZERO THEN NO ROLLOVER
   =20 INC    =20 COUNTER0H         &nbs= p;    =20 ;INCRMENT COUNTER ZERO HIGH BYTE
   =20 MOV    =20 A,COUNTER0H         &n= bsp;  =20 ;NOW FETCH IT
    JNZ    =20 TIMER1_INT_A         &= nbsp;  =20 ;IF NOT ZERO THEN NO ROLLOVER
    SETB  = ; =20 COUNTER0OVR         &n= bsp;  =20 ;SET THE COUNTER OVERFLOW FLAG
   =20 CLR     COUNTER0FLG   =20     ;CLEAR THE COUNTER IN-USE=20 FLAG
       =20
TIMER1_INT_A:   
   =20 JNB     COUNTER1FLG,TIMER1_INT_X  &nb= sp;=20 ;SKIP IF NOT USING COUNTER=20 ONE
          =             &= nbsp;           &n= bsp;    =20 ;RIGHT NOW
    INC    =20 COUNTER1L         &nbs= p;    =20 ;INCREMENT COUNTER ONE LOW BYTE
   =20 MOV    =20 A,COUNTER1L         &n= bsp;  =20 ;NOW FETCH IT
    JNZ    =20 TIMER1_INT_X         &= nbsp; =20 ;IF NOT ZERO THEN NO ROLLOVER
   =20 INC    =20 COUNTER1H         &nbs= p;    =20 ;INCRMENT COUNTER ONE HIGH BYTE
   =20 MOV    =20 A,COUNTER1H         &n= bsp;  =20 ;NOW FETCH IT
    JNZ    =20 TIMER1_INT_X         &= nbsp;  =20 ;IF NOT ZERO THEN NO ROLLOVER
    SETB  = ; =20 COUNTER1OVR         &n= bsp;  =20 ;SET THE COUNTER OVERFLOW FLAG
    CLR  = ; =20 COUNTER1FLG        ;CLEAR THE COUNTER= IN-USE=20 FLAG
TIMER1_INT_X:
    POP    = ;=20 ACC          &nbs= p;         =20 ;RESTORE THE ACC
    RETI
 
-------Original Message-------<= /I>
 
From: sdcc-user@lists.sou= rceforge.net
Date: Tuesda= y, March=20 25, 2003 12:34:42 PM
To: sdcc-user@lists.sou= rceforge.net
Subject: [Sd= cc-user]=20 help with timer
 

Hi all I would like to know if some one could help me. I am work= ing=20 with a home alarm system and I need to run a function for 30 sec to= check=20 if the right code has been inputed. I am using AT89C52 with 11.059=20 crystal. I am programming in c.



Do you Yahoo!?
Yahoo!=20 Platinum - Watch CBS' NCAA March Madness, live=20 on your desktop!=20
 
=09 =09 =09 =09 =09 =09 =09
____________________________________________________
  IncrediMail - Email has finally evolved -=20
Click=20 Here
--------------Boundary-00=_4DGBLVC0000000000000--