Hi everyone, I'm in need of some help with a program I'm trying to put together. I'm still a newbie here so this is just something I'm putting together as a learning exercise and hopefully I'm just missing something obvious. Please note that the following is a cut down version of something much larger that I'm putting together. I've cut it down to the minimal version that I can that exhibits the behaviour I'm seeing. I have a circuit with one LED (connected to PORTB,2) and a push button switch (push-to-make) on PORTB,0. I have an interrupt service routine which wakes up when the timer expires. The ISR checks a register which I've named SEQ and if it is set to 1 it turns the LED on, if it is set to 2 it turns the LED off. Meanwhile, in the main program it loops around waiting for the pin that the push button is connected to going low. At that point it changes SEQ from 1 to 2 and then goes into and idle loop. So, the program should start and light the LED by default. When I press the button for the first time the LED should go out and stay out until the system is reset. However, the LED just comes on and stays on. Here is the code: ---------- list P=16F84A include "p16f84a.inc" LEDR1 equ 10h SEQ equ 17h org 0 goto Start Init clrf PORTA clrf PORTB goto InitCont goto ISR ; MUST BE INSTRUCTION 0x04 InitCont bsf STATUS,5 ; Select bank 1 movlw b'0000' movwf TRISA movlw b'00000001' ; Push button is connected to PORTB,0 movwf TRISB ; LED is connected to PORTB,2 movlw b'00000111' ; 1:256 pre-scaler on TMR0 movwf OPTION_REG bcf STATUS,5 ; Select bank 0 movlw b'10100000' ; Enable timer interrupts movwf INTCON clrf LEDR1 movlw d'1' movwf SEQ retlw 0 ISR clrwdt bcf INTCON,3 ; Reset timer interrupt movlw d'1' ; Subtract 1 from sequence number to subwf SEQ,w ; make it zero based addwf PCL,f goto Sequence1 goto Sequence2 Sequence1 movlw b'01111110' ; Set LED pins high movwf LEDR1 goto RefreshLEDs Sequence2 movlw b'00000000' ; Set LED pins low movwf LEDR1 goto RefreshLEDs RefreshLEDs movfw LEDR1 movwf PORTB retfie Start call Init Main clrwdt btfsc PORTB,0 goto Main movlw d'2' movwf SEQ Done clrwdt goto Done END ----------- I'm pretty happy that the circuit is ok as I have a simpler program (not using interrupts, timers etc) which just turns the LED on whilst the push button is held down and that works fine in the same circuit. I can post that program or more details of the circuit if it helps. Thanks, and sorry for the longish post, Matt -- Matt N. Marsh Email: matt@mattmarsh.net Yahoo: marshmn Web: http://www.mattmarsh.net/ Jabber: mattmarsh@jabber.org MSN: matt@mattmarsh.net ICQ: 250467363 AIM: MattMarshUK -- http://www.piclist.com#nomail Going offline? Don't AutoReply us! email listserv@mitvma.mit.edu with SET PICList DIGEST in the body