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.
器件型号:TMS570LS1224PGE
您好!
我们目前遇到的问题与本主题中所述的完全相同:
不幸的是,除了"它应该以这种方式工作"之外,没有提供任何解决办法。
我们使用"example_etpwm_ecap"示例成功设置 ECAP 读数。 即使占空比或周期发生轻微变化、它也能正常运行。
但是、我们需要采集67Hz、3.3V 的 PWM、占空比约为10-20%、与示例中生成的 PWM 相比、这非常慢。 理论上、应该可以在计数器溢出之前捕获周期长度高达53秒的信号。
当尝试读取我们的慢速信号时、所有 ECAP 计数器都显示相同的值、因此我们只将占空比和周期值设置为零。 看起来所有捕捉事件都同时发生、并且同时触发上升沿和下降沿。
我们已经通过不同的来源生成了所需的信号(以及类似的信号)、以确保我们的信号源不是问题所在。 示波器中的信号看起来很好。
为什么该示例不适用于低频信号? 读取相对较慢的信号需要做些什么?
此致
克里斯蒂安
/** @example example_etpwm_ecap.c * This is an example which describes the steps to configure ETPWM for generating PWM signal * and ECAP to capture the same and calculate its frequency and duty cycle,Here ETPWM1A pin is configured * to generate a PWM wave and is fed to ECAP1 pin. * * * @b Step @b 1: * * Create a new project. * * Navigate: -> File -> New -> Project * * @image html example_createProject.jpg "Figure: Create a new Project" * * @b Step @b 2: * * Configure driver code generation: * - Enable ETPWM and ECAP drivers * - Disable others * * Navigate: -> TMS570LS12x/RM46 -> Enable Drivers * * @b Step @b 3: * * Configure PINMUX to enable ETPWM1A and ECAP1 pins (or enable ETPWM and ECAP checkboxes) * * Navigate: -> PINMUX -> Pin Muxing * * Enable TBCLK sync * * Navigate: -> PINMUX -> Special Pin Muxing * * @b Step @b 4: * * Enable ECAP1 Interrupt in VIM (Channel 104) * * Navigate: -> TMS570LS12x/RM46 -> VIM Channel 96-127 * * @b Step @b 4: * * Configure EPWM1A with specified duty and period * * @image html etpwm_module_enable.jpg "Figure: Enable ETPWM modules" * @image html etpwm_config.jpg "Figure: EPWM1A configuration" * * @b Step @b 5: * * Configure ECAP1 as follows * * @image html ecap_module_enable.jpg "Figure: Enable ETPWM modules" * @image html ecap_config.jpg "Figure: EPWM1A configuration" * * @b Step @b 6: * * Connect the pin ETPWM1A and ECAP1: * * * @b Step @b 7: * * Copy the source code below into your sys_main.c or replace sys_main.c with this file. * * The example file can also be found in the examples folder: ../HALCoGen/examples * * @note HALCoGen generates an empty main function in sys_main.c, * * */ /* * Copyright (C) 2009-2015 Texas Instruments Incorporated - 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. * */ /* USER CODE BEGIN (0) */ /* USER CODE END */ /* Include Files */ #include "sys_common.h" /* USER CODE BEGIN (1) */ #include "stdio.h" #include "system.h" #include "etpwm.h" #include "ecap.h" /* USER CODE END */ /** @fn void main(void) * @brief Application main function * */ /* USER CODE BEGIN (2) */ /* USER CODE END */ void main(void) { /* USER CODE BEGIN (3) */ _enable_interrupt_(); #if 1 /* Initialise EPWM and ECAP with GUI configuration */ etpwmInit(); ecapInit(); #else /* Alternate code for configuring ETPWM and ECAP */ /* Configure ETPWM1 */ /* Set the TBCLK frequency = VCLK4 frequency = 90MHz */ etpwmSetClkDiv(etpwmREG1, ClkDiv_by_1, HspClkDiv_by_1); /* Set the time period as 1000 ns (Divider value = (1000ns * 90MHz) - 1 = 89)*/ etpwmSetTimebasePeriod(etpwmREG1, 89); /* Configure Compare A value as half the time period */ etpwmSetCmpA(etpwmREG1, 45); /* Configure mthe module to set PWMA value as 1 when CTR=0 and as 0 when CTR=CmpA */ etpwmActionQualConfig_t configPWMA; configPWMA.CtrEqZero_Action = ActionQual_Set; configPWMA.CtrEqCmpAUp_Action = ActionQual_Clear; configPWMA.CtrEqPeriod_Action = ActionQual_Disabled; configPWMA.CtrEqCmpADown_Action = ActionQual_Disabled; configPWMA.CtrEqCmpBUp_Action = ActionQual_Disabled; configPWMA.CtrEqCmpBDown_Action = ActionQual_Disabled; etpwmSetActionQualPwmA(etpwmREG1, configPWMA); /* Start counter in CountUp mode */ etpwmSetCount(etpwmREG1, 0); etpwmSetCounterMode(etpwmREG1, CounterMode_Up); etpwmStartTBCLK(); /* Configure ECAP1 */ /* Configure Event 1 to Capture the rising edge */ ecapSetCaptureEvent1(ecapREG1, RISING_EDGE, RESET_DISABLE); /* Configure Event 2 to Capture the falling edge */ ecapSetCaptureEvent2(ecapREG1, FALLING_EDGE, RESET_DISABLE); /* Configure Event 3 to Capture the rising edge with reset counter enable */ ecapSetCaptureEvent3(ecapREG1, RISING_EDGE, RESET_ENABLE); /* Set Capure mode as Continuous and Wrap event as CAP3 */ ecapSetCaptureMode(ecapREG1, CONTINUOUS, CAPTURE_EVENT3); /* Start counter */ ecapStartCounter(ecapREG1); /* Enable Loading on Capture */ ecapEnableCapture(ecapREG1); /* Enable Interrupt for CAP3 event */ ecapEnableInterrupt(ecapREG1, ecapInt_CEVT3); #endif /* ... run forever */ while(1); /* USER CODE END */ } /* USER CODE BEGIN (4) */ void ecapNotification(ecapBASE_t *ecap,uint16 flags) { uint32 cap1, cap2, cap3; float64 duty, period; cap1 = ecapGetCAP1(ecapREG1); cap2 = ecapGetCAP2(ecapREG1); cap3 = ecapGetCAP3(ecapREG1); duty = (cap2 - cap1)*1000/VCLK4_FREQ; period = (cap3 - cap1)*1000/VCLK4_FREQ; printf("Duty = %fns\n", duty); printf("Period = %fns\n\n", period); } /* USER CODE END */
尊敬的 Christian:
您能否通过将 VCLK3时钟频率降至10MHz 来重新验证?
因为 eCAP 模块中的时基计数器将仅通过 VCLK3运行、因此如果我们降低该频率、我们就可以测量低频。
--
谢谢。此致、
Jagadish。
Jagadish、您好!
感谢您的答复。
我们使用的是电路板 TMS570LS1224PGE、而不是...1227。
我刚刚将 用于计算的 VCLK4以及 VCLK3更改为10MHz。
它没有更改 结果。
我们始终为不同的电容器变量获得相同的值、因此无法计算占空比或周期-另请参阅附件。
如果我们生成更快的信号、它仍然可以正常工作。
尊敬的 Christian:
我了解了您遇到的问题的根本原因。
实际上、这个问题并不是由 eCAP 模块造成的、而是由 ETPWM 模块造成的。 我的意思是、您是否确认您是从市场获得67Mhz 输出、
示波器的 ETPWM 模块?
实际上、ETPWM 不会从75MHz 的实际 TB 时钟频率中生成如此低的频率。 我在实践中进行了测试、发现了这个问题。
为了从 ETPWM 模块生成此类低频、我们应该如下所示调整预分频器:
调整如上所示的预分频器后、我从 ETPWM 获得了67Hz 的输出波形、如下所示:
现在您可以看到、我得到了67Hz 输入波形的捕获寄存器值:
下面是我经过测试的工程、供您参考:
e2e.ti.com/.../ECAP_5F00_TEST_5F00_LC4357.zip
注意:由于我没有 TMS570LS12x 板、因此我使用 TMS570LC43x Launchpad 板进行了该测试。
--
谢谢。此致、
Jagadish。
Jagadish、您好!
再次感谢您的答复。
我们不使用 ETPWM 模块生成慢信号。 我们已经试过实际的信号源(RC 接收器)和一个信号发生器、但是捕捉不能使用它们中的任何一个。 因此、问题在于 ECAP 模块。 如果我们生成高于大约200 kHz 的快速信号、捕获就可以很好地工作。 如果信号变得较慢、低于大约100 kHz、捕获将不再起作用。
感谢您分享详细信息。
我将尝试与其他板检查,并将为您提供,我的更新。
尊敬的 Christian:
我也使用了 RM46板进行了测试、而且此控制器与 TMS570LS12x 相同、而且在这里、我没有看到 ETPWM 的100Hz 频率输出有任何问题。
因此、我的建议是、在使用功能发生器进行测试之前、请尝试使用 ETPWM 信号进行测试一次、因为它是一个外部振荡器、可能会出现接地问题。 请使用我的代码进行测试一次、并告知我结果、我将附上我的 RM46代码供您参考。
e2e.ti.com/.../ECAP_5F00_TEST_5F00_RM46.zip
--
谢谢。此致、
Jagadish。
Jagadish、您好!
感谢您的支持。 它现在正在工作。 首先、我尝试读取 ETPWM 引脚生成的慢(100Hz)信号、工作正常。
然后、我们尝试了不同的信号源、但它不能像以前那样正常工作。
当我们删除所有 printf 命令和断点并将占空比和周期写入全局变量后、这个方法就开始起作用了。 因此、printf 中断和/或导致此问题的断点似乎会引起某种计时问题。
但是问题现已解决,再次感谢。
此致
克里斯蒂安