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-F280025C: identifier "PieCtrlRegs" is undefined

Part Number: LAUNCHXL-F280025C
Other Parts Discussed in Thread: C2000WARE

Hi, 

what's header file I should include for PieCtrlRegs  ?

If refer to example like adc_ex1_soc_epwm.c which include f28x_project.h then I've got below errors :

"/Users/dannychan/ti/C2000Ware_MotorControl_SDK_4_02_01_00/c2000ware/device_support/f28002x/headers/include/f28002x_nmiintrupt.h", line 159: error #41: expected an identifier

"/Users/dannychan/ti/C2000Ware_MotorControl_SDK_4_02_01_00/c2000ware/device_support/f28002x/headers/include/f28002x_nmiintrupt.h", line 170: error #41: expected an identifier

"/Users/dannychan/ti/C2000Ware_MotorControl_SDK_4_02_01_00/c2000ware/device_support/f28002x/headers/include/f28002x_nmiintrupt.h", line 180: error #41: expected an identifier

"/Users/dannychan/ti/C2000Ware_MotorControl_SDK_4_02_01_00/c2000ware/device_support/f28002x/headers/include/f28002x_lin.h", line 236: error #41: expected an identifier

"/Users/dannychan/ti/C2000Ware_MotorControl_SDK_4_02_01_00/c2000ware/device_support/f28002x/headers/include/f28002x_lin.h", line 236: error #80: expected a type specifier

"/Users/dannychan/ti/C2000Ware_MotorControl_SDK_4_02_01_00/c2000ware/device_support/f28002x/headers/include/f28002x_lin.h", line 236: error #170: a function type is not allowed here

"/Users/dannychan/ti/C2000Ware_MotorControl_SDK_4_02_01_00/c2000ware/device_support/f28002x/headers/include/f28002x_lin.h", line 236: warning #109-D: signed bit field of length 1

"/Users/dannychan/ti/C2000Ware_MotorControl_SDK_4_02_01_00/c2000ware/device_support/f28002x/common/include/f28002x_globalprototypes.h", line 92: error #41: expected an identifier

"/Users/dannychan/ti/C2000Ware_MotorControl_SDK_4_02_01_00/c2000ware/device_support/f28002x/common/include/f28002x_globalprototypes.h", line 92: error #80: expected a type specifier

"/Users/dannychan/ti/C2000Ware_MotorControl_SDK_4_02_01_00/c2000ware/device_support/f28002x/common/include/f28002x_globalprototypes.h", line 92: error #91: function returning function is not allowed

Danny

  • Hi Danny,

    what's header file I should include for PieCtrlRegs  ?

    PieCtrlRegs are defined in \device_support\f28002x\headers\source\f28002x_globalvariabledefs.c file.

    You can add this in your project properties.

    Thanks

    Aswin

  • Hi Aswin,

    do you mean I drag the file into my project like below ? but it not work :(

    Danny

  • Hi Danny,

    Can you confirm if the file path has been included in the example properties, if not please add it and try again.

    Right click on the example -> properties -> C2000 compiler -> include option . Add the file path for the headers.

    Thanks

    Aswin

  • Hi Aswin,

    Yes I did but no luck :(

    Danny

  • Hi Danny,

    Please add the include path in the file path option and try.

    Thanks

    Aswin

  • Hi Aswin,

    yes both include and source paths added but still no luck !

    Danny

  • Hi Danny,

    Were you able to build the ADC_ex1_soc example, without changing any settings?

  • yes I can import and build ADC_ex1_soc

  • The PIECTRL regs are also present in the src_device -> device support folder.

    I am not sure why it is not picking the registers from this folder.

    Can you please attach the example for further debug?

    Thanks

    Aswin

  • Do you mean the adc_ex1_soc file ? 

    //#############################################################################

    //

    // FILE:   adc_ex1_soc_epwm.c

    //

    // TITLE:  ADC ePWM Triggering

    //

    //! \addtogroup bitfield_example_list

    //! <h1>ADC ePWM Triggering</h1>

    //!

    //! This example sets up ePWM1 to periodically trigger a conversion on ADCA.

    //!

    //! \b External \b Connections \n

    //!  - A1 should be connected to a signal to convert

    //!

    //! \b Watch \b Variables \n

    //! - \b adcAResults - A sequence of analog-to-digital conversion samples from

    //!   pin A1. The time between samples is determined based on the period

    //!   of the ePWM timer.

    //!

    //

    //#############################################################################

    //

    //

    // $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 "f28x_project.h"

    //

    // Defines

    //

    #define RESULTS_BUFFER_SIZE     256

    //

    // Globals

    //

    uint16_t adcAResults[RESULTS_BUFFER_SIZE];   // Buffer for results

    uint16_t index;                              // Index into result buffer

    volatile uint16_t bufferFull;                // Flag to indicate buffer is full

    //

    // Function Prototypes

    //

    void initADC(void);

    void initEPWM(void);

    void initADCSOC(void);

    __interrupt void adcA1ISR(void);

    //

    // Main

    //

    void main(void)

    {

        //

        // Initialize device clock and peripherals

        //

        InitSysCtrl();

        //

        // Initialize GPIO

        //

        InitGpio();

        //

        // Disable CPU interrupts

        //

        DINT;

        //

        // Initialize the PIE control registers to their default state.

        // The default state is all PIE interrupts disabled and flags

        // are cleared.

        //

        InitPieCtrl();

        //

        // Disable CPU interrupts and clear all CPU interrupt flags:

        //

        IER = 0x0000;

        IFR = 0x0000;

        //

        // Initialize the PIE vector table with pointers to the shell Interrupt

        // Service Routines (ISR).

        //

        InitPieVectTable();

        //

        // Map ISR functions

        //

        EALLOW;

        PieVectTable.ADCA1_INT = &adcA1ISR;     // Function for ADCA interrupt 1

        EDIS;

        //

        // Configure the ADC and power it up

        //

        initADC();

        //

        // Configure the ePWM

        //

        initEPWM();

        //

        // Setup the ADC for ePWM triggered conversions on channel 1

        //

        initADCSOC();

        //

        // Enable global Interrupts and higher priority real-time debug events:

        //

        IER |= M_INT1;  // Enable group 1 interrupts

        EINT;           // Enable Global interrupt INTM

        ERTM;           // Enable Global realtime interrupt DBGM

        //

        // Initialize results buffer

        //

        for(index = 0; index < RESULTS_BUFFER_SIZE; index++)

        {

            adcAResults[index] = 0;

        }

        index = 0;

        bufferFull = 0;

        //

        // Enable PIE interrupt

        //

        PieCtrlRegs.PIEIER1.bit.INTx1 = 1;

        //

        // Sync ePWM

        //

        EALLOW;

        CpuSysRegs.PCLKCR0.bit.TBCLKSYNC = 1;

        //

        // Take conversions indefinitely in loop

        //

        while(1)

        {

            //

            // Start ePWM

            //

            EPwm1Regs.ETSEL.bit.SOCAEN = 1;    // Enable SOCA

            EPwm1Regs.TBCTL.bit.CTRMODE = 0;   // Unfreeze, and enter up count mode

            //

            // Wait while ePWM causes ADC conversions, which then cause interrupts,

            // which fill the results buffer, eventually setting the bufferFull

            // flag

            //

            while(!bufferFull)

            {

            }

            bufferFull = 0; //clear the buffer full flag

            //

            // Stop ePWM

            //

            EPwm1Regs.ETSEL.bit.SOCAEN = 0;    // Disable SOCA

            EPwm1Regs.TBCTL.bit.CTRMODE = 3;   // Freeze counter

            //

            // Software breakpoint. At this point, conversion results are stored in

            // adcAResults.

            //

            // Hit run again to get updated conversions.

            //

            ESTOP0;

        }

    }

    //

    // initADC - Function to configure and power up ADCA.

    //

    void initADC(void)

    {

        //

        // Setup VREF as internal

        //

        SetVREF(ADC_ADCA, ADC_INTERNAL, ADC_VREF3P3);

        EALLOW;

        //

        // Set ADCCLK divider to /4

        //

        AdcaRegs.ADCCTL2.bit.PRESCALE = 6;

        //

        // Set pulse positions to late

        //

        AdcaRegs.ADCCTL1.bit.INTPULSEPOS = 1;

        //

        // Power up the ADC and then delay for 1 ms

        //

        AdcaRegs.ADCCTL1.bit.ADCPWDNZ = 1;

        EDIS;

        DELAY_US(1000);

    }

    //

    // initEPWM - Function to configure ePWM1 to generate the SOC.

    //

    void initEPWM(void)

    {

        EALLOW;

        EPwm1Regs.ETSEL.bit.SOCAEN = 0;     // Disable SOC on A group

        EPwm1Regs.ETSEL.bit.SOCASEL = 4;    // Select SOC on up-count

        EPwm1Regs.ETPS.bit.SOCAPRD = 1;     // Generate pulse on 1st event

        EPwm1Regs.CMPA.bit.CMPA = 0x0800;   // Set compare A value to 2048 counts

        EPwm1Regs.TBPRD = 0x1000;           // Set period to 4096 counts

        EPwm1Regs.TBCTL.bit.CTRMODE = 3;    // Freeze counter

        EDIS;

    }

    //

    // initADCSOC - Function to configure ADCA's SOC0 to be triggered by ePWM1.

    //

    void initADCSOC(void)

    {

        //

        // Select the channels to convert and the end of conversion flag

        //

        EALLOW;

        AdcaRegs.ADCSOC0CTL.bit.CHSEL = 1;     // SOC0 will convert pin A1

                                               // 0:A0  1:A1  2:A2  3:A3

                                               // 4:A4   5:A5   6:A6   7:A7

                                               // 8:A8   9:A9   A:A10  B:A11

                                               // C:A12  D:A13  E:A14  F:A15

        AdcaRegs.ADCSOC0CTL.bit.ACQPS = 9;     // Sample window is 10 SYSCLK cycles

        AdcaRegs.ADCSOC0CTL.bit.TRIGSEL = 5;   // Trigger on ePWM1 SOCA

        AdcaRegs.ADCINTSEL1N2.bit.INT1SEL = 0; // End of SOC0 will set INT1 flag

        AdcaRegs.ADCINTSEL1N2.bit.INT1E = 1;   // Enable INT1 flag

        AdcaRegs.ADCINTFLGCLR.bit.ADCINT1 = 1; // Make sure INT1 flag is cleared

        EDIS;

    }

    //

    // adcA1ISR - ADC A Interrupt 1 ISR

    //

    __interrupt void adcA1ISR(void)

    {

        //

        // Add the latest result to the buffer

        // ADCRESULT0 is the result register of SOC0

        adcAResults[index++] = AdcaResultRegs.ADCRESULT0;

        //

        // Set the bufferFull flag if the buffer is full

        //

        if(RESULTS_BUFFER_SIZE <= index)

        {

            index = 0;

            bufferFull = 1;

        }

        //

        // Clear the interrupt flag

        //

        AdcaRegs.ADCINTFLGCLR.bit.ADCINT1 = 1;

        //

        // Check if overflow has occurred

        //

        if(1 == AdcaRegs.ADCINTOVF.bit.ADCINT1)

        {

            AdcaRegs.ADCINTOVFCLR.bit.ADCINT1 = 1; //clear INT1 overflow flag

            AdcaRegs.ADCINTFLGCLR.bit.ADCINT1 = 1; //clear INT1 flag

        }

        //

        // Acknowledge the interrupt

        //

        PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;

    }

    //

    // End of File

    //

  • Danny,

    I think you won't be able to access the device support registers, i will gather more info on this and shall come back.

    Can you please attach the complete example project in zip format which you were facing the error issue.

    I will try to open the example from my side and check the issue.

    Thanks

    Aswin

  • Hi Aswin,

    I just use example universal_motorcontrol_lab, this morning I removed my existing copy and import a brand new copy also upgraded to MotorControl SDK 5.0 (MotorControl_SDK_5_00_00_000)

    What I did : 

    1. upgrade to MotorControl SDK to 5.0

    2. import universal_motorcontrol_lab example 

    3. add both include path

    C2000Ware_MotorControl_SDK_5_00_00_00  > c2000ware > device_support > f28002x > headers > include

    C2000Ware_MotorControl_SDK_5_00_00_00  > c2000ware > device_support > f28002x > headers > source

    4. simply added TempPIEIER = PieCtrlRegs.PIEIER1.all to sys_main.c file 

    5. build all > error 

    I enclosed herewith the example and its workspace for your investigation, thanks ! 

    universal_motorcontrol_lab_f28002x.zip

    universal_motorcontrol_lab.zip

    Danny

  • Hi Danny,

    I have included this header file in the main.c file and added a definition for Uint16 Macro.

    Please add the below header if you are accessing any piectrlregs in the code.

    typedef unsigned int         Uint16;
    #include "f28002x_piectrl.h"

    Thanks

    Aswin

  • Hi Aswin,

    yes it worked :)

    Danny