> 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. Just a guess, but it doesn't look like you are clearing the interrupt flag before enabling interrupts. Remember, an interrupt flag will change irrespective of whether or not interrupts are enabled, so, if during powerup or some other time, if that pin "detects" the interrupt event it's set for it'll set the flag, whether or not you've actually enabled the interrupt or not. Have you put this code through simulation to see how it behaves? Thanks, TTYL ---------------------------------- Herbert's PIC Stuff: http://repatch.dyndns.org:8383/pic_stuff/ -- http://www.piclist.com hint: The PICList is archived three different ways. See http://www.piclist.com/#archives for details.