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

interrupt_active and INT_RA0...

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



Joined: 09 Mar 2010
Posts: 314
Location: Denmark

View user's profile Send private message

interrupt_active and INT_RA0...
PostPosted: Sun Apr 12, 2015 1:04 pm     Reply with quote

Hi

Compiler 5.044 / PIC:16F1825

When using interrupt on change, and use more then one, I test for the right one in the interrupt. The interrupt_active(INT_RA0); return wrong.

Is it me or the compiler?

Test code:
Code:

#include "16F1825.h"

/*All is test code for understand what is going on*/


#INT_RA
void intra(void){
int1 bit;

bit=interrupt_active(INT_RA0); //LOOK in lst

bit=interrupt_active(INT_RA1); //LOOK in lst.
}

void main(void){
enable_interrupts(INT_RA0);
enable_interrupts(INT_RA0_L2H);
enable_interrupts(INT_RA0_H2L);

enable_interrupts(INT_RA1);
enable_interrupts(INT_RA1_L2H);
enable_interrupts(INT_RA1_H2L);
}



List file MAIN section (Look OK):
Code:

.................... enable_interrupts(INT_RA0);
0034:  BSF    INTCON.IOCIE
0035:  MOVLB  07
0036:  BSF    IOCAP.0
0037:  BSF    IOCAN.0
.................... enable_interrupts(INT_RA0_L2H);
0038:  BSF    INTCON.IOCIE
0039:  BSF    IOCAP.0
003A:  BCF    IOCAN.0
.................... enable_interrupts(INT_RA0_H2L);
003B:  BSF    INTCON.IOCIE
003C:  BSF    IOCAN.0
003D:  BCF    IOCAP.0
.................... 
.................... enable_interrupts(INT_RA1);
003E:  BSF    INTCON.IOCIE
003F:  BSF    IOCAP.1
0040:  BSF    IOCAN.1
.................... enable_interrupts(INT_RA1_L2H);
0041:  BSF    INTCON.IOCIE
0042:  BSF    IOCAP.1
0043:  BCF    IOCAN.1
.................... enable_interrupts(INT_RA1_H2L);
0044:  BSF    INTCON.IOCIE
0045:  BSF    IOCAN.1
0046:  BCF    IOCAP.1



List interrupt:
Code:

.................... #INT_RA
.................... void intra(void){
.................... int1 bit;
.................... 
.................... bit=interrupt_active(INT_RA0);
001E:  BCF    24.0
001F:  BTFSC  INTCON.IOCIF --> I expect IOCAF0
0020:  BSF    bit
.................... 
.................... bit=interrupt_active(INT_RA1);
0021:  BCF    24.0
0022:  BTFSC  INTCON.IOCIF --> I expect IOCAF1
0023:  BSF    bit
-----
0024:  MOVLW  FF
0025:  MOVLB  07
0026:  XORWF  IOCAF,W
0027:  ANDWF  IOCAF,F
0028:  BCF    INTCON.IOCIF
0029:  MOVLP  00
002A:  MOVLB  00
002B:  GOTO   013
.................... }
Ttelmah



Joined: 11 Mar 2010
Posts: 19499

View user's profile Send private message

PostPosted: Sun Apr 12, 2015 2:29 pm     Reply with quote

Interrupt_active, only tests physical interrupts. The physical interrupt is INT_RA.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Apr 12, 2015 2:38 pm     Reply with quote

Here is something you could use. Add this little macro above your isr.
Code:

#byte IOCAF = getenv("SFR:IOCAF")
#define ioca_active(x)  (IOCAF & make8(x, 2))

#INT_RA
void intra(void){
int1 bit;

bit = ioca_active(INT_RA0);

bit= ioca_active(INT_RA1); 
}


It generates this code:
Code:

.................... bit = ioca_active(INT_RA0); 
001E:  MOVLB  07
001F:  MOVF   IOCAF,W  // Read IOCAF
0020:  ANDLW  01       // Mask it with 0x01 to test IOCAF0 bit
0021:  MOVWF  @78      // Save result in temp reg (ram)
0022:  MOVLB  00   
0023:  BCF    25.0     // Initialize bit = 0
0024:  BTFSC  @78.0    // Test state of ioc flag bit.
0025:  BSF    bit      // If ioc flag = 1, set bit = 1
.................... 
.................... bit= ioca_active(INT_RA1);   
0026:  MOVLB  07
0027:  MOVF   IOCAF,W
0028:  ANDLW  02      // Mask is 0x02 for int_ra1
0029:  MOVWF  @78
002A:  MOVLB  00
002B:  BCF    25.0
002C:  BTFSC  @78.0
002D:  BSF    bit
hmmpic



Joined: 09 Mar 2010
Posts: 314
Location: Denmark

View user's profile Send private message

PostPosted: Sun Apr 12, 2015 2:56 pm     Reply with quote

Hi

Many CCS special features are not that easy to figure, without testing them first ...

Thanks both of you.
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