如果某一常量在多个.h文件中出现,我现在想在main.c中修改该常量的值,应该怎么做呢?
#include "sw/modules/math/src/32b/math.h"
#include "sw/modules/memCopy/src/memCopy.h"
#include "sw/modules/est/src/32b/est.h"
#include "sw/modules/svgen/src/32b/svgen_current.h"
#include "sw/modules/fw/src/32b/fw.h"
#include "sw/modules/fem/src/32b/fem.h"
#include "sw/modules/cpu_usage/src/32b/cpu_usage.h"
Eric Ma:
哪个常量?
你说要修改常量的值,如何修改法?
ERIC
如果某一常量在多个.h文件中出现,我现在想在main.c中修改该常量的值,应该怎么做呢?
#include "sw/modules/math/src/32b/math.h"
#include "sw/modules/memCopy/src/memCopy.h"
#include "sw/modules/est/src/32b/est.h"
#include "sw/modules/svgen/src/32b/svgen_current.h"
#include "sw/modules/fw/src/32b/fw.h"
#include "sw/modules/fem/src/32b/fem.h"
#include "sw/modules/cpu_usage/src/32b/cpu_usage.h"
user4708725:
回复 Eric Ma:
比如说USER_PWM_FREQ_kHz常量。我把该常量便量化,即可修改其值。除了修改USER_PWM_FREQ_kHz常量出现电机发热,我修改其余常量(比如说USER_MOTOR_Rs )电机都正常。
user.h中出现:
#define USER_PWM_FREQ_kHz (25.0)
//! \brief Defines the Pulse Width Modulation (PWM) period, usec//! \brief Compile time calculation#define USER_PWM_PERIOD_usec (1000.0/USER_PWM_FREQ_kHz)
//! \brief Defines the Interrupt Service Routine (ISR) frequency, Hz//!#define USER_ISR_FREQ_Hz ((float_t)USER_PWM_FREQ_kHz * 1000.0 / (float_t)USER_NUM_PWM_TICKS_PER_ISR_TICK)
ctrl.h中出现:
inline _iq CTRL_angleDelayComp(CTRL_Handle handle, const _iq angle_pu){ CTRL_Obj *obj = (CTRL_Obj *)handle; _iq angleDelta_pu = _IQmpy(EST_getFm_pu(obj->estHandle),_IQ(USER_IQ_FULL_SCALE_FREQ_Hz/(USER_PWM_FREQ_kHz*1000.0))); _iq angleUncomp_pu = angle_pu; _iq angleCompFactor = _IQ(1.0 + (float_t)USER_NUM_PWM_TICKS_PER_ISR_TICK * (float_t)USER_NUM_ISR_TICKS_PER_CTRL_TICK * ((float_t)USER_NUM_CTRL_TICKS_PER_EST_TICK – 0.5)); _iq angleDeltaComp_pu = _IQmpy(angleDelta_pu, angleCompFactor); uint32_t angleMask = ((uint32_t)0xFFFFFFFF >> (32 – GLOBAL_Q)); _iq angleTmp_pu; _iq angleComp_pu;
// increment the angle angleTmp_pu = angleUncomp_pu + angleDeltaComp_pu;
// mask the angle for wrap around // note: must account for the sign of the angle angleComp_pu = _IQabs(angleTmp_pu) & angleMask;
// account for sign if(angleTmp_pu < 0) { angleComp_pu = -angleComp_pu; }
return(angleComp_pu);}