On Sun, Jul 07, 2013 at 07:00:19AM +0800, Electronic Consultation wrote: > Then how can I reduce it if there interrupt without using decrement ? Why would you not use decrement? What I said was that you cannot decrement it because you set it as a constant. Once it's declared as a variable, you can use decrement on it. BAJ > thanks > On 7/07/2013 12:16 AM, Byron Jeff wrote: > > On Sat, Jul 06, 2013 at 10:03:27PM +0800, Electronic Consultation wrote= : > >> after > >> LedTimer RES 1 > >> > >> How can I set it to 20 decimal ? > > Exactly the same way you did it with COUNT: > > > > MOVLW .20 ; Note I normally change my default Radix to decimal > > MOVWF LedTimer > > > >> thanks > >> On 6/07/2013 9:42 PM, Byron Jeff wrote: > >>> On Sat, Jul 06, 2013 at 07:08:16PM +0800, Electronic Consultation wro= te: > >>>> Guys, > >>>> > >>>> I want to reduce LedTimer after interrupt but it returned to 20 agai= n > >>>> after interrupt, > >>>> Do you have idea how handle it ? > >>> The Equate (EQU) you have below fixes the value of LedTimer to 20. Si= nce > >>> you were moving it to COUNT, I figured you wanted a constant 20 count= s to > >>> count down in COUNT (which I do not see a definition for). > >>> > >>> Your code uses the RES directive to declare variables. If you want Le= dTimer > >>> to change, then it needs to be a variable too. > >>> > >>> BAJ > >>> > >>>> thanks > >>>> [CODE]LedTimer EQU .20 ;10 decimal (for content of the counter to ge= t 100ms) > >>>> > >>>> led_state_1 > >>>> bcf INTCON,T0IF ;clear the interr= upt flag > >>>> bsf PORTB, POWERLED ;Turn on LED > >>>> movlw LedTimer > >>>> movwf COUNT > >>>> > >>>> > >>>> ;counting > >>>> > >>>> check_counter > >>>> btfss INTCON,T0IF > >>>> goto check_counter > >>>> > >>>> > >>>> sublw .1 > >>>> btfss STATUS, Z ;Is the result 0, cle= ar COUNT > >>>> > >>>> > >>>> goto check_counter ;if false check the COUNTER ag= ain > >>>> goto next_state ;if true go to this= statement > >>>> > >>>> > >>>> > >>>> next_state > >>>> clrf COUNT ;if false go to thi= s > >>>> statement > >>>> incf LedState,1 ; if 00 increas= e the > >>>> state, for the next state > >>>> > >>>> return[/CODE] > >>>> --=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 > >> --=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 >=20 > --=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 --=20 Byron A. Jeff Chair: Department of Computer Science and Information Technology College of Information and Mathematical Sciences Clayton State University http://faculty.clayton.edu/bjeff --=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 .