This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

[参考译文] TMS320F28069:设置 eCAP 模块内的中断触发器和 CAP 值(实验7)

Guru**** 2540720 points


请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/microcontrollers/c2000-microcontrollers-group/c2000/f/c2000-microcontrollers-forum/1201879/tms320f28069-setting-interrupttriggers-and-cap-values-within-the-ecap-module-lab-7

器件型号:TMS320F28069

我遵循了在 F2806x Workshop (TI.com)中找到的实验

我感谢这些指南的帮助、因为它们使我对不同的模块有了良好的/概括性的了解。

目前、我正在进行实验7、最后有几个问题:

PwmDuty 和 PwmPeriod 的捕获值与 ePWM1A 的比较寄存器 CMPA 和时基周期 TBPRD 设置有何关系?
•PwmDuty 在内存中的价值是什么?  
•PwmPeriod 在内存中的值是多少?
•它与预期值相比如何?

我的答案是:

PwmDuty: 4294951119.

PwmPeriod: 4294951119

预计值:根据 CMPA、我预计 CMPA = 75%∗TBPRD=0.75∗TBPRD=16875

其中 TBPRD 为 TBPRD=1/2∗ 90MHz/2kHz=22500

在 ECAP1_INT 的 ISR 内的调试会话中:

CAP1的值为  4294951119

而 CAP2和 CAP3保持为0

相应的 ISR 如所示  

interrupt void ECAP1_INT_ISR(void)				// PIE4.1 @ 0x000D70  ECAP1_INT
{
	PieCtrlRegs.PIEACK.all = PIEACK_GROUP4;		// Must acknowledge the PIE group

	ECap1Regs.ECCLR.bit.INT = 1;				// Clear the ECAP1 interrupt flag
	ECap1Regs.ECCLR.bit.CEVT3 = 1;				// Clear the CEVT3 flag

// Compute the PWM duty period (rising edge to falling edge)
	PwmDuty = (int32)ECap1Regs.CAP2 - (int32)ECap1Regs.CAP1;

// Compute the PWM period (rising edge to rising edge)
	PwmPeriod = (int32)ECap1Regs.CAP3 - (int32)ECap1Regs.CAP1;

}

我根据 ECAP_7_8_9_10_12.c 的解决方案调整了注册表条目:

	ECap1Regs.ECCTL2.all = 0x0096;				// ECAP control register 2
// bit 15-11     00000:  reserved
// bit 10        0:      APWMPOL donot care
// bit 9         0:      CAP/APWM, select Capture mode instead of APWM mode
// bit 8         0:      SWSYNC donot care
// bit 7-6       10:     SYNCO_SEL Sync-Out Select disabled, i.e. 1x
// bit 5         0:      SYNCI_EN (sync disbale)
// bit 4         1:      TSCTRSTOP timer stamp counter run
// bit 3         0:      RE-ARM rearm disable
// bit 2-1       11:     STOP_WRAP wrap capture after capture event 4
// bit 0         0:      CONT/ONESHT  continuous mode

	ECap1Regs.ECCTL1.all = 0xC144;				// ECAP control register 1
// bit 15-14     11:     FREE/SOFT, 11 = ignore emulation suspend
// bit 13-9      00000:  PRESCALE divide by 1
// bit 8         1:      CAPLDEN CAP1-4: Load on Capture Event - enable
// bit 7         0:      CTRRST4 donot care
// bit 6         1:      CAP4POL trigger on falling (1) edge
// bit 5         0:      CTRRST3
// bit 4         0:      CAP3POL trigger on rising (0) edge
// bit 3         0:      CTRRST2
// bit 2         1:      CAP2POL trigger on falling (1) edge
// bit 1         0:      CTRRST1
// bit 0         0:      CAP1POL trigger on rising (0) edge

	ECap1Regs.ECEINT.all = 0x0002;				// Enable desired eCAP interrupts
// bit 15-8      0's:    reserved
// bit 7         0:      CTR=CMP donot care
// bit 6         0:      CTR=PRD donot care
// bit 5         0:      CTROVF  donot care
// bit 4         0:      CEVT4 disable
// bit 3         0:      CEVT3 disable
// bit 2         0:      CEVT2 disable
// bit 1         1:      CEVT1 enable
// bit 0         0:      reserved

	PieCtrlRegs.PIEIER4.bit.INTx1 =1;   // Enable ECAP1_INT in PIE group 4
	IER |= 0x0008;         

与该解决方案相比、唯一的区别在于 ECEINT。 当我选择0x0002时、该解决方案建议使用0x0008。 以某种方式、如果使用解决方案的建议、则没有中断。

这里有两个问题:

为什么 CAP2和 CAP3值为0?

为什么我不能使用其他活动? 这里的数字表明、如果我理解正确的话、在多少个事件之后应该触发一个中断?

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    大家好,Mehmet,

    CAP1/2/3/4将在上升沿或下降沿到达定义的触发器之前捕获所捕获的 SYSCLK 周期数。 根据设置、在上升沿触发 CAP1。  4294951119的值似乎不正确、CAP2和 CAP3也不应为零。  

    为了对此进行调试、我会排除您使用 GPIO 的 PWM 输出。 即第1步、确保 PWM 输出信号供 eCAP 进行捕获。 如果可以、您能否发送该输出的屏幕截图。

    在对其进行验证之后、我们可以调试 eCAP。  

    对于 eCAP、我认为您需要为第一个捕获事件生成中断。 (CAP1)然而、在您的 ISR 中、你清除 CEVT3。  

    ECap1Regs.ECCLR.bit.CEVT3 = 1;				// Clear the CEVT3 flag

    为解决方案选择的中断为0x0008或启用 CAP4中断。 这意味着在第四次捕获时、您将已经捕获了发生边沿的所有边沿。 我建议按照该图捕获所有边沿、看看它是否与您的实际 PWM 周期相匹配。

    Unknown 说:
    当我选择了0x0002时、解决方案建议使用0x0008。 不知何故,如果使用解决方案的建议,就没有中断。[/引号]

    如果 您可以发送 PWM 和 CAP1/CAP2/CAP3/CAP4值的一些示波器图片。  

    此致!

    Ryan Ma