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.
CONTROLSUIT里的f2833xdrvlib.h与TI的例程DSP2833x_EPwm.h,DSP2833x_EQep.h,DSP2833x_ECap.h是不是冲突?
为什么在程序中同时include以上4个头文件会出现以下错误:
<Linking>
>> error: symbol _eQEP is defined multiple times:
C:\\CCStudio_v3.3\\MyProjects\\svpwm\\Debug\\DSP2833x_DefaultIsr.obj and C:\\CCStudio_v3.3\\MyProjects\\svpwm\\Debug\\svpwmmain.obj
>> error: symbol _eCAP is defined multiple times:
C:\\CCStudio_v3.3\\MyProjects\\svpwm\\Debug\\DSP2833x_DefaultIsr.obj and C:\\CCStudio_v3.3\\MyProjects\\svpwm\\Debug\\svpwmmain.obj
>> error: symbol _ePWM is defined multiple times:
C:\\CCStudio_v3.3\\MyProjects\\svpwm\\Debug\\DSP2833x_DefaultIsr.obj and C:\\CCStudio_v3.3\\MyProjects\\svpwm\\Debug\\svpwmmain.obj
楼主是参考CONTROLSUIT里的例程和宏写PMSM的FOC控制程序。
DSP2833x_EPwm.h中定义了结构EPWM_REGS声明了6个此结构的外部变量EPwmxRegs:
struct EPWM_REGS {
union TBCTL_REG TBCTL; //
union TBSTS_REG TBSTS; //
union TBPHS_HRPWM_GROUP TBPHS; // Union of TBPHS:TBPHSHR
Uint16 TBCTR; // Counter
Uint16 TBPRD; // Period register set
Uint16 rsvd1; //
union CMPCTL_REG CMPCTL; // Compare control
union CMPA_HRPWM_GROUP CMPA; // Union of CMPA:CMPAHR
Uint16 CMPB; // Compare B reg
union AQCTL_REG AQCTLA; // Action qual output A
union AQCTL_REG AQCTLB; // Action qual output B
union AQSFRC_REG AQSFRC; // Action qual SW force
union AQCSFRC_REG AQCSFRC; // Action qualifier continuous SW force
union DBCTL_REG DBCTL; // Dead-band control
Uint16 DBRED; // Dead-band rising edge delay
Uint16 DBFED; // Dead-band falling edge delay
union TZSEL_REG TZSEL; // Trip zone select
Uint16 rsvd2;
union TZCTL_REG TZCTL; // Trip zone control
union TZEINT_REG TZEINT; // Trip zone interrupt enable
union TZFLG_REG TZFLG; // Trip zone interrupt flags
union TZCLR_REG TZCLR; // Trip zone clear
union TZFRC_REG TZFRC; // Trip zone force interrupt
union ETSEL_REG ETSEL; // Event trigger selection
union ETPS_REG ETPS; // Event trigger pre-scaler
union ETFLG_REG ETFLG; // Event trigger flags
union ETCLR_REG ETCLR; // Event trigger clear
union ETFRC_REG ETFRC; // Event trigger force
union PCCTL_REG PCCTL; // PWM chopper control
Uint16 rsvd3; //
union HRCNFG_REG HRCNFG; // HRPWM Config Reg
};
//---------------------------------------------------------------------------
// External References & Function Declarations:
//
extern volatile struct EPWM_REGS EPwm1Regs;
extern volatile struct EPWM_REGS EPwm2Regs;
extern volatile struct EPWM_REGS EPwm3Regs;
extern volatile struct EPWM_REGS EPwm4Regs;
extern volatile struct EPWM_REGS EPwm5Regs;
extern volatile struct EPWM_REGS EPwm6Regs;
DSP2833x_GlobalVariableDefs.c中定义了6个EPWM_REGS结构变量EPwmxRegs:
#ifdef __cplusplus
#pragma DATA_SECTION("EPwm1RegsFile")
#else
#pragma DATA_SECTION(EPwm1Regs,"EPwm1RegsFile");
#endif
volatile struct EPWM_REGS EPwm1Regs;
……
f2833xdrvlib.h中定义了指向结构EPWM_REGS类型的 变量的指针*ePWM
volatile struct EPWM_REGS *ePWM[] =
{ &EPwm1Regs, //intentional: (ePWM[0] not used)
&EPwm1Regs,
&EPwm2Regs,
&EPwm3Regs,
&EPwm4Regs,
&EPwm5Regs,
&EPwm6Regs,
};
编译的Linking阶段出现>> error: symbol _ePWM is defined multiple times:这样的错误。
发现在f2833xpwm.h中正是中用*ePWM这个指针代替EPwm1Regs来设置寄存器的。因为error是因为f2833xpwm.h引用了f2833xdrvlib.h之后引起的,为了消除error,干脆去掉这个指针,不再引用f2833xdrvlib.h。
比如在PWM_INIT_MACRO(v)中将
(*ePWM[ch1]).TBCTL.bit.SYNCOSEL = 0; /* Pass through*/ \
(*ePWM[ch2]).TBCTL.bit.SYNCOSEL = 0; /* Pass through*/ \
(*ePWM[ch3]).TBCTL.bit.SYNCOSEL = 0; /* Pass through*/
改为
EPwm1Regs.TBCTL.bit.SYNCOSEL = 0; /* Pass through*/ \
EPwm2Regs.TBCTL.bit.SYNCOSEL = 0; /* Pass through*/ \
EPwm3Regs.TBCTL.bit.SYNCOSEL = 0; /* Pass through*/
这样,编译后errors消除。
但是!依然不太清楚>> error: symbol _ePWM is defined multiple times这个错误出在哪。说多次定义了ePWM,但好像语法上也没有多次定义啊?
求大神指点!
你好!
DefaultIsr.c及svpwmmain.c两个文件没有包含eQEP,eCAP的定义。正是因为引用了头文件f2833xpwm(f2833xdrvlib.h),DSP2833x_EPwm.h,DSP2833x_EQep.h,DSP2833x_ECap.h才出现多次定义的错误。
比如我新建一个.c文件,引用这几个头文件,还是会报错。