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 support@ccsinfo.com

Can I have separate handle for every IOC?

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



Joined: 13 Apr 2011
Posts: 403

View user's profile Send private message

Can I have separate handle for every IOC?
PostPosted: Fri Nov 03, 2017 1:38 pm     Reply with quote

I'm working on a PIC16F1826 and have an IOC activated in RB2 and RB4.

There's any way to declare separated routines to handle them separately?

I tried to use INT_IOC_B2 or INT_IOC_B2_H2L and doesn't compile so I put all the code in a single routine but I don't know if the compiler will clean the proper IOCF so I do it by my self.

Is this ok?

Code:
#INT_IOC
void B2_ISR()
{
   if(interrupt_active(INT_IOC_B4))
   {
      RecTimeVariables();
      clear_interrupt(INT_IOC_B4);
   }
   else if(interrupt_active(INT_IOC_B2))
   {
      if(Mode!=ShuttingDown)
      {
         if(SM1_Count<0xFFFF)
         {
            SM1_Count++;
         }   
      }
      else
      {
         SM1_Count=0;
      }
      clear_interrupt(INT_IOC_B2);
   }   
}

_________________
Electric Blue
Ttelmah



Joined: 11 Mar 2010
Posts: 19195

View user's profile Send private message

PostPosted: Fri Nov 03, 2017 3:27 pm     Reply with quote

No.
You just have to separate them yourself.

There is only one IOC. Single interrupt, but different bits get set in the IOC register.
So all you do is test the bits, and call your required routines.
This is what you are doing.

The INT_IOC_xx settings, set the masks to enable the particular sources to trigger the interrupt, but since only one interrupt actually exists, you can't have separate handlers.

If you look at PCM_programmers example at the end of this thread:
<http://www.ccsinfo.com/forum/viewtopic.php?t=56676>
he shows how to clear the IOCAF register as a single operation.
E_Blue



Joined: 13 Apr 2011
Posts: 403

View user's profile Send private message

PostPosted: Mon Nov 06, 2017 7:56 am     Reply with quote

Ok, so, the compiler will clean only the main IOC and I should check and clean the proper IOCF.

Thanks!
_________________
Electric Blue
Ttelmah



Joined: 11 Mar 2010
Posts: 19195

View user's profile Send private message

PostPosted: Mon Nov 06, 2017 10:27 am     Reply with quote

Answer depends on the compiler version. On recent compilers, the test and clear will work as you show. On older compilers the compiler only set the masks, it couldn't clear and test the bits like this. I'd hate to say 'when' it started working, but it was well after V5 launched.
Even where it does work, being able to clear 'all' in one operation is much quicker.
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