• AVR Freaks

Hot!Setting up PIC32MM Interrupts

Author
btremaine
Junior Member
  • Total Posts : 59
  • Reward points : 0
  • Joined: 2013/08/17 14:46:34
  • Location: San Jose, CA
  • Status: offline
2019/12/05 09:44:56 (permalink)
0

Setting up PIC32MM Interrupts

I am using application note AN1160 as a basis for some new motor code. I haven't used the PIC32 family before and I am a bit lost on setting up interrupts. I'm using the AN1160 as a guideline to understand the PIC32MM before I make changes. Along with the application note I have the code that was supposedly written for the PIC32MM0064GPL036 (attached).  
 
The application note AN1160 has an ADC ISR set-up with the following starting line:
void __attribute__ ((vector(_ADC_VECTOR), interrupt(IPL7SOFT), micromips)) _ADC1Interrupt(void)
 
This code apparently compiles okay, I have loaded it on a Curiosity board.
 
Is the above code line still correct for XC32? What is the interpretation? What is micromips? IPL7SOFT?
 
If I look at the Microchip online developer help they give an example as:
void __ISR(_CORE_TIMER_VECTOR, IPL2SOFT) CoreTimerHandler(void);
 
Should my line of code be changed to the following ?
void __ISR(_ADC_VECTOR, IPL7SOFT) ADC1Interrupt(void);
 
I did try to replace the line and question and received errors
//void __attribute__ ((vector(_ADC_VECTOR), interrupt(IPL7SOFT), micromips)) _ADC1Interrupt(void)
void__ISR(_ADC1Interrupt, IPL7SOFT) ADC1Interrupt(void);
 
The void_ISR was unresolved. I do have an #include <sys/attribs.h> at the top of the file but the code complains it cannot find the file. What folder should it be in? I see them under a pic32 and pic32mx folder ...
 
Thanks,
Brian
 
 
 
 
post edited by btremaine - 2019/12/05 11:09:50
#1

3 Replies Related Threads

    btremaine
    Junior Member
    • Total Posts : 59
    • Reward points : 0
    • Joined: 2013/08/17 14:46:34
    • Location: San Jose, CA
    • Status: offline
    Re: Setting up PIC32MM Interrupts 2019/12/05 16:27:26 (permalink)
    0
    Answering/updating my own question:
     
    ==========================================================
            I did try to replace the line and question and received errors
           //void __attribute__ ((vector(_ADC_VECTOR), interrupt(IPL7SOFT), micromips)) _ADC1Interrupt(void)
             void__ISR(_ADC1Interrupt, IPL7SOFT) ADC1Interrupt(void);
     
    The void_ISR was unresolved. I do have an #include <sys/attribs.h> at the top of the file but the code complains it cannot find the  file. What folder should it be in? I see them under a pic32 and pic32mx folder ...
     ==================================================================================
     
    The void __ISR(_ADC1Interrupt, IPL7SOFT) ADC1Interrupt(void); had an error. There was no space after void before __ISR.
     
    It compiles without error, but I am still interested in comments on the two different methods of declaring the interrupt:
     void __attribute__ ((vector(_ADC_VECTOR), interrupt(IPL7SOFT), micromips)) _ADC1Interrupt(void)
    versus
     void  __ISR(_ADC1Interrupt, IPL7SOFT) ADC1Interrupt(void);
     

    #2
    Mysil
    Super Member
    • Total Posts : 3677
    • Reward points : 0
    • Joined: 2012/07/01 04:19:50
    • Location: Norway
    • Status: offline
    Re: Setting up PIC32MM Interrupts 2019/12/05 20:21:16 (permalink)
    0
    Hi,
    __ISR(...)
    is a macro provided  by one of the files included by <xc.h>,
    supposedly to make it easier,
    by not having to manipulate the parantheses of the __attribute__((...))  construct.
    It should end up the same anyway after preprocessing
     
    'micromips' is the instruction set used by the CPU in PIC32MM devices.
    It is a version of MIPS32 instruction set with 16 bit instruction word size.
    In some other PIC32 devices, there may be possible to switch between 32 bit instructions and 16 bit instructions,
    but as far as I understand, PIC32MM  devices use 16 bit instrucctions only.
     
    Specifying micromips, in the interrupt specification, might be redundant.
    The compiler will probably use the 16 bit instruction set anyway if it know that it shall run on a MM.
    It does no harm, confirming that code is intended for a PIC32MM.
     
    void__ISR(_ADC1Interrupt, IPL7SOFT) ADC1Interrupt(void);
    with a semicolon at the end, is just a declaration, it will not produce executable code for a interrupt handler,
    so it cannot be resolved by the linker.
     
    You must provide a body for the interrupt handler, without the semicolon :
    void __attribute__ ((vector(_ADC_VECTOR), interrupt(IPL7SOFT), micromips)) _ADC1Interrupt(void)
    {
        IFS0CLR = _IFS0_AD1IF_MASK;  /* Clear the interrupt flag. */
    /* ... Insert interrupt handling code. */
    }
     
    Writing  Declarations  for interrupt handlers, is not really needed on PIC32.
    There are no other functions that shall be able , or allowed to call the Interrupt Service Routine.
    Compiler and linker will know how to make the ISR code, and know where it shall be placed,
    from the definition and body of the interrupt handler.
    And if there is an interrupt Enabled, and it trigger, interrupt hardware will go to the interrupt vector location,
    whether you have prepared a ISR or not.
    If there is no ISR written, then default_interrupt_handler will be called, and that one will Reset the microcontroller.
     
    There may be some new constructs available with XC32 compilers version 2.xx
    Look up XC32 Compiler Users Guide,  it is on your computer in a \docs directory,
    together with compiler binaries, and all the include files and other stuff.
    Look for:     __interrupt(...)
     
        Mysil
     
     
    post edited by Mysil - 2019/12/05 20:29:33
    #3
    btremaine
    Junior Member
    • Total Posts : 59
    • Reward points : 0
    • Joined: 2013/08/17 14:46:34
    • Location: San Jose, CA
    • Status: offline
    Re: Setting up PIC32MM Interrupts 2019/12/05 20:54:31 (permalink)
    0
    Thanks for you complete response ;)
    #4
    Jump to:
    © 2020 APG vNext Commercial Version 4.5