On 4/07/2013 4:17 AM, Byron Jeff wrote: > The interrupt handler is perfectly capable of doing the counting for > you. Do you need a task that changes faster that 1S? If not, then there i= s > no need for counting anything in the main loop. > > I think your perceptual problem is that you are thinking of a system that > remains in a physical location of code for a certain amount of time as > opposed to an event/trigger based system that monitors a series of trigge= rs > and does an action when the trigger fires. When organized this way the ma= in > loop can handle several tasks that are triggered by different events. That's right, I still can not see if there's tick in the background, How can I use it, is it related with T0IF, yup I need the main loop to=20 handle several tasks controlled by interrupt. I have created : on main : led_state_1 bsf PORTB, POWERLED ;Turn on LED incf LedState,1 movlw LedTimer ;load the content of=20 LedTimer movwf COUNT_TIMER ;load the LedTimer into=20 file register ;if COUNT_TIMER equal to 0 jump to the next state return is it like this on timer ? ;....... 1ms timer counter here..... clrf TMR0 ;Clear TMR0 and prescaler banksel TMR0 movlw 0xB2 ;Count=3DB2 movwf TMR0 timer1ms movf LedTimer,f btfsc STATUS,Z decf LedTimer,Z return ;.................................... incf COUNT, f movlw .10 ;Compare count to 10 decimal subwf COUNT, W ;Store the result back in btfss STATUS, C ;Is the result 0, skip if no goto exittimer clrf COUNT ;Clear count register Please correct me , thank you... --=20 http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist .