How do I properly enable interrupt on change for GP3 on the 12F629?
ECACE
Joined: 24 Jul 2006 Posts: 94
Posted: Tue Mar 24, 2009 11:35 am
First off, you have to turn off the MCLR function of that pin. This is done in the fuses section. I have ****** next to the line. Next, you enable the interupt for that function. You can't have it interupt just for that pin, it is for the port. But in the ISR, you can just look at the pin you are interested in. See code below:
Code:
#include <12F629.h>
#FUSES NOWDT //No Watch Dog Timer
#FUSES INTRC //Internal RC Osc
#FUSES NOCPD //No EE protection
#FUSES NOPROTECT //Code not protected from reading
#FUSES NOMCLR //Master Clear pin used for I/O *************
#FUSES PUT //Power Up Timer
#FUSES BROWNOUT //Reset when brownout detected
#FUSES BANDGAP_HIGH
#use delay(clock=8000000)
#int_RA
void RA_isr(void)
{
//This will be your port change interupt ISR
//When a change is detected on Port A you will end up here
//You will then have to poll Port A to see what changed from the last time youwere here.
//Then save the current Port settings in a temp var
//Next time you come in, you compare against that temp var
//to determine what changed.
//You can set some flags in the ISR that your main()
//would look at to see if a change has happened.
}
void main()
{
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
setup_timer_1(T1_DISABLED);
setup_comparator(NC_NC);
setup_vref(FALSE);
enable_interrupts(INT_RA); //*****It is enabled here*********
enable_interrupts(GLOBAL);
// TODO: USER CODE!!
}
Good Luck! _________________ A HW Engineer 'trying' to do SW !!! Run!!!
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum