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

12F675 INt RA

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



Joined: 11 Oct 2017
Posts: 144

View user's profile Send private message

12F675 INt RA
PostPosted: Mon Sep 15, 2025 5:06 am     Reply with quote

I'm using a PIC 12F675 and would like to know if I can use #INT_RA and #int_ext each with their own routine.
It seems not, so I combined the routines using #INT_RA.
I use pins A3 and A2.
How can I know which one the event occurred on, and could I use one or the other within the interrupt routine depending on which pin changed state?
One routine is triggered by a zero crossing, and the other is to read an infrared remote control that uses Timer1.

Code:
#include "12f675.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 NOPUT         //No Power Up Timer
#FUSES BROWNOUT      //Reset when brownout detected

#use delay(clock=4000000)

#use   fast_io(a)
...
      setup_adc_ports(NO_ANALOGS|VSS_VDD);
      setup_adc(ADC_OFF);
      setup_comparator(NC_NC_NC_NC);
      setup_vref(FALSE);
    //  SETUP_TIMER_1(T1_INTERNAL|T1_DIV_BY_2);

      set_tris_a(0b00111110);
      port_a_pullups(0b00110010); 
    //  ext_int_edge(L_TO_H);     
     // enable_interrupts(INT_EXT);
      clear_interrupt(INT_RA);
     // enable_interrupts(INT_RA2);
      enable_interrupts(INT_RA2 | INT_RA3);
      enable_interrupts(GLOBAL);
    //  disable_interrupts(INT_TIMER1);
    //  disable_interrupts(INT_TIMER0);

 


If anyone has a better idea, please comment.
I thought about using one pic for infrared and another for zero cross.
Ttelmah



Joined: 11 Mar 2010
Posts: 19944

View user's profile Send private message

PostPosted: Mon Sep 15, 2025 7:52 am     Reply with quote

OK. The INT_RA on this chip is like the INT_RB on most of the similar
small chips. If enabled, the interrupt is triggered when the pin changes.
_Changes_. So this interrupt happens on both the rising and falling
edge of the selected pins. Now unlike the older chips, this chip does have
a mask bit for each pin, and it is this mask the the INT_RA1 etc., control.
There is no ability n this interrupt to know which pin triggered. However
you also cannot clear this interrupt, until a read is done from the
register. So what you have to do is read the pins and decide in your code
which one(s) have changed.
So the big question is do you want interrupts to be on both edges of
any of your signals. If the answer is 'only one', then instead of doing what
you are suggesting, enable INT_EXT instead of RA2 (this is the pin this
interrupt is on), and program it's edge. Then just enable RA3 for INT_RA,
and in the INT_RA handler, read this pin to know which edge has triggered.
You then have a separate enable for INT_EXT, and handler for this.
There are actually three ways of generating signal change interrupts on this
chip@
INT_RA (on any of the I/O pins)
INT_EXT (on RA2), and
INT_COMP (on pin RA1).
The latter can be setup to interrupt when this pin passes the voltage
from the internal DAC. This like INT_RA is on both edges of the change.
The latter two interrupts have the advantage of happening on just a
single pin.

There is an example with the compiler of port B interrupt on change.
vtrx



Joined: 11 Oct 2017
Posts: 144

View user's profile Send private message

PostPosted: Mon Sep 15, 2025 2:00 pm     Reply with quote

I'm going to do some experiments here.
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