| View previous topic :: View next topic   | 
	
	
	
		| Author | 
		Message | 
	
	
		
			sebalitter
 
 
  Joined: 05 May 2015 Posts: 47
  
			
			 
			 
			 
			
			
			
			
			
			
  
		  | 
		
			
				| Interrupt variable type | 
			 
			
				 Posted: Wed May 20, 2020 7:52 am     | 
				     | 
			 
			
				
  | 
			 
			
				Hi 
 
 
what kind of variable should i put to toggle between two INTERRUPT types like  INT_IOC_A3_H2L and INT_IOC_A5_H2L. 
 
 
 
let me explain what i have in mind.
 
 
 	  | Code: | 	 		  
 
 int32 interrupcion = INT_IOC_A3_H2L;
 
 
    if(toggle_sensors_vcc==1){
 
        interrupcion = (int32)INT_IOC_A5_H2L;
 
    }
 
 
 set_timer1(0); // clear timer
 
      
 
 clear_interrupt(interrupcion);   // Error#51  A numeric expression must appear here  :: 
 
 
 cant =0;
 
      
 
      while(!interrupt_active(interrupcion) && cant<4000 ){  //same error here
 
          cant++;
 
      }
 
ticks = get_timer1();
 
 
 | 	  
 
 
thank you | 
			 
		  | 
	
	
		  | 
	
	
		
			temtronic
 
 
  Joined: 01 Jul 2010 Posts: 9589 Location: Greensville,Ontario 
			
			 
			 
			
			
			
			
			
			
			
  
		  | 
		
			
				 | 
			 
			
				 Posted: Wed May 20, 2020 8:00 am     | 
				     | 
			 
			
				
  | 
			 
			
				quick answer...
 
According to the manual the clear_interrupt(...) function requires a CONSTANT not a variable.... so you MUST put the 'name' of the interrupt you're using.
 
The PIC header file will have a list of available interrupts and their names. | 
			 
		  | 
	
	
		  | 
	
	
		
			sebalitter
 
 
  Joined: 05 May 2015 Posts: 47
  
			
			 
			 
			 
			
			
			
			
			
			
  
		  | 
		
			
				 | 
			 
			
				 Posted: Wed May 20, 2020 8:19 am     | 
				     | 
			 
			
				
  | 
			 
			
				 	  | temtronic wrote: | 	 		  quik answer...
 
According to the manual the clear_interrupt(...) function requires a CONSTANT not a variable.... so you MUST put the 'name' of the interrupt you're using.
 
The PIC header file will have a list of available interrupts and their names. | 	  
 
 
Thanks for the answer!
 
 
in the header file it says...
 
 
 	  | Code: | 	 		  
 
_bif void clear_interrupt(int32 interrupt);
 
_bif int1 interrupt_active(int32 interrupt);
 
 | 	  
 
 
But thats fine, so my solution was this one..
 
 
 	  | Code: | 	 		  
 
 
      if(toggle_sensors_vcc) 
 
            clear_interrupt(INT_IOC_A5_H2L);
 
    else
 
        clear_interrupt(INT_IOC_A3_H2L);  //clear  interrupt flag
 
    
 
        cant =0;
 
      // wait for CCP1 interrupt.  CCP1 will interrupt when PIN_ULTRASONIC_ECHO
 
      // goes low due to CCP_CAPTURE_FE passed to setup_ccp1()
 
        
 
        if(toggle_sensors_vcc==1){
 
                while(!interrupt_active(INT_IOC_A5_H2L) && cant<4000 ){
 
                    cant++;
 
                }
 
        }else{
 
                 while(!interrupt_active(INT_IOC_A3_H2L) && cant<4000 ){
 
                    cant++;
 
                }
 
        }
 
 | 	  
 
 
It should be another improved solution for this. please let me know. | 
			 
		  | 
	
	
		  | 
	
	
		
			temtronic
 
 
  Joined: 01 Jul 2010 Posts: 9589 Location: Greensville,Ontario 
			
			 
			 
			
			
			
			
			
			
			
  
		  | 
		
			
				 | 
			 
			
				 Posted: Wed May 20, 2020 9:34 am     | 
				     | 
			 
			
				
  | 
			 
			
				Header files normally have this format ...
 
 	  | Code: | 	 		  
 
// Constants used in ENABLE/DISABLE_INTERRUPTS() are:
 
#define GLOBAL                    0xF2C0
 
#define PERIPH                    0xF240
 
#define INT_RTCC                  0x00F220
 
#define INT_TIMER0                0x00F220
 
#define INT_TIMER1                0x009D01
 
#define INT_TIMER2                0x009D02
 
#define INT_TIMER3                0x00A002
 
#define INT_EXT_L2H               0x5000F210
 
#define INT_EXT_H2L               0x6000F210 | 	  
 
... this is part of the PIC18F46K22.h file | 
			 
		  | 
	
	
		  | 
	
	
		
			jeremiah
 
 
  Joined: 20 Jul 2010 Posts: 1401
  
			
			 
			 
			
			
			
			
			
			
			
  
		  | 
		
			
				 | 
			 
			
				 Posted: Wed May 20, 2020 10:35 am     | 
				     | 
			 
			
				
  | 
			 
			
				 	  | sebalitter wrote: | 	 		   	  | temtronic wrote: | 	 		  quik answer...
 
According to the manual the clear_interrupt(...) function requires a CONSTANT not a variable.... so you MUST put the 'name' of the interrupt you're using.
 
The PIC header file will have a list of available interrupts and their names. | 	  
 
 
Thanks for the answer!
 
 
in the header file it says...
 
 
 	  | Code: | 	 		  
 
_bif void clear_interrupt(int32 interrupt);
 
_bif int1 interrupt_active(int32 interrupt);
 
 | 	  
 
 
 | 	  
 
 
Note that those lines in the header file have the _bif in front of them, that's an annotation meant to indicate that those are just declarations used to help IDE's identify which builtin functions are created by the compiler.  Always check versus the compiler manual as some functions are compile time constant only (and the C language does not provide a way to express that, so the function declaration doesn't help there). | 
			 
		  | 
	
	
		  | 
	
	
		
			temtronic
 
 
  Joined: 01 Jul 2010 Posts: 9589 Location: Greensville,Ontario 
			
			 
			 
			
			
			
			
			
			
			
  
		  | 
		
			
				 | 
			 
			
				 Posted: Wed May 20, 2020 5:39 pm     | 
				     | 
			 
			
				
  | 
			 
			
				| there are NO _bifs in the PIC18F46K22.h file tha I use.... | 
			 
		  | 
	
	
		  | 
	
	
		
			PCM programmer
 
 
  Joined: 06 Sep 2003 Posts: 21708
  
			
			 
			 
			
			
			
			
			
			
			
  
		  | 
		
			
				 | 
			 
			
				 Posted: Wed May 20, 2020 7:20 pm     | 
				     | 
			 
			
				
  | 
			 
			
				| You're using an old compiler version. | 
			 
		  | 
	
	
		  | 
	
	
		
			jeremiah
 
 
  Joined: 20 Jul 2010 Posts: 1401
  
			
			 
			 
			
			
			
			
			
			
			
  
		  | 
		
			
				 | 
			 
			
				 Posted: Wed May 20, 2020 7:38 pm     | 
				     | 
			 
			
				
  | 
			 
			
				 	  | temtronic wrote: | 	 		  | there are NO _bifs in the PIC18F46K22.h file tha I use.... | 	  
 
 
They added it some time ago...I forget when, sometime after MPLABX v2 because it was highlighting all the CCS functions as undefined (with the syntax highlighter). | 
			 
		  | 
	
	
		  | 
	
	
		
			temtronic
 
 
  Joined: 01 Jul 2010 Posts: 9589 Location: Greensville,Ontario 
			
			 
			 
			
			
			
			
			
			
			
  
		  | 
		
			
				 | 
			 
			
				 Posted: Thu May 21, 2020 4:23 am     | 
				     | 
			 
			
				
  | 
			 
			
				re:  	  | Quote: | 	 		  | You're using an old compiler version. | 	  
 
yeah, it's old, I'm old, sigh.....
 
not getting any younger , the older I get
 
great...now I depressed too ! | 
			 
		  | 
	
	
		  | 
	
	
		 |