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.

LAUNCHXL-F280049C: DCL REFERENCE GENERATOR

Part Number: LAUNCHXL-F280049C


Hello,

I've been attempting to use the DCL reference generator, following the instructions in the user's guide document, to generate a sine wave.

I'm reading the results from the ISR of timer0 configured for 10us. However, I'm consistently getting a constant value of 1, and this doesn't change regardless of the waveform I'm trying to generate.

I believe I've followed the implementation steps in the guide correctly, but I'm unable to figure out why I'm always getting a result of 1.

I would greatly appreciate some assistance with this issue.

  • Can you please paste the snippet of code you're using to generate the ref signal?

  • Hi Sira,

    I've attached my code below:

    //#############################################################################
    //
    // 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);
    }
    

    I also did this in the linker file: dclfuncs : > RAMGS1,    PAGE = 0

    Thanks,

    Aloba.

  • Please give me a day or so to review this and get back to you. Unfortunately we currently don't have an example for this in DCL, I will also try to work on a plan to create one.

  • Hello Sira,

    I'd like to gently remind you that I'm eagerly awaiting your feedback.

  • Aloba,

    I noticed you have

    DCL_SET_CONTROLLER_PERIOD(&rgen, 0.0001);

    which corresponds to 0.1ms i.e. 100us, whereas your ISR is at 10us.

    I believe you need

    DCL_SET_CONTROLLER_PERIOD(&rgen, 0.00001);

    If this doesn't help, try putting a breakpoint inside DCL_runRefgen() in DCL_refgen.h and checking the values of p->mode, p->theta, p->ya.

    Thanks,

    Sira

  • Hello Sira,

    I've adjusted the parameter of DCL_SET_CONTROLLER_PERIOD() as recommended, but I haven't noticed any changes so far. I've captured snapshots of the values of 'p' within DCL_runRefgen() from DCL_refgen.h at 5 different intervals, and I've attached them.

    It's possible that there's something I'm missing or not understanding correctly.

    Thank you,

    Aloba.

  • So the mode looks correct (2 = REFGEN_SINE), and the theta values seem to be updating as expected. But the ya is 1 in each case, so that's wrong.

    Do you have the TMU enabled in your project? Can you place a breakpoint there, look at the generated code in the disassembly view and see whether SINPUF32 is generated?

    #ifdef __TMS320C28XX_TMU__
                p->ya = __sinpuf32(p->theta);
            #else
                p->ya = sinf(CONST_2PI_32 * p->theta);
            #endif

    Thanks,

    Sira

  • Hello Sira,

    TMU0 is enabled, and here is the disassembly output.

    Best regards,
    Aloba

  • Aloba,

    Please step through the instructions from 00e26a to 00e274 and look at the corresponding values in ACC, R0H etc. to understand what is happening. That may give a clue about why theta is non-zero but ya is 1.

    Thanks,

    Sira 

  • I've followed the instructions and checked if there were any changes in the ACC or R0H parameters, but I didn't find any.

    Also, I must admit that while the instructions are in assembly language, I don't fully understand the language and much of what I see in the disassembler.

  • Aloba,

    What I mean is check them as you step through the code from 00e26a to 00e274. Please send a screenshot of the register view window in CCS with these (ACC, R0H) and also p->theta, p-> ya.