Imre, I'm not currently running a watchdog, I didn't want it to mask any problems that may occur (comments on this approach welcome), I've tried disabling the Brownout detect bit, and I doubt EMI(though I will include a little diagram of the switch buffering for all to look at. switch circuit: ---Vcc | [10k] | o---|-------|---[1K]---PORTB, 6 | | ===0.1uF V 5V transorb | --- | | o---|-------|---Gnd hope this comes out, notes on code: I have two LEDs on PORTC, 4 and 5 two switches buffered as above on PORTB, 6 and 7 muxes for more I/O on PORTS A and C this is stripped down code to try and isolate the problem, with a lot of stuff added to the ISR to clock registers out the LEDs (I use a DSO to catch the data) code: ; This is to test the serial output of the PIC list p=16f873 include "p16F873.inc" ; Constants ESC equ 0x1b ACK equ 0x06 CR equ 0x0d SW1EN equ 0x00 ; PORT C SW2EN equ 0x05 ; PORT A SW3EN equ 0x02 ; PORT C SW4EN equ 0x03 ; PORT C SW_SEL1 equ 0x01 ; PORT A SW_SEL2 equ 0x02 ; PORT A SW_SEL3 equ 0x03 ; PORT A SW_DATA equ 0x00 ; PORT A ;Variables ***************************************** delaycounter equ 0x20 delaycounter2 equ 0x21 delaycounter3 equ 0x22 delaycounter_ms equ 0x29 switch equ 0x25 setup_switch equ 0x26 dip_switch equ 0x27 denom equ 0x28 module_number_hi equ 0x30 module_number_lo equ 0x31 temp_w equ 0x23 temp_status equ 0x24 led_flasher equ 32 led_flasher2 equ 33 led_flasher3 equ 34 serial_buffer equ 0x40 ORG 0x000 clrf PCLATH goto start__code ORG 4 _interrupt movwf temp_w swapf STATUS, W clrf STATUS movwf temp_status movlw A'I' movlw B'00100000' movf INTCON, W movlw 0x50 bsf PORTC, 4 bsf PORTC, 5 ; call delayWms nop nop nop bcf PORTC, 4 nop nop nop bcf PORTC, 5 bsf PORTC, 4 btfsc PIE1, 0 bsf PORTC, 5 movlw 0x50 ; call delayWms nop nop nop bcf PORTC, 4 nop nop nop bcf PORTC, 5 bsf PORTC, 4 btfsc PIE1, 1 bsf PORTC, 5 movlw 0x50 ; call delayWms nop nop nop bcf PORTC, 4 nop nop nop bcf PORTC, 5 bsf PORTC, 4 btfsc PIE1, 2 bsf PORTC, 5 movlw 0x50 ; call delayWms nop nop nop bcf PORTC, 4 nop nop nop bcf PORTC, 5 bsf PORTC, 4 btfsc PIE1, 3 bsf PORTC, 5 movlw 0x50 ; call delayWms nop nop nop bcf PORTC, 4 nop nop nop bcf PORTC, 5 bsf PORTC, 4 btfsc PIE1, 4 bsf PORTC, 5 movlw 0x50 ; call delayWms nop nop nop bcf PORTC, 4 nop nop nop bcf PORTC, 5 bsf PORTC, 4 btfsc PIE1, 5 bsf PORTC, 5 movlw 0x50 ; call delayWms nop nop nop bcf PORTC, 4 nop nop nop bcf PORTC, 5 bsf PORTC, 4 btfsc PIE1, 6 bsf PORTC, 5 movlw 0x50 ; call delayWms nop nop nop bcf PORTC, 4 nop nop nop bcf PORTC, 5 bsf PORTC, 4 btfsc PIE1, 7 bsf PORTC, 5 movlw 0x50 ; call delayWms nop nop nop bcf PORTC, 4 nop nop nop bsf PORTC, 4 bsf PORTC, 5 movlw 0x50 ; call delayWms nop nop nop nop nop nop bcf PORTC, 5 ; btfsc STATUS, Z ; bsf PORTC, 5 ; xorwf PORTC, F ; clrf INTCON ; clrf PIR1 ; clrf PIE1 ; bsf PORTC, 5 ; movwf TXREG ; banksel TXSTA ;tx_wait3 ; btfss TXSTA, TRMT ; goto tx_wait3 ; movlw 0x30 ; movwf delaycounter ;tx_wait4 ; decfsz delaycounter, F ; goto tx_wait4 ; banksel TXREG ; bcf PORTC, 5 ; Disable CTS ; call tx_w ; movlw B'00010000' ; xorwf PORTC, 1 ; bsf PORTC, 4 ; btfsc PIR1, RCIF ; call rx_data ; clrf PIR1 bcf INTCON, T0IF ;clear interrupt flag swapf temp_status, W movwf STATUS swapf temp_w, F swapf temp_w, W retfie start__code _main__code initialisation banksel TRISC movlw B'00000001' ; init PORTA movwf TRISA movlw 0x06 movwf ADCON1 movlw 0xff ; init PORTB movwf TRISB movlw B'11000010' ; init PORTC movwf TRISC movlw 0x0a ; init Baud Rate 19200 movwf SPBRG bsf TXSTA, CSRC bsf TXSTA, TXEN bsf TXSTA, BRGH ; movlw B'00100000' ; Enable RX interupt ; movwf PIE1 ; bsf PIE1, RCIE clrf PIE1 banksel RCSTA bsf RCSTA, SPEN bsf RCSTA, CREN ; bsf PORTC, 5 // Enable CTS ; movlw B'11001000' ; movwf INTCON clrf INTCON clrf PORTC movf RCREG, W movf RCREG, W movlw B'00100000' movwf PORTA movlw B'00001101' movwf PORTC movlw serial_buffer movwf FSR label_0001 ; movlw B'00010000' ; xorwf PORTC, F ; movlw 0x30 ; call tx_w ; movlw 0xff ; call delayWms btfss PORTB, 6 goto debounce_read ; movlw 0x31 ; call tx_w goto label_0001 debounce_read clrf delaycounter clrf delaycounter2 debounce_wait_read decfsz delaycounter, F goto debounce_wait_read decfsz delaycounter2, F goto debounce_wait_read btfss PORTB, 6 goto read_mode goto label_0001 read_mode movlw B'00010000' xorwf PORTC, F ; movlw 0x30 ; call tx_w movlw 0xff call delayWms ; movlw 0x30 ; call tx_w goto label_0001 ----- Original Message ----- From: "Dr. Imre Bartfai" To: Sent: Saturday, 23 September 2000 8:34 Subject: Re: PIC16F873 interrupts when disabled (fwd) > Hi, > I see at this moment only one possible cause: the processor does a reset > somehow after 1st press (previous word reset is a typo; sorry). Maybe a > watchdog or an EMI problem? > > Regards, > Imre > > > On Fri, 22 Sep 2000, Carl Rouse wrote: > > > Hi all, > > got a bit of an annoying problem. > > > > I've cleared INTCON, and therefore GIE, so interupts should be disabled. > > Yet, when I press a switch on PORTB, 6 the first time it behaves as it > > should, but the second and subsequent times result in a jump to the > > interrupt handling routine at 0x004. > > I've added a routine to send data out about the state of certain registers > > to the interrupt handling routine and INTCON is > > '00000000' on the second press (first jump to 0x004), > > '10000000' on third press (second jump to 0x004). > > RETFIE sets GIE on execution, so that is why GIE is set on the second > > interrupt call, but GIE is '0' when the first jump to 0x004 is made. > > PIR1 is '00010000' which is TXREG is empty > > PIR2 is '00000000' > > > > Has anyone out there come across something like this before? > > Does anyone have any ideas on what I can look at? > > > > Thanks, > > -Carl > > > > -- > > http://www.piclist.com#nomail Going offline? Don't AutoReply us! > > use mailto:listserv@mitvma.mit.edu?body=SET%20PICList%20DIGEST > > > > > > > > > > -- > http://www.piclist.com hint: To leave the PICList > mailto:piclist-unsubscribe-request@mitvma.mit.edu > > > -- http://www.piclist.com hint: The list server can filter out subtopics (like ads or off topics) for you. See http://www.piclist.com/#topics