Part Number:TMS320F28335Other Parts Discussed in Thread:CONTROLSUITE
您好,在做bldc电机控制,我将f2803xdrvlib.h内容,移植至F28335环境,出现以下错误,但在2803x工程中为什么不报错。
Description Resource Path Location Type
#10056 symbol "_ePWM" redefined: first defined in "./BLDCSensoredMain.obj"; redefined in "./source/f28335bldcpwm.obj" BLDC_Sensored_v1.0_Func C/C++ Problem
其实就是用这个定义引起的
volatile struct EPWM_REGS *ePWM[] =
{ &EPwm1Regs, //intentional: (ePWM[0] not used)
&EPwm2Regs,
&EPwm3Regs,
&EPwm4Regs,
&EPwm5Regs,
&EPwm6Regs,
};
我应该怎么正确使用
Susan Yang:
then and 说:#10056 symbol "_ePWM" redefined: first defined in
根据错误提示,是重复定义了。您在BLDCSensoredMain和 source/f28335bldcpwm文件内都定义了?
then and 说:
其实就是用这个定义引起的
volatile struct EPWM_REGS *ePWM[] =
这个是定义在哪里的?
,
then and:
f28335bldcpwm.c的一部分
#include "f2833xbmsk.h"#include "f28335drvlib.h"#include "PeripheralHeaderIncludes.h"#include "f28335bldcpwm.h"#include "DSP2833x_EPwm_defines.h"
void BLDCPWM_INIT_MACRO(int ch1,int ch2,int ch3,PWMGEN *v);void BLDCPWM_MACRO(int ch1,int ch2,int ch3,PWMGEN *v);void BLDCPWM_Protection_MACRO(int ch1,int ch2,int ch3,PWMGEN *v);
voidBLDCPWM_INIT_MACRO(int ch1,int ch2,int ch3,PWMGEN *v){ /* Setup Sync*/ \ (*ePWM[ch1]).TBCTL.bit.SYNCOSEL = 0; \ (*ePWM[ch2]).TBCTL.bit.SYNCOSEL = 0; \ (*ePWM[ch3]).TBCTL.bit.SYNCOSEL = 0; \ \ /* Allow each timer to be sync'ed*/ \ (*ePWM[ch1]).TBCTL.bit.PHSEN = 1; \ (*ePWM[ch2]).TBCTL.bit.PHSEN = 1; \ (*ePWM[ch3]).TBCTL.bit.PHSEN = 1; \
在f28335drvlib.h中定义的,内容如下:
#include "DSP2833x_Device.h"
// Used to indirectly access all EPWM modulestypedef EPWM_REGS *ePWM[] = { &EPwm1Regs, //intentional: (ePWM[0] not used) &EPwm2Regs, &EPwm3Regs, &EPwm4Regs, &EPwm5Regs, &EPwm6Regs, };
// Used to indirectly access eQEP modulevolatile struct EQEP_REGS *eQEP[] = { &EQep1Regs, &EQep2Regs, };
// Used to indirectly access eQEP modulevolatile struct ECAP_REGS *eCAP[] = { &ECap1Regs, &ECap2Regs, &ECap3Regs, &ECap4Regs, &ECap5Regs, &ECap6Regs, };
这种方式在f2803x的历程中也是这么用的。但不报错。
,
Susan Yang:
then and 说:这种方式在f2803x的历程中也是这么用的。但不报错。
这种方式没错。但有可能时28335已经在别的地方定义了 _ePWM
若是可以的话,请上传一下工程,我们具体看一下
,
then and:
BLDC_Sensored_v1.0_Func.rar
,
then and:
HVBLDC_Sensored.rar
这个是controlSUITE导入的f2803x的历程,正常编译不报错。
,
Susan Yang:
1 在f28335bldcpwm.c内
删除
#include "f28335drvlib.h"
并添加
extern volatile struct EPWM_REGS *ePWM[];
2 在BLDCSensoredMain.c内添加
#include "f28335drvlib.h"
编译后无报错
,
then and:
非常感谢!
,
Susan Yang:
很高兴能帮到您