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 variable type

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



Joined: 05 May 2015
Posts: 47

View user's profile Send private message Send e-mail

Interrupt variable type
PostPosted: Wed May 20, 2020 7:52 am     Reply with quote

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: 9225
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Wed May 20, 2020 8:00 am     Reply with quote

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

View user's profile Send private message Send e-mail

PostPosted: Wed May 20, 2020 8:19 am     Reply with quote

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: 9225
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Wed May 20, 2020 9:34 am     Reply with quote

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: 1345

View user's profile Send private message

PostPosted: Wed May 20, 2020 10:35 am     Reply with quote

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: 9225
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Wed May 20, 2020 5:39 pm     Reply with quote

there are NO _bifs in the PIC18F46K22.h file tha I use....
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed May 20, 2020 7:20 pm     Reply with quote

You're using an old compiler version.
jeremiah



Joined: 20 Jul 2010
Posts: 1345

View user's profile Send private message

PostPosted: Wed May 20, 2020 7:38 pm     Reply with quote

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: 9225
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Thu May 21, 2020 4:23 am     Reply with quote

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 !
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