Hi everyone, Need some help on the source code below. Basically i need to implement a counter using the Timer0. I am using a 16F84A and i disabled the watchdog. I am assigning the ratio 1:256 for the prescaler and i am using additional 2 counters. ; source codes MAIN < some operation > bank1 bsf OPTREG,RBPU bsf OPTREG,INTEDG bcf INTCON,INTF bsf INTCON,INTE bsf INTCON,GIE LOOP sleep ; let IRQ wake it up and determine functions nop clrwdt ; initialisation of Timer0 bank1 bcf OPTREG,PSA bcf OPTREG,TOCS bsf OPTREG,PS2 bsf OPTREG,PS1 bsf OPTREG,PS0 goto DATA_RECEIVE FINISH goto LOOP ; go back to sleep and wait for the next INT DATA_RECEIVE clrf timer2 clrf timer3 DV_HIGH bank0 btfss PORTB,DV ; TEST FOR THE DV ( / Data Valid ) goto DV_LOW ; if Low, then Data Valid True, branch out btfss INTCON,TOIF ; if not,check if TMRO overflow goto DV_HIGH ; no overflow, check DV again bcf INTCON,TOIF ; got overflow, reset the TOIF incf timer2 ; increment timer2 counter btfss STATUS,C ; check if timer2 overflow goto DV_HIGH ; timer2 no overflow, check DV again clrf timer2 ; timer2 overflow, reset timer2 incf timer3 ; increment timer3 counter movf timer3,W sublw H'0A' ; btfss STATUS,Z ; check for timer3 = 10 goto DV_HIGH ; timer3 less than 10, continue check DV goto LOOP ; timer3 = 10, stop checking DV ; go back sleep The accuracy of the time is not important. and based on a rough calculation the duration that i can wait for DV ( Data Valid ) to go LOW is around time for TMRO to overflow (1 / 2.5MHz) x 256 x 255 = 0.02611 sec time for timer2 to overflow 0.02611 sec x 255 = 6.658 sec time for timer3 to overflow ( the whole duration ) 6.658 sec x 10 = 66.58 sec What i am trying to do is to have a counter so that if the DV does not goes LOW after around 1 min. , i stop polling for DV and return to sleep. actually the DV is some sort of user response. is there anything wrong with my code? One last question, can i just simply reset the TMR0 flag as and when i like it? and when the overflow occurs, the timer will still continue running right? Thanks for reading. _________________________________________________________________________ Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com. -- http://www.piclist.com hint: To leave the PICList mailto:piclist-unsubscribe-request@mitvma.mit.edu