struct EPWM_REGS {
union CMPCTL_REG CMPCTL; // Compare control
union CMPA_HRPWM_GROUP CMPA; // Union of CMPA:CMPAHR
Uint16 CMPB; // Compare B reg
}
typedef struct
{
volatile struct EPWM_REGS *EPwmRegHandle;
Uint16 EPwm_CMPA_Direction;
Uint16 EPwm_CMPB_Direction;
Uint16 EPwmTimerIntCount;
Uint16 EPwmMaxCMPA;
Uint16 EPwmMinCMPA;
Uint16 EPwmMaxCMPB;
Uint16 EPwmMinCMPB;
}EPWM_INFO;
EPWM_INFO epwm4_info;
void update_compare(EPWM_INFO *epwm_info)
{
MotorControl();
epwm_info->EPwmRegHandle->CMPA.half.CMPA = CmpA;
epwm_info->EPwmRegHandle->CMPB = CmpB;
return;
}
主要是这几句话“struct EPWM_REGS” “volatile struct EPWM_REGS *EPwmRegHandle;”“epwm_info->EPwmRegHandle->CMPA.half.CMPA = CmpA;”像是在struct EPWM_REGS这里定义了“ union CMPA_HRPWM_GROUP CMPA; // Union of CMPA:CMPAHR
Uint16 CMPB; // Compare B reg”就可以用指针调用了?
这个是直流电机的 感觉好难哦! |