View previous topic :: View next topic |
Author |
Message |
E_Blue
Joined: 13 Apr 2011 Posts: 417
|
Can I have separate handle for every IOC? |
Posted: Fri Nov 03, 2017 1:38 pm |
|
|
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: 19546
|
|
Posted: Fri Nov 03, 2017 3:27 pm |
|
|
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: 417
|
|
Posted: Mon Nov 06, 2017 7:56 am |
|
|
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: 19546
|
|
Posted: Mon Nov 06, 2017 10:27 am |
|
|
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. |
|
|
|