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.

[参考译文] TMS320F280037:TZCTL 寄存器的 DCxEVT 有任何用例?

Guru**** 2391195 points
Other Parts Discussed in Thread: C2000WARE

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

https://e2e.ti.com/support/microcontrollers/c2000-microcontrollers-group/c2000/f/c2000-microcontrollers-forum/1199532/tms320f280037-any-use-case-for-dcxevt-of-tzctl-register

器件型号:TMS320F280037
主题中讨论的其他器件:C2000WARE

我们对  TZCTL 寄存器中的 DCAEVT1/2和 DCBEVT1/2感到困惑。 在实际应用中、通常将 TZA 和 TZB 与 TZSEL 一起配置为实现 CBC 或一次性保护。 但是、我尝试通过  DCAEVT1/2和 DCBEVT1/2启用操作、例如、强制为低电平、但考虑到 TZCTL 操作的以下优先级、需要将 TZA 设置为"什么都不做"、对吗? 但是、在 发生 DCAEVTx 事件时、EPWM 输出没有按预期变为低电平。
TZA (最高)-> DCAEVT1 -> DCAEVT2 (最低)

您能帮助说明一下 在 TZCTL 寄存器中 DCAEVT1/2和 DCBEVT1/2的用法吗? 谢谢你。

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

    Aki、您好!

    DCxEVTy 可配置为  触发相关的 TZA/B (TZSEL[DCxEVTy]= 1、DCxEVTy 行为不受独立控制) 、或 触发单独配置的事件(TZSEL[DCxEVTy]= 0、DCxEVTy 行为与 TZA/B 单独配置)。

    本质上、这意味着 DCxEVTy 事件既可以用作 TZA/B 的额外触发器、也可以完全用作单独事件的触发器。  我不记得曾经看到 TZSEL[DCxEVTy]= 1 和  DCxEVTy 行为是在 TZ 寄存器中独立配置的任何用例。 (这并不意味着它们不存在、但我不能想到它们需要这么做的任何原因。)

    我希望这是合理的!

    此致、

    Jason Osborn

    (作为一项优势、我相信这一点 主题 更详细地介绍这一点并提供示例行为。)

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

    大家好、Jason、

    如果使用  DCxEVTy 触发 单独配置的事件、如何处理 TZCTL 的 TZA/B 寄存器? 它应该 保持高阻抗、还是进行更改以 "什么都不做"?

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

    尊敬的 Aki:

    可以使用 TZSEL 寄存器(设置 TZSEL[DCxEVTy]= 0)将 DCxEVTy 与 TZA/B 断开、这意味着它们可以独立于 DCxEVTy 进行配置和使用。

    此致、

    Jason Osborn

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

    大家好、Jason、

    我明白你的意思了。

    但是、我尝试了测试此特性、PWM 输出不符合预期。 我按如下所示修改了 epwm_ex1_trip_zone 示例项目、其中使用的是 C2000WARE 4.00。

    您能帮我们仔细检查一下吗?

    //#############################################################################
    //
    // FILE:   epwm_ex1_trip_zone.c
    //
    // TITLE:  ePWM Using Trip-Zone Submodule.
    //
    //! \addtogroup driver_example_list
    //! <h1>ePWM Trip Zone</h1>
    //!
    //! This example configures ePWM1 and ePWM2 as follows
    //!  - ePWM1 has TZ1 as one shot trip source
    //!  - ePWM2 has TZ1 as cycle by cycle trip source
    //!
    //! Initially tie TZ1 high. During the test, monitor ePWM1 or ePWM2
    //! outputs on a scope. Pull TZ1 low to see the effect.
    //!
    //!  \b External \b Connections \n
    //!  - ePWM1A is on GPIO0
    //!  - ePWM2A is on GPIO2
    //!  - TZ1 is on GPIO12
    //!
    //! This example also makes use of the Input X-BAR. GPIO12 (the external
    //! trigger) is routed to the input X-BAR, from which it is routed to TZ1.
    //!
    //! The TZ-Event is defined such that ePWM1A will undergo a One-Shot Trip
    //! and ePWM2A will undergo a Cycle-By-Cycle Trip.
    //!
    //              _____________             __________________
    //              |           |             |                |
    //  GPIO12 -----| I/P X-BAR |-----TZ1-----| ePWM TZ Module |-----TZ-Event
    //              |___________|             |________________|
    //
    //
    //
    //#############################################################################
    //
    //
    // $Copyright:
    // Copyright (C) 2021 Texas Instruments Incorporated - http://www.ti.com/
    //
    // Redistribution and use in source and binary forms, with or without 
    // modification, are permitted provided that the following conditions 
    // are met:
    // 
    //   Redistributions of source code must retain the above copyright 
    //   notice, this list of conditions and the following disclaimer.
    // 
    //   Redistributions in binary form must reproduce the above copyright
    //   notice, this list of conditions and the following disclaimer in the 
    //   documentation and/or other materials provided with the   
    //   distribution.
    // 
    //   Neither the name of Texas Instruments Incorporated nor the names of
    //   its contributors may be used to endorse or promote products derived
    //   from this software without specific prior written permission.
    // 
    // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
    // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
    // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
    // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
    // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
    // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
    // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
    // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
    // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
    // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    // $
    //#############################################################################
    
    //
    // Included Files
    //
    #include "driverlib.h"
    #include "device.h"
    #include "board.h"
    
    //
    // Globals
    //
    uint32_t  epwm1TZIntCount;
    uint32_t  epwm2TZIntCount;
    uint16_t test_flag=0;
    //
    // Function Prototypes
    //
    void initEPWM1(void);
    void initEPWM2(void);
    __interrupt void epwm1TZISR(void);
    __interrupt void epwm2TZISR(void);
    
    void main(void)
    {
        //
        // Initialize global variables
        //
        epwm1TZIntCount = 0U;
        epwm2TZIntCount = 0U;
    
        //
        // Initialize device clock and peripherals
        //
        Device_init();
    
        //
        // Disable pin locks and enable internal pull-ups.
        //
        Device_initGPIO();
    
        //
        // Initialize PIE and clear PIE registers. Disables CPU interrupts.
        //
        Interrupt_initModule();
    
        //
        // Initialize the PIE vector table with pointers to the shell Interrupt
        // Service Routines (ISR).
        //
        Interrupt_initVectorTable();
    
        //
        // Interrupts that are used in this example are re-mapped to ISR functions
        // found within this file.
        //
        Interrupt_register(INT_EPWM1_TZ, &epwm1TZISR);
        Interrupt_register(INT_EPWM2_TZ, &epwm2TZISR);
    
        //
        // Configure ePWM1, ePWM2, and TZ GPIOs
        //
        Board_init();
    
        //
        // Disable sync(Freeze clock to PWM as well)
        //
        SysCtl_disablePeripheral(SYSCTL_PERIPH_CLK_TBCLKSYNC);
    
        //
        // Initialize ePWM1 and ePWM2
        //
        initEPWM1();
        initEPWM2();
    
        //
        // Enable sync and clock to PWM
        //
        SysCtl_enablePeripheral(SYSCTL_PERIPH_CLK_TBCLKSYNC);
    
        //
        // Enable interrupts required for this example
        //
        Interrupt_enable(INT_EPWM1_TZ);
        Interrupt_enable(INT_EPWM2_TZ);
    
        //
        // Enable Global Interrupt (INTM) and real time interrupt (DBGM)
        //
        EINT;
        ERTM;
    
        //
        // IDLE loop. Just sit and loop forever (optional):
        //
        for(;;)
        {
            NOP;
                if(test_flag==1)
                {
                    EPWM_forceTripZoneEvent(myEPWM1_BASE, EPWM_TZ_FORCE_EVENT_DCAEVT1);
    
                }
                else
                {
                    EPWM_clearTripZoneFlag(myEPWM1_BASE, EPWM_TZ_FLAG_DCAEVT1);
                }
        }
    }
    
    //
    // epwm1TZISR - ePWM1 TZ ISR
    //
    __interrupt void epwm1TZISR(void)
    {
        epwm1TZIntCount++;
    
        //
        // To re-enable the OST Interrupt, uncomment the below code:
        //
        // EPWM_clearTripZoneFlag(EPWM1_BASE,
        //                        (EPWM_TZ_INTERRUPT | EPWM_TZ_FLAG_OST));
    
        //
        // Acknowledge this interrupt to receive more interrupts from group 2
        //
        Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP2);
    }
    
    //
    // epwm2TZISR - ePWM2 TZ ISR
    //
    __interrupt void epwm2TZISR(void)
    {
        epwm2TZIntCount++;
    
        //
        // Toggle GPIO to notify when TZ is entered
        //
        GPIO_togglePin(myGPIO11);
    
        //
        // Clear the flags - we will continue to take this interrupt until the TZ
        // pin goes high.
        //
        EPWM_clearTripZoneFlag(myEPWM2_BASE, (EPWM_TZ_INTERRUPT | EPWM_TZ_FLAG_CBC));
    
        //
        // Acknowledge this interrupt to receive more interrupts from group 2
        //
        Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP2);
    }
    
    //
    // initEPWM1 - Configure ePWM1
    //
    void initEPWM1()
    {
        //
        // Enable TZ1 as one shot trip sources
    //    //
    //    EPWM_enableTripZoneSignals(myEPWM1_BASE, EPWM_TZ_SIGNAL_OSHT1);
    //
    //    //
    //    // Action on TZ1
    //    //
    //    EPWM_setTripZoneAction(myEPWM1_BASE,
    //                           EPWM_TZ_ACTION_EVENT_TZA,
    //                           EPWM_TZ_ACTION_DISABLE);
    
        EPWM_setTripZoneAction(myEPWM1_BASE,
                               EPWM_TZ_ACTION_EVENT_DCAEVT1,
                               EPWM_TZ_ACTION_HIGH);
        //
        // Enable TZ interrupt
        //
        EPWM_enableTripZoneInterrupt(myEPWM1_BASE, EPWM_TZ_INTERRUPT_OST);
    
        //
        // Set-up TBCLK
        //
        EPWM_setTimeBasePeriod(myEPWM1_BASE, 12000U);
        EPWM_setPhaseShift(myEPWM1_BASE, 0U);
        EPWM_setTimeBaseCounter(myEPWM1_BASE, 0U);
        EPWM_setTimeBaseCounterMode(myEPWM1_BASE, EPWM_COUNTER_MODE_UP_DOWN);
        EPWM_disablePhaseShiftLoad(myEPWM1_BASE);
    
        //
        // Set ePWM clock pre-scaler
        //
        EPWM_setClockPrescaler(myEPWM1_BASE,
                               EPWM_CLOCK_DIVIDER_4,
                               EPWM_HSCLOCK_DIVIDER_4);
    
        //
        // Set up shadowing
        //
        EPWM_setCounterCompareShadowLoadMode(myEPWM1_BASE,
                                             EPWM_COUNTER_COMPARE_A,
                                             EPWM_COMP_LOAD_ON_CNTR_ZERO);
    
        //
        // Set-up compare
        //
        EPWM_setCounterCompareValue(myEPWM1_BASE, EPWM_COUNTER_COMPARE_A, 6000U);
    
        //
        // Set actions
        //
        EPWM_setActionQualifierAction(myEPWM1_BASE,
                                      EPWM_AQ_OUTPUT_A,
                                      EPWM_AQ_OUTPUT_HIGH,
                                      EPWM_AQ_OUTPUT_ON_TIMEBASE_UP_CMPA);
        EPWM_setActionQualifierAction(myEPWM1_BASE,
                                      EPWM_AQ_OUTPUT_A,
                                      EPWM_AQ_OUTPUT_LOW,
                                      EPWM_AQ_OUTPUT_ON_TIMEBASE_DOWN_CMPA);
    }
    
    //
    // initEPWM2 - Configure ePWM2
    //
    void initEPWM2()
    {
        //
        // Enable TZ1 as one cycle-by-cycle trip sources
        //
        EPWM_enableTripZoneSignals(myEPWM2_BASE, EPWM_TZ_SIGNAL_CBC1);
    
        //
        // Action on TZ1
        //
        EPWM_setTripZoneAction(myEPWM2_BASE,
                               EPWM_TZ_ACTION_EVENT_TZA,
                               EPWM_TZ_ACTION_HIGH);
    
        //
        // Enable TZ interrupt
        //
        EPWM_enableTripZoneInterrupt(myEPWM2_BASE,
                                     EPWM_TZ_INTERRUPT_CBC);
    
        //
        // Set-up TBCLK
        //
        EPWM_setTimeBasePeriod(myEPWM2_BASE, 6000U);
        EPWM_setPhaseShift(myEPWM2_BASE, 0U);
        EPWM_setTimeBaseCounter(myEPWM2_BASE, 0U);
        EPWM_setTimeBaseCounterMode(myEPWM2_BASE, EPWM_COUNTER_MODE_UP_DOWN);
        EPWM_disablePhaseShiftLoad(myEPWM2_BASE);
    
        //
        // Set ePWM clock pre-scaler
        //
        EPWM_setClockPrescaler(myEPWM2_BASE,
                               EPWM_CLOCK_DIVIDER_4,
                               EPWM_HSCLOCK_DIVIDER_4);
    
        //
        // Set-up compare
        //
        EPWM_setCounterCompareValue(myEPWM2_BASE, EPWM_COUNTER_COMPARE_A, 3000U);
    
        //
        // Set actions
        //
        EPWM_setActionQualifierAction(myEPWM2_BASE,
                                      EPWM_AQ_OUTPUT_A,
                                      EPWM_AQ_OUTPUT_HIGH,
                                      EPWM_AQ_OUTPUT_ON_TIMEBASE_UP_CMPA);
        EPWM_setActionQualifierAction(myEPWM2_BASE,
                                      EPWM_AQ_OUTPUT_A,
                                      EPWM_AQ_OUTPUT_LOW,
                                      EPWM_AQ_OUTPUT_ON_TIMEBASE_DOWN_CMPA);
    }
    
    

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

    Aki、您好!

    为了确保、在运行时期间、在 CCS 调试中将 test_FLAG 的值设置为1以测试功能、对吗? 如果不是、默认情况下、该位设置为0、始终不会调整其值、并且不会在主循环中发生强制跳闸操作。

    快速浏览一下、我看不到另一个可能导致该问题的问题。 如果可能、您可以在输出上获得 TZFLG[DCAEVT1]吗?   如果不是与 TEST_FLAG 相关的问题、在这里能够准确地看到应该触发跳闸的时间将非常有帮助。

    此致、

    Jason Osborn