我正在使用 MPLABX 编程 DSPIC33EP512GM710-I_PT TQFP 问题是我生成 2 个类似的中断 MPlabX 它在多个 .c 文件中写入相同的函数名称,因此编译器生成错误,因为创建了 2 个或更多具有相同名称的函数
这里有两种可能的解决方案:
解决方案1:更改中断名称,但我不知道是否会到达中断
解决方案 2:注释除一个中断函数之外的所有中断函数,并在该中断中请求寄存器以查看真正的中断是什么
注意:我看过帖子:__attribute__((__interrupt__, no_auto_psv)) 做什么? 还有手册:(https://www.mouser.com/datasheet/2/268/MPLAB_XC16_v1_10_C_Compiler_UG_52081-477561.pdf第 128 页)
但是我不知道如果在所有属性(( interrupt , no_auto_psv)) 代码中按顺序查看 micro 当到达中断时会发生什么
这是我对应于解决方案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;
}