> From: John and Anne Duncan[SMTP:duncans@GIL.COM.AU] > Sent: Friday, April 23, 2004 12:18 AM > 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. The INTF flag in INTCON is supposed to be set to zero at power up, but try setting it to zero anyway (before setting GIE). > GPIO2 is tied low until it is > pulled high by the press button. Your code does not have a SLEEP instruction, so it will power up in running mode. > 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. GPIO,0 will continuously toggle until the interrupt is triggered. You should expect that it will show some activity before that. > 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 > ; <== try clearing INTF flag in INTCON > bsf INTCON, INTE > bsf INTCON, GIE > ; <== where is SLEEP? . bsf GPIO, 0 > nop > bcf GPIO, 0 > goto $-3 > > end John Power -- http://www.piclist.com hint: The PICList is archived three different ways. See http://www.piclist.com/#archives for details.