Other Parts Discussed in Thread: C2000WARE
大家好,
我想要使用28388配置epwm5并执行中断配置,我按照例程interrupt_ex4_epwm_realtime_interrupt进行配置,在debug发现无法进入中断,但在debug时候我停止调试然后点击restart后又能重新进入中断,如果烧写离线程序又无法进入中断,不知道我的代码配置是否有问题,麻烦各位帮忙解答一下,谢谢。
下面附上我的代码,我使用的是ccs12.0版本,c2000Ware是4.03版本
主函数:
void main(void)
{
Device_init();
//
// Boot CPU2 core
//
#if DEBUG
#ifdef _FLASH
// Send boot command to allow the CPU2 application to begin execution
Device_bootCPU2(BOOTMODE_BOOT_TO_FLASH_SECTOR0);
Device_bootCM(BOOTMODE_BOOT_TO_FLASH_SECTOR0);
#else
// Send boot command to allow the CPU2 application to begin execution
Device_bootCPU2(BOOTMODE_BOOT_TO_M0RAM);
Device_bootCM(BOOTMODE_BOOT_TO_S0RAM);
#endif
#endif
// Device_initGPIO();
// syscfg配置调用
Board_init();
//
// Initialize PIE and clear PIE registers. Disables CPU interrupts.
//
Interrupt_initModule();
//
// Initialize the PIE vector table with pointers to the shell Interrupt
// Service Routines (ISR).
//
Interrupt_initVectorTable();
EPWM_init();
INTERRUPT_init();
//
// Enable Global Interrupt (INTM) and realtime interrupt (DBGM)
//
EINT;
ERTM;
//
// Loop Forever
//
for(;;)
{
}
}
Epwm初始化函数:
void EPWM_init(){
SysCtl_setEPWMClockDivider(SYSCTL_EPWMCLK_DIV_1);
SysCtl_disablePeripheral(SYSCTL_PERIPH_CLK_TBCLKSYNC);
EPWM_setClockPrescaler(EPWM5_BASE, EPWM_CLOCK_DIVIDER_1, EPWM_HSCLOCK_DIVIDER_1);
EPWM_disablePhaseShiftLoad(EPWM5_BASE);
EPWM_setPhaseShift(EPWM5_BASE, 0);
EPWM_setEmulationMode(EPWM5_BASE, EPWM_EMULATION_STOP_AFTER_FULL_CYCLE);
EPWM_setTimeBasePeriod(EPWM5_BASE, myEPWM5_TBPRD);
EPWM_setTimeBaseCounterMode(EPWM5_BASE, EPWM_COUNTER_MODE_UP_DOWN);
EPWM_setTimeBaseCounter(EPWM5_BASE, 0U);
EPWM_setPeriodLoadMode(EPWM5_BASE, EPWM_PERIOD_DIRECT_LOAD);
EPWM_setInterruptSource(EPWM5_BASE, EPWM_INT_TBCTR_ZERO_OR_PERIOD);
EPWM_enableInterrupt(EPWM5_BASE);
EPWM_setInterruptEventCount(EPWM5_BASE, 1);
SysCtl_enablePeripheral(SYSCTL_PERIPH_CLK_TBCLKSYNC);
}
使能中断:
void INTERRUPT_init(){
// Interrupt Setings for INT_myEPWM5
Interrupt_register(INT_myEPWM5, &INT_myEPWM5_ISR);
Interrupt_enable(INT_myEPWM5);
}
中断服务函数:
__interrupt void INT_myEPWM5_ISR(void)
{
count ++;
if(count >= 8000)
{
GPIO_togglePin(DEVICE_GPIO_PIN_LED_3);
count = 0;
}
EPWM_clearEventTriggerInterruptFlag(EPWM5_BASE);
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP3);
}