The INTCON register contains a Global Interrupt Enable bit (GIE) and also masks for each interrupt source.
T0IE is the mask for Timer 0 overflow
INTE is the mask for the external interrupt
RBIE is the mask for interrupt on PORTB change .
EEIE is the mask for EEPROM write complete interrupt.
In practice, to enable interrupts, you set the masks for whichever interrupt sources to wish to use, and then set GIE.
If you wish to turn off all interrupts then there is a small gotcha. Basically if you just clear GIE, then there is a chance it will be re-enabled by a pending interrupt. You have to clear GIE and then check that it is still clear. Something like:
InterruptsOff
bcf INTCON,GIE
btfsc INTCON,GIE
goto InterruptsOff
Once you have turned interrupts on, they shouldn't turn themselves off so there's no need to re-enable them.
In your interrupt routine, starting at address 0x04, you should check the interrupt flags T0IF,INTF,RBIF,EEIF to check which source has caused the interrupt. You should then clear that flag for the next time.
Hope that helps
Mike
-----Original Message-----
From: Andrew T Kelley [SMTP:k_andrew@JUNO.COM]
Sent: Tuesday, February 29, 2000 12:32 PM
To: PICLIST@MITVMA.MIT.EDU
Subject: Interrupts and Sleep
Hello
Could someone tell me how to turn on interrupts and when to turn them
back on (if needed) in a 16f84?
I need it to wake up a project from zzzz's.
Thanks,
Andrew K.
A.R.S. N1YEW
PS: the device the pic is used in is a laser (!) communicator.( it uses
morse code(aka CW) not voice )(the pic generates the 'dits' and 'dahs'
________________________________________________________________
YOU'RE PAYING TOO MUCH FOR THE INTERNET!
Juno now offers FREE Internet Access!
Try it today - there's no risk! For your FREE software, visit:
http://dl.www.juno.com/get/tagj.