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.

[参考译文] CCS/TMS570LS1224:读取多个 eCAP 端口

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

https://e2e.ti.com/support/microcontrollers/arm-based-microcontrollers-group/arm-based-microcontrollers/f/arm-based-microcontrollers-forum/618282/ccs-tms570ls1224-reading-multiple-ecap-ports

器件型号:TMS570LS1224
主题中讨论的其他器件:HALCOGEN

工具/软件:Code Composer Studio

尊敬的所有人:

我已按照"example_etpwm_ecap.c"示例操作、并设法使其正常工作。 我想知道我需要如何修改代码才能读取多个 ECAP 模块、比如 ECAP3、4和5。 我目前有:

现在、我是否可以通过某种方法由哪个 ECAP 引起中断事件、以便能够读取相应的 CAP1、CAP2和 CAP3? 非常感谢!

我的代码如下:

/* include 文件*/

#include "sys_common.h"

//用户代码开始(1)*/
#include "stdio.h"
#include "system.h"
#include "etpwm.h"
#include "ecap.h"
//*用户代码结束*/**


@fn void main (void)
*@简要应用程序 main 函数
*







**/* void /用户代码结束*/*(void end)*/用户代码/* 2 / void 代码结束*/用户代码结束*
/*用户代码开始(3)*/

_enable_interrupt_();

#if 1
//使用 GUI 配置初始化 ePWM 和 ECAP */
etpwmInit();
ecapInit();
#else
/*用于配置 ETPWM 和 ECAP 的备用代码*//
*配置 ETPWG1 *//
*设置 TBCLK 频率= VpkInit (1
),设置为 VpwmCliv_1,按1设置 CtkmCliv_1 * 1,1设置 CtkmClkmCliv_1 (1)

/*将时间周期设置为1000ns (分频器值=(1000ns * 90MHz)- 1 = 89)*/
etpwmSetTimebasePeriod (etpwmREG1、89);

//将比较 A 值配置为时间周期的一半*/
etpwmSetCmpA (etpwmREG1、45);

//配置 mthe 模块,在 CTR=0时将 PWMA 值设置为1,在 CTR=CmpA 时将 PWMA 值设置为0 */
etpwmActionQualConfig_t configPWMA;
configPWMA.CtrlEqZero_Action = ActionQUAL_SET;
configPWMA.configEqAction_Action = Disabled_CmpAUP_Action;
CONFIGPWMA.CMAP_CAL.Imped_Action_Ed_Disabled;CONFIGAP_Imped_Imped_Impedance = Impedance;CONFIGPQ_Impedance = Impedance

configPWMA.CtrlEqCmpBUp_Action = ActionQual_Disabled;
configPWMA.CtrlBBDown _Action = ActionQual_Disabled;
etpwmSetActionPwmA (etpwmREG1、configPWMA);

// ActionCountermode 中的 Start 计数器*/
etpwmCount (etpwmREG1、SetPWMA);// SetStartCountermode (etpwmCwmCwm0);SetPwmCwmCwpwmCpwmCwmCwmCount (etwmCwpwmRpwpwmCw0)
;
Set

/*配置 ECAP1 */*
配置事件1以捕获上升沿*/
ecapSetCaptureEvent1 (ecapREG1、上升沿、RESET_DISABLE);

/*配置事件2以捕获下降沿*/
ecapSetCaptureEvent2 (ecapREG1、下降沿、RESET_DISABLE);

//配置事件3以启用上升沿、
ecapSetCaptureEvent2 (ecapREG1);启用上升沿计数器*以启用上升沿、ecapture_reset_reset_reset/复位

//将 Capure 模式设置为连续事件,并将事件后续处理为 CAP3 */
ecapSetCaptureMode (ecapREG1,Continuous,CAPTURE_EVENT3);

//开始计数器*/
ecapStartCounter (ecapREG1);

//启用 Capture 上的加载*/
ecapEnableCapture (ecapREG1);

//启用 CAP3事件的中断#ecapStartInt


,ecapenableInterrupt
/*... 永久运行*/
while (1);

/*用户代码结束*/
}

/*用户代码开始(4)*/
void ecapNotification (ecapBASE-t * ECAP、uint16标志)
{
uint32 cap1、CAP2、cap3;
float64占空比、周期;

CAP1 = ecapGetCAP1 (ecapREG1);
CAP2 = ecapGetCAP2 (ecapREG1);
cap3 = ecapGetCAP3 (ecapREG1);

Duty =(CAP2 - CAP1)* 1000/VCLK4_FREQ;
period =(cap3 - cap1) print1000/VCLK4_FREQ;duty =

%fn
(%fn)、duty =%fn、duty

=%fn ("、%fn)、duty =%fns"、%frandy =%fns、%fn、"ns"
/*用户代码结束*/ 

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

    您好、索非亚、

    您也可以在另一个通道上使用相同的配置、只需更改寄存器、因此、如果您希望使用 ECAP CH3、则需要将寄存器从 ecapREG1更改为 ecapREG3。 我认为根据通知函数参数(ecapbase_t * ECAP),您可以决定哪个 ECAP 通道导致了触发。  

    此致、

    Norbert

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

    您好、Sofia、

    1.启用 ECAP 驱动器

    2.在 VIM 中启用 ECAP 中断:针对 ecap3的 VIM 通道106、 针对 ecap4的 VIM 通道107、 针对 ecap5的 VIM 通道108

    3.启用 ECAP 模块:ecap3、ecap4、ecap5

    4.配置 ecap3、ecap4、ecap5:单次触发或连续、捕捉所有事件的极性、为事件3启用中断等

    5. HalCoGen 将生成带有中断例程的代码

    #pragma CODE_STATE (ecap3nterrupt、32)
    #pragma INTERRUPT (ecap3nterrupt、IRQ)

    /* sourceId:ECAP_sourceId_034 */
    /* DesignId:ECAP_DesignId_021 */
    /*要求:HL_ECAP_SR15 */
    void ecap3nterrupt (void)
    {…

    /*将中断标志传递给用户通知功能*/
    ecapNotification (ecapREG3、Int_Flag);

    6.在 ecapNotification 函数中,使用 ECAP 确定哪个模块(ecap3/4/5)是中断

    void ecapNotification (ecapBASE-t * ECAP、uint16标志) 
    IF (ECAP = ecapREG3) 
    CAP1 = ecapGetCAP1 (ecapREG3);
    CAP2 = ecapGetCAP2 (ecapREG3);
    cap3 = ecapGetCAP3 (ecapREG3);
    
    Duty =(CAP2 - CAP1)* 1000/VCLK4_FREQ;
    period =(cap3 - cap1) print1000/VCLK4_FREQ;duty =
    
    %fn
    (%fx)、duty =%fn ("、%fruty =%fn); 
    如果(ECAP = ecapREG4) 
    等等