您好!
我一直在尝试按照用户指南文档中的说明使用 DCL 基准发生器来生成正弦波。
我正在从配置为10us 的 timer0的 ISR 中读取结果。 不过、我会一直得到一个常数值1、无论我尝试生成的波形如何、该值都没有变化。
我认为我正确地遵循了指南中的实施步骤、但我无法弄清为什么我始终得到结果1。
如果能就这一问题提供一些帮助,我将不胜感激。
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.
您好!
我一直在尝试按照用户指南文档中的说明使用 DCL 基准发生器来生成正弦波。
我正在从配置为10us 的 timer0的 ISR 中读取结果。 不过、我会一直得到一个常数值1、无论我尝试生成的波形如何、该值都没有变化。
我认为我正确地遵循了指南中的实施步骤、但我无法弄清为什么我始终得到结果1。
如果能就这一问题提供一些帮助,我将不胜感激。
尊敬的 Sira:
我在下面附上了我的代码:
//############################################################################# // // FILE: empty_driverlib_main.c // //! \addtogroup driver_example_list //! <h1>Empty Project Example</h1> //! //! This example is an empty project setup for Driverlib development. //! // //############################################################################# // // // $Copyright: // Copyright (C) 2023 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" #include "c2000ware_libraries.h" #include <DCL_refgen.h> // variable declarations DCL_REFGEN rgen = DCL_REFGEN_DEFAULTS; DCL_CSS rgen_css = DCL_CSS_DEFAULTS; int i; float32_t x; interrupt void ISRTimer0(void); void initTimer(void); // // Main // void main(void) { // // 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(); // // PinMux and Peripheral Initialization // Board_init(); // // C2000Ware Library initialization // C2000Ware_libraries_init(); // // Enable Global Interrupt (INTM) and real time interrupt (DBGM) // EINT; ERTM; rgen.css = &rgen_css; DCL_SET_CONTROLLER_PERIOD(&rgen, 0.0001); DCL_resetRefgen(&rgen); DCL_setRefgenMode(&rgen, REFGEN_SINE); DCL_setRefgenFreq(&rgen, 50.0f, 0.0f); DCL_setRefgenAmpl(&rgen, 0.25f, 0.0f); //DCL_setRefgenRamp(&rgen, 0.15f, 0.01f); initTimer(); while(1) { } } // // End of File // void initTimer(void) { Interrupt_register(INT_TIMER0, &ISRTimer0); SysCtl_enablePeripheral(SYSCTL_PERIPH_CLK_TIMER0); asm(" RPT #5 || NOP"); CPUTimer_setPeriod (CPUTIMER0_BASE, 100000); CPUTimer_setPreScaler (CPUTIMER0_BASE, 0); CPUTimer_stopTimer(CPUTIMER0_BASE); CPUTimer_reloadTimerCounter(CPUTIMER0_BASE); CPUTimer_setEmulationMode(CPUTIMER0_BASE, CPUTIMER_EMULATIONMODE_STOPAFTERNEXTDECREMENT); CPUTimer_clearOverflowFlag(CPUTIMER0_BASE); /**< enable interrupt of the timer */ CPUTimer_enableInterrupt(CPUTIMER0_BASE); /**< enable cpu interrupt number 13 for the timer 1 interrupt */ Interrupt_enable(INT_TIMER0); /**< start timer */ CPUTimer_startTimer(CPUTIMER0_BASE); } interrupt void ISRTimer0(void) { DCL_runRefgen(&rgen); i++; x = DCL_getRefgenPhaseA(&rgen); Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP1); }
我也在链接器文件中执行了此操作: dclfuncs:> RAMGS1、 page = 0
谢谢。
阿洛巴。
Atoba,
我注意到您有
DCL_SET_CONTROL_PERIOD (&rgen、0.0001);
它对应于0.1ms、即100us、而您的 ISR 是10us。
我认为您需要
DCL_SET_CONTROL_PERIOD (&rgen、0.00001);
如果这样不起作用,请尝试在 DCL_refgen.h 的 DCL_runRefgen()中放入一个断点,并检查 p->mode、p->theta、p->ya 的值。
谢谢。
Sira
因此、模式看起来是正确的(2 = REFGEN_Sine)、θ 值似乎正在按预期更新。 但每种情况下 ya 为1、这是错误的。
您的项目中是否启用了 TMU? 您能否在这里放置断点、在反汇编视图中查看生成的代码并查看是否生成了 SINPUF32?
谢谢。
Sira