#include /** @function LVW_TSD_INT @brief 芯片过温 芯片欠压故障中断 @date 2025-11-01 */ void LVW_TSD_INT(void) interrupt 0 { if (ReadBit(LVSR, LVWIF)) { if (ReadBit(LVSR, LVWF)) { FaultProcess(); ClrBit(LVSR, LVWF); } ClrBit(LVSR, LVWIF); } if (TSDIF) { TSDIF = 0; } } /** @function EXTERN_INT0 @brief 外部中断0 用于预驱故障检测 中断优先级最高 @date 2025-11-01 */ void EXTERN_INT0(void) interrupt 1 { if (IF0) { FaultProcess(); mcFaultSource = FaultHardOVCurrent; IF0 = 0; } } /* ------------------------------------------------------------------------------------------------- Function Name : void CMP3_INT(void) Description : CMP3:硬件比较器过流保护,关断输出,中断优先级最高 Input : 无 Output : 无 -------------------------------------------------------------------------------------------------*/ void CMP3_INT(void) interrupt 12 { if (ReadBit(CMP_SR, CMP3IF)) { FaultProcess(); // 关闭输出 mcFaultSource = FaultHardOVCurrent; // 硬件过流保护 ClrBit(CMP_SR, CMP3IF); } } /** @function DRV_ISR @brief FOC中断(Drv中断),每个载波周期执行一次,用于处理响应较高的程序,中断优先级第二。DCEN开了就会产生中断。 @date 2025-11-01 */ void DRV_ISR(void) interrupt 3 { if (ReadBit(DRV_SR, DCIF)) // 比较中断 { Fault_Overcurrent(); //软件过流保护 #if (FiledWeakenCompEnable) { FiledWeakenControl(FOC__UD, FOC__UQ, udc.WeakenUsRef, mcFocCtrl.IsRef); if (mcFieldWeaken.mcIdref < ID_Limit) {mcFieldWeaken.mcIdref = ID_Limit;} mcFocCtrl.IdRef = mcFieldWeaken.mcIdref; mcFocCtrl.IqRef = mcFieldWeaken.mcIqref; } #else { mcFocCtrl.IqRef = mcFocCtrl.IsRef; mcFocCtrl.IdRef = 0; } #endif if (mcFocCtrl.CtrlMode) { FOC_IQREF = mcFocCtrl.IqRef; FOC_IDREF = mcFocCtrl.IdRef; } #if (VoltageCompensationEn) VoltageCompensation();//电压补偿 #endif DRV_SR = (DRV_SR | SYSTIF) & (~DCIF); } } /** @function SYStick_INT @brief 定时器中断(SYS TICK中断) @date 2025-11-01 */ void SYStick_INT(void) interrupt 10 { if (ReadBit(DRV_SR, SYSTIF)) // SYS TICK中断 { IsTick = true; if (mcFocCtrl.State_Count > 0) { mcFocCtrl.State_Count--; } if (mcFocCtrl.mcAcbustime < 30000) { mcFocCtrl.mcAcbustime++; } DRV_SR = (DRV_SR | DCIF) & (~SYSTIF);// 清零标志位 } } void USART_INT(void) interrupt 14 { if (UT2TI) { UT2TI = 0; } if (UT2RI) { UT2RI = 0; } } void USART_INT1(void) interrupt 13 { if (TI) { TI = 0; } if (RI) { RI = 0; } }