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

TMS320F280049的ECAP问题,请大神指点

原代码如下配置,得到结果是ECAP1-3都能捕获到相应的数据,但是ECAP4却捕获不到数据。如果把ECAP4的INPUTxSELECT调到3,其他依次后移,则ECAP3捕获不到数据,多次尝试结果相同,只要是INPUTxSELECT的x最大,则相应的ECAP就捕获不到数据,请大神指点是为什么?还是哪里的配置有问题?

EALLOW;
InputXbarRegs.INPUT3SELECT = 13 ;
GpioCtrlRegs.GPAPUD.bit.GPIO13 = 0; // Enable pullup on GPIO12
GpioCtrlRegs.GPAQSEL1.bit.GPIO13 = 0; // Synch to SYSCLKOUT
ECap1Regs.ECCTL0.bit.INPUTSEL = 3; // Select eCAP1 TO INPU12

InputXbarRegs.INPUT4SELECT = 12 ;
GpioCtrlRegs.GPAPUD.bit.GPIO12 = 0; // Enable pullup on GPIO13
GpioCtrlRegs.GPAQSEL1.bit.GPIO12 = 0; // Synch to SYSCLKOUT
ECap2Regs.ECCTL0.bit.INPUTSEL = 4; // Select eCAP2 TO INPU13

InputXbarRegs.INPUT5SELECT = 13 ;
GpioCtrlRegs.GPAPUD.bit.GPIO13 = 0; // Enable pullup on GPIO16
GpioCtrlRegs.GPAQSEL1.bit.GPIO13 = 0; // Synch to SYSCLKOUT
GpioCtrlRegs.GPAGMUX1.bit.GPIO13 = 0;
GpioCtrlRegs.GPAMUX1.bit.GPIO13 = 0;
ECap3Regs.ECCTL0.bit.INPUTSEL = 5; // Select eCAP3 TO INPU16

InputXbarRegs.INPUT6SELECT = 12 ;
GpioCtrlRegs.GPAPUD.bit.GPIO12 = 0; // Enable pullup on GPIO17
GpioCtrlRegs.GPAQSEL1.bit.GPIO12 = 0; // Synch to SYSCLKOUT
GpioCtrlRegs.GPAGMUX1.bit.GPIO12 = 0;
GpioCtrlRegs.GPAMUX1.bit.GPIO12 = 0;
ECap4Regs.ECCTL0.bit.INPUTSEL = 6; // Select eCAP4 TO INPU17

//2.Init Regs .Ecap1-4
ECap1Regs.ECEINT.all = 0x0000; // Disable all capture interrupts
ECap1Regs.ECCLR.all = 0xFFFF; // Clear all CAP interrupt flags
ECap1Regs.ECCTL1.bit.CAP1POL = 0; // 上升沿捕捉
ECap1Regs.ECCTL1.bit.CAP2POL = 1; // 下降沿捕捉
ECap1Regs.ECCTL1.bit.CAP3POL = 0; // 上升沿捕捉
ECap1Regs.ECCTL1.bit.CAP4POL = 1; // 下降沿捕捉
ECap1Regs.ECCTL1.bit.CTRRST1 = 1; // cap1捕捉事件不清零计数器
ECap1Regs.ECCTL1.bit.CTRRST2 = 1; // Difference operation
ECap1Regs.ECCTL1.bit.CTRRST3 = 1; // Difference operation
ECap1Regs.ECCTL1.bit.CTRRST4 = 1; // Difference operation
ECap1Regs.ECCTL1.bit.CAPLDEN = 1; // Enable capture units
ECap1Regs.ECCTL1.bit.FREE_SOFT = 3;

ECap1Regs.ECCTL2.bit.CAP_APWM = 0; //ECAP;
ECap1Regs.ECCTL2.bit.SYNCI_EN = 0; // Enable sync in
ECap1Regs.ECCTL2.bit.SYNCO_SEL = 2; // Pass through
ECap1Regs.ECCTL2.bit.TSCTRSTOP = 1; // Start Counter
ECap1Regs.ECCTL2.bit.REARM = 1; // arm one-shot
ECap1Regs.ECEINT.bit.CEVT4 = 0; // 4 events = interrupt
ECap1Regs.ECCTL2.bit.STOP_WRAP = 3;

ECap2Regs.ECEINT.all = 0x0000; // Disable all capture interrupts
ECap2Regs.ECCLR.all = 0xFFFF; // Clear all CAP interrupt flags
ECap2Regs.ECCTL1.bit.CAP1POL = 0; // 上升沿捕捉
ECap2Regs.ECCTL1.bit.CAP2POL = 1; // 下降沿捕捉
ECap2Regs.ECCTL1.bit.CAP3POL = 0; // 上升沿捕捉
ECap2Regs.ECCTL1.bit.CAP4POL = 1; // 下降沿捕捉
ECap2Regs.ECCTL1.bit.CTRRST1 = 1; // cap1捕捉事件不清零计数器
ECap2Regs.ECCTL1.bit.CTRRST2 = 1; // Difference operation
ECap2Regs.ECCTL1.bit.CTRRST3 = 1; // Difference operation
ECap2Regs.ECCTL1.bit.CTRRST4 = 1; // Difference operation
ECap2Regs.ECCTL1.bit.CAPLDEN = 1; // Enable capture units
ECap2Regs.ECCTL1.bit.FREE_SOFT = 3;

ECap2Regs.ECCTL2.bit.CAP_APWM = 0; //ECAP;
ECap2Regs.ECCTL2.bit.SYNCI_EN = 0; // Enable sync in
ECap2Regs.ECCTL2.bit.SYNCO_SEL = 2; // Pass through
ECap2Regs.ECCTL2.bit.TSCTRSTOP = 1; // Start Counter
ECap2Regs.ECCTL2.bit.REARM = 1; // arm one-shot
ECap2Regs.ECEINT.bit.CEVT4 = 1; // 4 events = interrupt
ECap2Regs.ECCTL2.bit.STOP_WRAP = 3;

ECap3Regs.ECEINT.all = 0x0000; // Disable all capture interrupts
ECap3Regs.ECCLR.all = 0xFFFF; // Clear all CAP interrupt flags
ECap3Regs.ECCTL1.bit.CAP1POL = 0; // 上升沿捕捉
ECap3Regs.ECCTL1.bit.CAP2POL = 1; // 下降沿捕捉
ECap3Regs.ECCTL1.bit.CAP3POL = 0; // 上升沿捕捉
ECap3Regs.ECCTL1.bit.CAP4POL = 1; // 下降沿捕捉
ECap3Regs.ECCTL1.bit.CTRRST1 = 1; // cap1捕捉事件不清零计数器
ECap3Regs.ECCTL1.bit.CTRRST2 = 1; // Difference operation
ECap3Regs.ECCTL1.bit.CTRRST3 = 1; // Difference operation
ECap3Regs.ECCTL1.bit.CTRRST4 = 1; // Difference operation
ECap3Regs.ECCTL1.bit.CAPLDEN = 1; // Enable capture units
ECap3Regs.ECCTL1.bit.FREE_SOFT = 3;

ECap3Regs.ECCTL2.bit.CAP_APWM = 0; //ECAP;
ECap3Regs.ECCTL2.bit.SYNCI_EN = 0; // Enable sync in
ECap3Regs.ECCTL2.bit.SYNCO_SEL = 2; // Pass through
ECap3Regs.ECCTL2.bit.TSCTRSTOP = 1; // Start Counter
ECap3Regs.ECCTL2.bit.REARM = 1; // arm one-shot
ECap3Regs.ECEINT.bit.CEVT4 = 1; // 4 events = interrupt
ECap3Regs.ECCTL2.bit.STOP_WRAP = 3;

ECap4Regs.ECEINT.all = 0x0000; // Disable all capture interrupts
ECap4Regs.ECCLR.all = 0xFFFF; // Clear all CAP interrupt flags
ECap4Regs.ECCTL1.bit.CAP1POL = 0; // 上升沿捕捉
ECap4Regs.ECCTL1.bit.CAP2POL = 1; // 下降沿捕捉
ECap4Regs.ECCTL1.bit.CAP3POL = 0; // 上升沿捕捉
ECap4Regs.ECCTL1.bit.CAP4POL = 1; // 下降沿捕捉
ECap4Regs.ECCTL1.bit.CTRRST1 = 1; // cap1捕捉事件不清零计数器
ECap4Regs.ECCTL1.bit.CTRRST2 = 1; // Difference operation
ECap4Regs.ECCTL1.bit.CTRRST3 = 1; // Difference operation
ECap4Regs.ECCTL1.bit.CTRRST4 = 1; // Difference operation
ECap4Regs.ECCTL1.bit.CAPLDEN = 1; // Enable capture units
ECap4Regs.ECCTL1.bit.FREE_SOFT = 3;

ECap4Regs.ECCTL2.bit.CAP_APWM = 0; //ECAP;
ECap4Regs.ECCTL2.bit.SYNCI_EN = 0; // Enable sync in
ECap4Regs.ECCTL2.bit.SYNCO_SEL = 2; // Passx through
ECap4Regs.ECCTL2.bit.TSCTRSTOP = 1; // Start Counter
ECap4Regs.ECCTL2.bit.REARM = 1; // arm one-shot
ECap4Regs.ECEINT.bit.CEVT4 = 1; // 4 events = interrupt
ECap4Regs.ECCTL2.bit.STOP_WRAP = 3;

EDIS;

Annie Liu:

为更加有效地解决您的问题,我们建议您将问题发布在E2E英文技术论坛上https://e2e.ti.com/support/microcontrollers/c2000/f/171,将由资深的工程师为您提供帮助。我们的E2E英文社区有TI专家进行回复,并得到全球各地工程师的支持,分享他们的知识和经验。

赞(0)
未经允许不得转载:TI中文支持网 » TMS320F280049的ECAP问题,请大神指点
分享到: 更多 (0)