如图所示,打算使用三个中断,分别是EPWM4_ISR(90kHz), CpuTimer_ISR(10 kHz), EPWM1_ISR(200 kHz, 50%, Zero Trigger), 使其中EPWM4_ISR,CpuTimer_ISR 中都嵌套 EPWM1_ISR;当只 EPWM4_ISR 嵌套EPWM1_ISR 或 只CpuTimer_ISR嵌套EPWM1_ISR,EPWM1_ISR 可正常嵌套执行;但是当EPWM4_ISR,CpuTimer_ISR,同时嵌套EPWM1_ISR时出现一个问题, EPWM1_ISR 会不时的多执行一次(图中红色箭头处)。请问为什么会这样,怎么解决这个问题?请大神指导!!!!
代码如下:
volatile Uint16 NestPIEIER;
__interrupt void epwm1_isr ( void )
{
—————————————————————–
// Update EPWM1 & EPWM2
//———————————————————————
// Clear INT flag for this timer
// Acknowledge this interrupt to receive more interrupts from group 3
//———————————————————————
EPwm1Regs.ETCLR.bit.INT = 1;
PieCtrlRegs.PIEACK.all = PIEACK_GROUP3;
}
__interrupt void epwm4_isr(void)
{ //————————————————————-
// Set interrupt priority:
NestPIEIER = PieCtrlRegs.PIEIER3.all;
IER |= M_INT3;
IER &= M_INT3; // Set "global" priority
PieCtrlRegs.PIEIER3.all &= 0x0001; // Set "group" priority
PieCtrlRegs.PIEACK.all = 0xFFFF; // Enable PIE interrupts
__asm(" NOP");
EINT;
//———————————————————
// Insert ISR Code here…….
//———————————————————
//———————————————————————
// Restore registers saved:
DINT;
PieCtrlRegs.PIEIER3.all = NestPIEIER;
//———————————————————————
// Acknowledge this interrupt to receive more interrupts from group 3
PieCtrlRegs.PIEACK.all = PIEACK_GROUP3; ///2
// Clear INT flag for this timer
EPwm4Regs.ETCLR.bit.INT = 1; ///2
}
__interrupt void CpuTimer0_isr ( void )
{
//————————————————————-
// Set interrupt priority:
NestPIEIER = PieCtrlRegs.PIEIER3.all;
IER |= M_INT3;
IER &= M_INT3; // Set "global" priority
PieCtrlRegs.PIEIER3.all &= 0x0001; // Set "group" priority
PieCtrlRegs.PIEACK.all = 0xFFFF; // Enable PIE interrupts
__asm(" NOP");
EINT;
//———————————————————
// Insert ISR Code here…….
//———————————————————
//———————————————————————
// Restore registers saved:
DINT;
PieCtrlRegs.PIEIER3.all = NestPIEIER;
//
// Acknowledge this interrupt to receive more interrupts from group 1
//
PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;
}
通道2(绿):测试IO Epwm4_isr 90kHz
通道4(红): 测试IO CpuTimer0_isr 10 kHz
通道1(黄):测试IO epwm1_isr 200KHz,
通道3(蓝):epwm1 outputA
mangui zhang:看波形好像与CPUTimer有关系注意中断中清除标志
如图所示,打算使用三个中断,分别是EPWM4_ISR(90kHz), CpuTimer_ISR(10 kHz), EPWM1_ISR(200 kHz, 50%, Zero Trigger), 使其中EPWM4_ISR,CpuTimer_ISR 中都嵌套 EPWM1_ISR;当只 EPWM4_ISR 嵌套EPWM1_ISR 或 只CpuTimer_ISR嵌套EPWM1_ISR,EPWM1_ISR 可正常嵌套执行;但是当EPWM4_ISR,CpuTimer_ISR,同时嵌套EPWM1_ISR时出现一个问题, EPWM1_ISR 会不时的多执行一次(图中红色箭头处)。请问为什么会这样,怎么解决这个问题?请大神指导!!!!
代码如下:
volatile Uint16 NestPIEIER;
__interrupt void epwm1_isr ( void )
{
—————————————————————–
// Update EPWM1 & EPWM2
//———————————————————————
// Clear INT flag for this timer
// Acknowledge this interrupt to receive more interrupts from group 3
//———————————————————————
EPwm1Regs.ETCLR.bit.INT = 1;
PieCtrlRegs.PIEACK.all = PIEACK_GROUP3;
}
__interrupt void epwm4_isr(void)
{ //————————————————————-
// Set interrupt priority:
NestPIEIER = PieCtrlRegs.PIEIER3.all;
IER |= M_INT3;
IER &= M_INT3; // Set "global" priority
PieCtrlRegs.PIEIER3.all &= 0x0001; // Set "group" priority
PieCtrlRegs.PIEACK.all = 0xFFFF; // Enable PIE interrupts
__asm(" NOP");
EINT;
//———————————————————
// Insert ISR Code here…….
//———————————————————
//———————————————————————
// Restore registers saved:
DINT;
PieCtrlRegs.PIEIER3.all = NestPIEIER;
//———————————————————————
// Acknowledge this interrupt to receive more interrupts from group 3
PieCtrlRegs.PIEACK.all = PIEACK_GROUP3; ///2
// Clear INT flag for this timer
EPwm4Regs.ETCLR.bit.INT = 1; ///2
}
__interrupt void CpuTimer0_isr ( void )
{
//————————————————————-
// Set interrupt priority:
NestPIEIER = PieCtrlRegs.PIEIER3.all;
IER |= M_INT3;
IER &= M_INT3; // Set "global" priority
PieCtrlRegs.PIEIER3.all &= 0x0001; // Set "group" priority
PieCtrlRegs.PIEACK.all = 0xFFFF; // Enable PIE interrupts
__asm(" NOP");
EINT;
//———————————————————
// Insert ISR Code here…….
//———————————————————
//———————————————————————
// Restore registers saved:
DINT;
PieCtrlRegs.PIEIER3.all = NestPIEIER;
//
// Acknowledge this interrupt to receive more interrupts from group 1
//
PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;
}
通道2(绿):测试IO Epwm4_isr 90kHz
通道4(红): 测试IO CpuTimer0_isr 10 kHz
通道1(黄):测试IO epwm1_isr 200KHz,
通道3(蓝):epwm1 outputA
user5860441:把PieCtrlRegs.PIEACK.all = PIEACK_GROUP3;换成PieCtrlRegs.PIEACK.bit.ACK3 = 1;
把所有的都改一下,试试。
如图所示,打算使用三个中断,分别是EPWM4_ISR(90kHz), CpuTimer_ISR(10 kHz), EPWM1_ISR(200 kHz, 50%, Zero Trigger), 使其中EPWM4_ISR,CpuTimer_ISR 中都嵌套 EPWM1_ISR;当只 EPWM4_ISR 嵌套EPWM1_ISR 或 只CpuTimer_ISR嵌套EPWM1_ISR,EPWM1_ISR 可正常嵌套执行;但是当EPWM4_ISR,CpuTimer_ISR,同时嵌套EPWM1_ISR时出现一个问题, EPWM1_ISR 会不时的多执行一次(图中红色箭头处)。请问为什么会这样,怎么解决这个问题?请大神指导!!!!
代码如下:
volatile Uint16 NestPIEIER;
__interrupt void epwm1_isr ( void )
{
—————————————————————–
// Update EPWM1 & EPWM2
//———————————————————————
// Clear INT flag for this timer
// Acknowledge this interrupt to receive more interrupts from group 3
//———————————————————————
EPwm1Regs.ETCLR.bit.INT = 1;
PieCtrlRegs.PIEACK.all = PIEACK_GROUP3;
}
__interrupt void epwm4_isr(void)
{ //————————————————————-
// Set interrupt priority:
NestPIEIER = PieCtrlRegs.PIEIER3.all;
IER |= M_INT3;
IER &= M_INT3; // Set "global" priority
PieCtrlRegs.PIEIER3.all &= 0x0001; // Set "group" priority
PieCtrlRegs.PIEACK.all = 0xFFFF; // Enable PIE interrupts
__asm(" NOP");
EINT;
//———————————————————
// Insert ISR Code here…….
//———————————————————
//———————————————————————
// Restore registers saved:
DINT;
PieCtrlRegs.PIEIER3.all = NestPIEIER;
//———————————————————————
// Acknowledge this interrupt to receive more interrupts from group 3
PieCtrlRegs.PIEACK.all = PIEACK_GROUP3; ///2
// Clear INT flag for this timer
EPwm4Regs.ETCLR.bit.INT = 1; ///2
}
__interrupt void CpuTimer0_isr ( void )
{
//————————————————————-
// Set interrupt priority:
NestPIEIER = PieCtrlRegs.PIEIER3.all;
IER |= M_INT3;
IER &= M_INT3; // Set "global" priority
PieCtrlRegs.PIEIER3.all &= 0x0001; // Set "group" priority
PieCtrlRegs.PIEACK.all = 0xFFFF; // Enable PIE interrupts
__asm(" NOP");
EINT;
//———————————————————
// Insert ISR Code here…….
//———————————————————
//———————————————————————
// Restore registers saved:
DINT;
PieCtrlRegs.PIEIER3.all = NestPIEIER;
//
// Acknowledge this interrupt to receive more interrupts from group 1
//
PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;
}
通道2(绿):测试IO Epwm4_isr 90kHz
通道4(红): 测试IO CpuTimer0_isr 10 kHz
通道1(黄):测试IO epwm1_isr 200KHz,
通道3(蓝):epwm1 outputA
user4828609:
回复 user5860441:
试过了,没效果
如图所示,打算使用三个中断,分别是EPWM4_ISR(90kHz), CpuTimer_ISR(10 kHz), EPWM1_ISR(200 kHz, 50%, Zero Trigger), 使其中EPWM4_ISR,CpuTimer_ISR 中都嵌套 EPWM1_ISR;当只 EPWM4_ISR 嵌套EPWM1_ISR 或 只CpuTimer_ISR嵌套EPWM1_ISR,EPWM1_ISR 可正常嵌套执行;但是当EPWM4_ISR,CpuTimer_ISR,同时嵌套EPWM1_ISR时出现一个问题, EPWM1_ISR 会不时的多执行一次(图中红色箭头处)。请问为什么会这样,怎么解决这个问题?请大神指导!!!!
代码如下:
volatile Uint16 NestPIEIER;
__interrupt void epwm1_isr ( void )
{
—————————————————————–
// Update EPWM1 & EPWM2
//———————————————————————
// Clear INT flag for this timer
// Acknowledge this interrupt to receive more interrupts from group 3
//———————————————————————
EPwm1Regs.ETCLR.bit.INT = 1;
PieCtrlRegs.PIEACK.all = PIEACK_GROUP3;
}
__interrupt void epwm4_isr(void)
{ //————————————————————-
// Set interrupt priority:
NestPIEIER = PieCtrlRegs.PIEIER3.all;
IER |= M_INT3;
IER &= M_INT3; // Set "global" priority
PieCtrlRegs.PIEIER3.all &= 0x0001; // Set "group" priority
PieCtrlRegs.PIEACK.all = 0xFFFF; // Enable PIE interrupts
__asm(" NOP");
EINT;
//———————————————————
// Insert ISR Code here…….
//———————————————————
//———————————————————————
// Restore registers saved:
DINT;
PieCtrlRegs.PIEIER3.all = NestPIEIER;
//———————————————————————
// Acknowledge this interrupt to receive more interrupts from group 3
PieCtrlRegs.PIEACK.all = PIEACK_GROUP3; ///2
// Clear INT flag for this timer
EPwm4Regs.ETCLR.bit.INT = 1; ///2
}
__interrupt void CpuTimer0_isr ( void )
{
//————————————————————-
// Set interrupt priority:
NestPIEIER = PieCtrlRegs.PIEIER3.all;
IER |= M_INT3;
IER &= M_INT3; // Set "global" priority
PieCtrlRegs.PIEIER3.all &= 0x0001; // Set "group" priority
PieCtrlRegs.PIEACK.all = 0xFFFF; // Enable PIE interrupts
__asm(" NOP");
EINT;
//———————————————————
// Insert ISR Code here…….
//———————————————————
//———————————————————————
// Restore registers saved:
DINT;
PieCtrlRegs.PIEIER3.all = NestPIEIER;
//
// Acknowledge this interrupt to receive more interrupts from group 1
//
PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;
}
通道2(绿):测试IO Epwm4_isr 90kHz
通道4(红): 测试IO CpuTimer0_isr 10 kHz
通道1(黄):测试IO epwm1_isr 200KHz,
通道3(蓝):epwm1 outputA
Li Robert:根據波形,懷疑是Timer0的中斷觸發epwm1,所以當進入Timer0打開中斷後直接跳epwm1中斷。
可以把Timer0換成Timer1/2看能否避掉此問題