您好!
事件触发中断的产生有问题、我希望在 CTR = 0时生成由 ePWM1触发的中断。 因此、您可以看到我的配置下面的内容。
问题:ETSEL.INTSEL 等于1,因此 CTR = 0 和 INTEN = 1可以启用中断。 ETPS 配置出现问题我想选择 ETPS.INTPRD、因为我想在每次触发时生成事件。
那么 ETPS.INTPRD 将等于1 NO? 在 CCS 窗口调试器中、您可以看到 ETPS.INTPRD = 0。 如何通过 driverlib 选择此位? 使用此函数 ePWM_setInterruptEventCount (EPWM1_BASE、1)选择 ETINTPS.INTPRD2。
我在 ePWM1和 INT_EPWM1之间看到 *** 时序有什么问题? 我想将 ePWM1上升沿与 INTePWM1上升沿同步。
粉色信号:ePWM1
黄色信号:INT_EPWM1 (1个输入中断、0个输出)
如果我在每个事件中选择中断、ETPS.INTPRD 和 ETINTPS.INTPRD2之间有何不同?
#include "device.h"
__interrupt void isr_read_adc(void);
void main(void)
{
/// Initialize device clock and peripherals
Device_init();
/// Disable pin locks and enable internal pullups.
Device_initGPIO();
/// Initialize PIE and clear PIE (for pie multiplexer) and IFR (for cpu) registers (IER for pie table).
Interrupt_initModule();
/// Initialize the PIE vector table with pointers to the shell Interrupt Service Routines (ISR).
Interrupt_initVectorTable();
/// Disable sync and clock to PWM
SysCtl_disablePeripheral(SYSCTL_PERIPH_CLK_TBCLKSYNC);
/// Parameters
EPWM_setTimeBaseCounterMode(EPWM1_BASE, EPWM_COUNTER_MODE_UP);
EPWM_setTimeBaseCounter(EPWM1_BASE, 0U);
/// To have around 0.05% (See ePWM chapter in Chapter 17 Technical reference manual page 1798) do point for ePWM precision who is the maximum precision with the ePWM module.
/// If we want more precision use the HRPWM module.
EPWM_setClockPrescaler(EPWM1_BASE, EPWM_CLOCK_DIVIDER_1, EPWM_HSCLOCK_DIVIDER_1);
/// Set up shadowing
EPWM_setCounterCompareShadowLoadMode(EPWM1_BASE, EPWM_COUNTER_COMPARE_A, EPWM_COMP_LOAD_ON_CNTR_ZERO);
/// Set actions for boost assembly
EPWM_setActionQualifierAction(EPWM1_BASE, EPWM_AQ_OUTPUT_A, EPWM_AQ_OUTPUT_HIGH, EPWM_AQ_OUTPUT_ON_TIMEBASE_UP_CMPA);
EPWM_setActionQualifierAction(EPWM1_BASE, EPWM_AQ_OUTPUT_A, EPWM_AQ_OUTPUT_LOW, EPWM_AQ_OUTPUT_ON_TIMEBASE_ZERO);
/// For buck assembly
EPWM_setActionQualifierAction(EPWM1_BASE, EPWM_AQ_OUTPUT_B, EPWM_AQ_OUTPUT_HIGH, EPWM_AQ_OUTPUT_ON_TIMEBASE_UP_CMPB);
EPWM_setActionQualifierAction(EPWM1_BASE, EPWM_AQ_OUTPUT_B, EPWM_AQ_OUTPUT_LOW, EPWM_AQ_OUTPUT_ON_TIMEBASE_ZERO);
EPWM_setTimeBasePeriod(EPWM1_BASE, 2499);
EPWM_setCounterCompareValue(EPWM1_BASE, EPWM_COUNTER_COMPARE_B, 1250);
/// Interrupt where we will change the Compare Values
/// Select INT on Time base counter zero event,
/// Enable INT, generate INT on 1rd event
EPWM_setInterruptSource(EPWM1_BASE, EPWM_INT_TBCTR_ZERO);
EPWM_enableInterrupt(EPWM1_BASE);
/// To trigger the interrupt at each event, maximum value equal to 15.
EPWM_setInterruptEventCount(EPWM1_BASE, 1);
EPWM_setPhaseShift(EPWM1_BASE, 0);
EPWM_disablePhaseShiftLoad(EPWM1_BASE);
GPIO_setPinConfig(GPIO_42_GPIO42);
GPIO_setDirectionMode(42, GPIO_DIR_MODE_OUT);
GPIO_setPadConfig(42, GPIO_PIN_TYPE_STD);
GPIO_writePin(42, 0);
/// GPIO initialization EPWM1
EALLOW;
GPIO_setPinConfig(GPIO_0_EPWM1_A);
GPIO_setPinConfig(GPIO_1_EPWM1_B);
EDIS;
Interrupt_register(INT_EPWM1, &isr_read_adc);
Interrupt_enable(INT_EPWM1);
/// Enable sync and clock to PWM
SysCtl_enablePeripheral(SYSCTL_PERIPH_CLK_TBCLKSYNC);
/// Enable Global Interrupt (INTM) and realtime interrupt (DBGM)
EINT;
ERTM;
while(1)
{
}
}
__interrupt void isr_read_adc(void)
{
EPWM_clearEventTriggerInterruptFlag(EPWM1_BASE);
GPIO_writePin(42, 1);
DEVICE_DELAY_US(2);
GPIO_writePin(42, 0);
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP3);
}

谢谢
Damien

