0

I am programming a DSPIC33EP512GM710-I_PT TQFP using MPLABX The problem is that I generate 2 similar interrupts the MPlabX it writes the same function name in several .c files so the compiler generate an error because 2 or more functions with same name are created

Here are 2 possible solutions:

Solution-1: Change interrupt name, but then I o not know if the interrupt will be reached

Solution-2: Comment all but one of the interrupt functions and in that interrupt ask for registers to look what was the real interruption

Note: I have seen the post: What does __attribute__((__interrupt__, no_auto_psv)) do? And also the manual: (https://www.mouser.com/datasheet/2/268/MPLAB_XC16_v1_10_C_Compiler_UG_52081-477561.pdf page 128)

But I do not know what does micro when reaches an interruption if it look sequentially in all the attribute((interrupt, no_auto_psv)) codes

Here is my code corresponding to solution-2:

void __attribute__ ( ( interrupt, no_auto_psv ) ) _CM1Interrupt(void)
{
    /*
     * *************  ALTERADO PARA ACEPTAR OTROS COMPARADORES ************************
    // CMP1 callback function 
    CMP1_CallBack();

    // Clear the CEVT bit to enable further interrupts
    CMP1_EventStatusReset();
          */

    if (CM1CONbits.CEVT)
    {
        //all up mosfets to 0
        aplica_mapa(0,6);      //todo a 0 
        delay_us1(5);
        CMP1_EventStatusReset();
    }

    if (CM2CONbits.CEVT)
    {
        //all up mosfets to 0
        aplica_mapa(1,6);     
        delay_us1(5);
        CMP2_EventStatusReset();
    }
    if (CM5CONbits.CEVT)
    {
        //all up mosfets to 0
        aplica_mapa(3,6);      //todo a 0 
        delay_us1(5);
        CMP5_EventStatusReset();
    }
    // clear the CMP1 interrupt flag
    IFS1bits.CMIF = 0;

}
mathengineer
  • 140
  • 6
  • please show some code. An interrupt could only be interrupted by another interrupt with higher priority. You only could write one ISR for each interrupt case. – Mike Feb 28 '20 at 11:01
  • Are you trying to assign more than one ISR (interrupt service routine) to the same interrupt? – the busybee Feb 28 '20 at 11:28
  • They were generated by MPLABX MCC (code generator). I think the better thing is to merge all interrupts in one function and use ifs to check every interruption inside Unfortunately that problem appeared at a company where I worked in the past, so I can not have the code now. – mathengineer May 01 '20 at 11:39

0 Answers0