CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

PIC12F629 interrupt on change

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
test153



Joined: 09 Feb 2009
Posts: 28

View user's profile Send private message

PIC12F629 interrupt on change
PostPosted: Tue Mar 24, 2009 2:46 am     Reply with quote

How do I properly enable interrupt on change for GP3 on the 12F629?
ECACE



Joined: 24 Jul 2006
Posts: 94

View user's profile Send private message

PostPosted: Tue Mar 24, 2009 11:35 am     Reply with quote

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!!!
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Mar 24, 2009 11:40 am     Reply with quote

Here are some threads on this topic:
http://www.ccsinfo.com/forum/viewtopic.php?t=32702
http://www.ccsinfo.com/forum/viewtopic.php?t=37574
http://www.ccsinfo.com/forum/viewtopic.php?t=25589
test153



Joined: 09 Feb 2009
Posts: 28

View user's profile Send private message

PostPosted: Tue Mar 24, 2009 11:55 am     Reply with quote

Would something like
Code:
 enable_interrupts(INT_RA3);
work to only enable interrupt on GP3?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Mar 24, 2009 12:05 pm     Reply with quote

Look in the 12F629 data sheet:
http://ww1.microchip.com/downloads/en/DeviceDoc/41190E.pdf
Look in this section:
Quote:
3.2.2 INTERRUPT-ON-CHANGE
REGISTER 3-4: IOC — INTERRUPT-ON-CHANGE GPIO REGISTER

It shows that individual pins can be enabled/disabled for interrupt on change.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2005 phpBB Group