我需要在德州仪器 (TI) 项目中编写此评论中解释的代码(使用 Code Composer Studio):
//this is in motor1_drive.c:
// Enable MOTOR1_HALL_CAL pre-defined symbols, run the motor with FAST for angle calibration
// Copy hall_M1.thetaCalBuf[] to hallAngleBuf[]
// 1->1, 2->2, 3->3, 4->4, 5->5, 6->6, 6->0
// Disable MOTOR1_HALL_CAL pre-defined symbols after calibration for normal operation
// 6 1 2
// 3 4 5
// 6
//I've tried this but an error (one for every line below) exist:
//**declaration is incompatible with "const float32_t hallAngleBuf[7]"**
const float32_t hallAngleBuf[7] = { 0, 0, 0, 0, 0 , 0, 0 };
hallAngleBuf[0] = hall_M1.thetaCalBuff[0]; //I've tried only the first element copy
考虑一下:
//this is in hall.h:
typedef struct _HALL_Obj_
{
float32_t speedSwitch_Hz; // Hz
uint32_t timeStampCAP; //
float32_t thetaBuff[7]; // 1~6 are valid value
float32_t thetaHall_rad; //
float32_t thetaDelta_rad; //
float32_t thetaHall_pu; //
#ifdef HALL_CAL
float32_t thetaCalBuff[7]; //
#endif //HALL_CAL
} HALL_Obj;
我已经启用/禁用了预定义符号,这是从项目属性中完成的
这声明了一个 const 数组:
const float32_t hallAngleBuf[7] = { 0, 0, 0, 0, 0 , 0, 0 };
因此你不能像下面这样给它赋值:
hallAngleBuf[0] = hall_M1.thetaCalBuff[0];
删除
const
,它应该可以工作。