Hi ! A few things... Where do you clear INTF ? Should/could be done just before re-setting INTE and GIE. See data sheet, page 63, section 9.4.1, lines 6-8. (Use "goto label" instead of "goto $-3" so we don't have to count instructions...) Jan-Erik. > -----Original Message----- > From: pic microcontroller discussion list > [mailto:PICLIST@MITVMA.MIT.EDU]On Behalf Of John and Anne Duncan > Sent: den 23 april 2004 06:18 > To: PICLIST@MITVMA.MIT.EDU > Subject: [PIC]: PIC12F675 and INTF > > > Hello, > > I have been working on my first project using a PIC12F675. This is a > low powered battery operated device that should stay in sleep > mode until > woken up by a button press to do it's thing. > > I am using INTF to wake up from sleep. I have followed the manual and > ensured that the comparator is off and that the ADC is switched off. > However the interrupt doesn't behave as I expect it should. > as soon as > GIE is set, execution branches to the ISR, even though there > has been no > +ve going edge to trigger the interrupt. GPIO2 is tied low > until it is > pulled high by the press button. > > The test code below shows how I have initially set up the GPIO pins in > the 'main' routine. I would expect that GPIO0 would toggle until the > switch is pressed but instead GPIO1 will toggle. It appears however > that the ' > 'bsf GPIO, 0' statement after GIE is executed, as GPIO, 0 goes high > before the ISR is executed. > > Perhaps I am missing something in my GPIO initialization?? Any help > would be greatly appreciated. > > John > > ;============================================================= > ================= > ; intf_test.asm -- > ; Bare bones quick test to see why INTF doesn't work properly in > vibeclock.asm > ; > ;============================================================= > ================= > list p=12f675 > include "p12f675.inc" > __idlocs 0x6789 > __config _MCLRE_OFF & _BODEN_OFF & _CP_OFF & _PWRTE_ON & > _WDT_OFF & _INTRC_OSC_NOCLKOUT > > > messg "INTF Test" > > org 0x00 > goto main > > org 0x04 > > bsf GPIO, 1 > nop > bcf GPIO, 1 > goto $-3 > > main > ;; Initialize I/O pins > clrf GPIO > > ;; Turn comparator OFF > movlw 0x07 > movwf CMCON > > ;; Switch to Bank 1 to initialize registers in that bank > bsf STATUS, RP0 > > ;; Ensure ALL inputs are digital inputs initially > clrf ANSEL > > ;; Initialize TRISIO > movlw b'11111100' > movwf TRISIO > > ;; Initialize OPTION_REG > movlw b'11011111' > movwf OPTION_REG > > > bcf STATUS, RP0 ;Bank 0 > > bsf INTCON, INTE > bsf INTCON, GIE > > bsf GPIO, 0 > nop > bcf GPIO, 0 > goto $-3 > > end > > -- > http://www.piclist.com hint: The PICList is archived three different > ways. See http://www.piclist.com/#archives for details. -- http://www.piclist.com hint: The PICList is archived three different ways. See http://www.piclist.com/#archives for details.