TI中文支持网
TI专业的中文技术问题搜集分享网站

TMS320F28375S: Ecap只能进入一次中断

Part Number:TMS320F28375SOther Parts Discussed in Thread:C2000WARE

我用信号发生器生成一个方波,输入到Ecap的引脚,设置触发源为EVENT_4,补货为连续捕获模式,但是不知道为什么只能进入一次中断,麻烦帮忙看看是哪里有问题

这是初始化的代码

void initECAP()
{//// Disable ,clear all capture flags and interrupts//ECAP_disableInterrupt(ECAP1_BASE,(ECAP_ISR_SOURCE_CAPTURE_EVENT_1  |ECAP_ISR_SOURCE_CAPTURE_EVENT_2  |ECAP_ISR_SOURCE_CAPTURE_EVENT_3  |ECAP_ISR_SOURCE_CAPTURE_EVENT_4  |ECAP_ISR_SOURCE_COUNTER_OVERFLOW |ECAP_ISR_SOURCE_COUNTER_PERIOD|ECAP_ISR_SOURCE_COUNTER_COMPARE));ECAP_clearInterrupt(ECAP1_BASE,(ECAP_ISR_SOURCE_CAPTURE_EVENT_1  |ECAP_ISR_SOURCE_CAPTURE_EVENT_2  |ECAP_ISR_SOURCE_CAPTURE_EVENT_3  |ECAP_ISR_SOURCE_CAPTURE_EVENT_4  |ECAP_ISR_SOURCE_COUNTER_OVERFLOW |ECAP_ISR_SOURCE_COUNTER_PERIOD|ECAP_ISR_SOURCE_COUNTER_COMPARE));//// Disable CAP1-CAP4 register loads//ECAP_disableTimeStampCapture(ECAP1_BASE);//// Configure eCAP//Enable capture mode.//One shot mode, stop capture at event 4.//Set polarity of the events to rising, falling, rising, falling edge.//Set capture in time difference mode.//Select input from XBAR7.//Enable eCAP module.//Enable interrupt.//ECAP_stopCounter(ECAP1_BASE);ECAP_enableCaptureMode(ECAP1_BASE);ECAP_setCaptureMode(ECAP1_BASE, ECAP_CONTINUOUS_CAPTURE_MODE, ECAP_EVENT_4);ECAP_setEventPolarity(ECAP1_BASE, ECAP_EVENT_1, ECAP_EVNT_FALLING_EDGE);ECAP_setEventPolarity(ECAP1_BASE, ECAP_EVENT_2, ECAP_EVNT_FALLING_EDGE);ECAP_setEventPolarity(ECAP1_BASE, ECAP_EVENT_3, ECAP_EVNT_FALLING_EDGE);ECAP_setEventPolarity(ECAP1_BASE, ECAP_EVENT_4, ECAP_EVNT_FALLING_EDGE);ECAP_enableCounterResetOnEvent(ECAP1_BASE, ECAP_EVENT_1);ECAP_enableCounterResetOnEvent(ECAP1_BASE, ECAP_EVENT_2);ECAP_enableCounterResetOnEvent(ECAP1_BASE, ECAP_EVENT_3);ECAP_enableCounterResetOnEvent(ECAP1_BASE, ECAP_EVENT_4);XBAR_setInputPin(XBAR_INPUT7, 19);ECAP_enableLoadCounter(ECAP1_BASE);ECAP_setSyncOutMode(ECAP1_BASE, ECAP_SYNC_OUT_DISABLED);ECAP_startCounter(ECAP1_BASE);ECAP_enableTimeStampCapture(ECAP1_BASE);ECAP_reArm(ECAP1_BASE);ECAP_enableInterrupt(ECAP1_BASE, ECAP_ISR_SOURCE_CAPTURE_EVENT_4);
}

这是中断的代码

__interrupt void ecap1ISR(void)
{//// Get the capture counts. Each capture should be 4x the ePWM count// because of the ePWM clock dividers.//cap1Count = ECAP_getEventTimeStamp(ECAP1_BASE, ECAP_EVENT_1);cap2Count = ECAP_getEventTimeStamp(ECAP1_BASE, ECAP_EVENT_2);cap3Count = ECAP_getEventTimeStamp(ECAP1_BASE, ECAP_EVENT_3);cap4Count = ECAP_getEventTimeStamp(ECAP1_BASE, ECAP_EVENT_4);calc_pulse1 = cap4Count - cap1Count;calc_time = calc_pulse1 * 5.1282051282 * 10e-9;rpm = 1/calc_time*20;ECAP_clearInterrupt(ECAP1_BASE,ECAP_ISR_SOURCE_CAPTURE_EVENT_4);ECAP_clearGlobalInterrupt(ECAP1_BASE);// Start eCAP//ECAP_reArm(ECAP1_BASE);//// Acknowledge the group interrupt for more interrupts.//Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP4);

}

Ben Qin:

你好,你有参考过C2000Ware中的例程吗?C:\ti\c2000\C2000Ware_4_03_00_00\driverlib\f2837xs\examples\cpu1\ecap

赞(0)
未经允许不得转载:TI中文支持网 » TMS320F28375S: Ecap只能进入一次中断
分享到: 更多 (0)

© 2024 TI中文支持网   网站地图 鲁ICP备2022002796号-1