dsPIC interrupts and xc16 compiler

Discussion in 'Embedded Systems and Microcontrollers' started by odm4286, Sep 12, 2015.

  1. odm4286

    Thread Starter Active Member

    Sep 20, 2009
    155
    5
    Hello all, played around with interrupts for the first time and I have a question. I'm having a little trouble/curiosity with how ISR are assigned. Here is my interrupt routine(I know I broke some rules here, calling functions from within, etc etc)
    Code (C):
    1.  
    2.  
    3. void __attribute__ (( __interrupt__ )) _ADCInterrupt (void)
    4. {
    5.     sprintf(data, "%d", ADCBUF0);
    6.     IFS0bits.ADIF = 0;                                  // clear interrupt flag
    7. }
    8.  
    9.  
    Now see where it says _ADCInterrupt? Well, the dsPIC3014 datasheet lists 0x00002E as the IVT for this peripheral. Is it possible to use this address somehow? That way I'm not always dependent on a compiler specific constant? Also, I've searched around in the xc16 datasheet and can't seem to find a list of interrupt constants...

    So any explanation would be greatly appreciated, I'm understanding the theory of interrupts so far I just wish I knew more about how they are assigned.
     
    Last edited: Sep 12, 2015
  2. shteii01

    AAC Fanatic!

    Feb 19, 2010
    3,377
    494
    I would think it would be in the pic datasheet.
     
  3. odm4286

    Thread Starter Active Member

    Sep 20, 2009
    155
    5
    The datasheet has a list of memory addresses, but not the actually constants the compiler uses to assign ISR's to a specific peripheral interrupt. You can't use a memory address in place of the constant _ADCInterrupt, at least not on my compiler
     
  4. dannyf

    Well-Known Member

    Sep 13, 2015
    1,767
    357
    Constants like _T1Interrupt is automatically resolved in the corresponding .gld files.

    Code (Text):
    1. That way I'm not always dependent on a compiler specific constant?
    It is always more desirable to use the compiler-dependent names, vs. some magic numbers you may put there - the addresses may change from device to device and it is much harder to remember that _T1Interrupt() is a timer1 interrupt, rather than 0x00002E.
     
    ErnieM likes this.
Loading...