|
@@ -52,12 +52,9 @@
|
|
|
****************************************************************/
|
|
|
int main(void)
|
|
|
{
|
|
|
+#ifndef RUN_ARCH_SIM
|
|
|
SCB->VTOR = 0x08003000;
|
|
|
- /*Bootloader configuration*/
|
|
|
- // #ifdef BOOTLOADER
|
|
|
- // boot_voBootloader();
|
|
|
- // #endif
|
|
|
- /* Disable all interrupts */
|
|
|
+
|
|
|
DISABLE_IRQ;
|
|
|
/* MCU Core and GPIO configuration */
|
|
|
hw_voHardwareSetup1();
|
|
@@ -92,6 +89,8 @@ int main(void)
|
|
|
}
|
|
|
|
|
|
return 0;
|
|
|
+
|
|
|
+#endif
|
|
|
}
|
|
|
/***************************************************************
|
|
|
Function: mn_voSoftwareInit;
|
|
@@ -154,19 +153,19 @@ void mn_voParaSet(void)
|
|
|
{
|
|
|
if (i2c_stRXCRCOut.blMotorParaFltFlg == FALSE)
|
|
|
{
|
|
|
- cp_stMotorPara.swMotrPolePairs = I2C_uwMotorParaRead[0];
|
|
|
- cp_stMotorPara.swRsOhm = I2C_uwMotorParaRead[1];
|
|
|
- cp_stMotorPara.swLdmH = I2C_uwMotorParaRead[2];
|
|
|
- cp_stMotorPara.swLqmH = I2C_uwMotorParaRead[3];
|
|
|
- cp_stMotorPara.swFluxWb = I2C_uwMotorParaRead[4];
|
|
|
- cp_stMotorPara.swIdMaxA = I2C_uwMotorParaRead[5];
|
|
|
- cp_stMotorPara.swIdMinA = I2C_uwMotorParaRead[6];
|
|
|
- cp_stMotorPara.swRSpeedRpm = I2C_uwMotorParaRead[7];
|
|
|
- cp_stMotorPara.swRPwrWt = I2C_uwMotorParaRead[8];
|
|
|
- cp_stMotorPara.swRIarmsA = I2C_uwMotorParaRead[9];
|
|
|
- cp_stMotorPara.swRUdcV = I2C_uwMotorParaRead[10];
|
|
|
- cp_stMotorPara.swJD = I2C_uwMotorParaRead[11];
|
|
|
- cp_stMotorPara.swTorMax = I2C_uwMotorParaRead[12];
|
|
|
+ cp_stMotorPara.swMotrPolePairs = (SWORD)I2C_uwMotorParaRead[0];
|
|
|
+ cp_stMotorPara.swRsOhm = (SWORD)I2C_uwMotorParaRead[1];
|
|
|
+ cp_stMotorPara.swLdmH = (SWORD)I2C_uwMotorParaRead[2];
|
|
|
+ cp_stMotorPara.swLqmH = (SWORD)I2C_uwMotorParaRead[3];
|
|
|
+ cp_stMotorPara.swFluxWb = (SWORD)I2C_uwMotorParaRead[4];
|
|
|
+ cp_stMotorPara.swIdMaxA = (SWORD)I2C_uwMotorParaRead[5];
|
|
|
+ cp_stMotorPara.swIdMinA = (SWORD)I2C_uwMotorParaRead[6];
|
|
|
+ cp_stMotorPara.swRSpeedRpm = (SWORD)I2C_uwMotorParaRead[7];
|
|
|
+ cp_stMotorPara.swRPwrWt = (SWORD)I2C_uwMotorParaRead[8];
|
|
|
+ cp_stMotorPara.swRIarmsA = (SWORD)I2C_uwMotorParaRead[9];
|
|
|
+ cp_stMotorPara.swRUdcV = (SWORD)I2C_uwMotorParaRead[10];
|
|
|
+ cp_stMotorPara.swJD = (SWORD)I2C_uwMotorParaRead[11];
|
|
|
+ cp_stMotorPara.swTorMax = (SWORD)I2C_uwMotorParaRead[12];
|
|
|
}
|
|
|
else
|
|
|
{}
|
|
@@ -181,7 +180,7 @@ void mn_voParaSet(void)
|
|
|
ass_stParaCong.uwAssistSelect1 = I2C_uwBikeParaRead[6];
|
|
|
ass_stParaCong.uwAssistSelect2 = I2C_uwBikeParaRead[7];
|
|
|
ass_stParaCong.uwLightVoltage = I2C_uwBikeParaRead[8];
|
|
|
- ass_stParaCong.swDeltPerimeter = I2C_uwBikeParaRead[9];
|
|
|
+ ass_stParaCong.swDeltPerimeter = (SWORD)I2C_uwBikeParaRead[9];
|
|
|
ass_stParaCong.uwStartMode = I2C_uwBikeParaRead[10];
|
|
|
ass_stParaCong.uwAutoPowerOffTime = I2C_uwBikeParaRead[11];
|
|
|
}
|
|
@@ -191,16 +190,16 @@ void mn_voParaSet(void)
|
|
|
{
|
|
|
cp_stFlg.ParaFirstSetFlg = I2C_uwMControlRead[0];
|
|
|
cp_stFlg.SpiOffsetFirstSetFlg = I2C_uwMControlRead[1];
|
|
|
- spi_stResolverOut.swSpiThetaOffsetOrignPu = I2C_uwMControlRead[2];
|
|
|
- spi_stResolverOut.swSpiThetaOffsetPu = I2C_uwMControlRead[3];
|
|
|
- cp_stMotorPara.swIpeakMaxA = I2C_uwMControlRead[4];
|
|
|
- cp_stControlPara.swAlmOverCurrentVal = I2C_uwMControlRead[5];
|
|
|
- cp_stControlPara.swAlmOverVolVal3 = I2C_uwMControlRead[6];
|
|
|
- cp_stControlPara.swAlmUnderVolVal2 = I2C_uwMControlRead[7];
|
|
|
- cp_stControlPara.swAlmOverSpdVal = I2C_uwMControlRead[8];
|
|
|
- cp_stControlPara.swAlmOverHeatCeVal = I2C_uwMControlRead[9];
|
|
|
- cp_stControlPara.swAlmRecOHeatVal = I2C_uwMControlRead[10];
|
|
|
- cp_stControlPara.swAlmPwrLimitStartTempVal = I2C_uwMControlRead[11];
|
|
|
+ spi_stResolverOut.swSpiThetaOffsetOrignPu = (SWORD)I2C_uwMControlRead[2];
|
|
|
+ spi_stResolverOut.swSpiThetaOffsetPu = (SWORD)I2C_uwMControlRead[3];
|
|
|
+ cp_stMotorPara.swIpeakMaxA = (SWORD)I2C_uwMControlRead[4];
|
|
|
+ cp_stControlPara.swAlmOverCurrentVal = (SWORD)I2C_uwMControlRead[5];
|
|
|
+ cp_stControlPara.swAlmOverVolVal3 = (SWORD)I2C_uwMControlRead[6];
|
|
|
+ cp_stControlPara.swAlmUnderVolVal2 = (SWORD)I2C_uwMControlRead[7];
|
|
|
+ cp_stControlPara.swAlmOverSpdVal = (SWORD)I2C_uwMControlRead[8];
|
|
|
+ cp_stControlPara.swAlmOverHeatCeVal = (SWORD)I2C_uwMControlRead[9];
|
|
|
+ cp_stControlPara.swAlmRecOHeatVal = (SWORD)I2C_uwMControlRead[10];
|
|
|
+ cp_stControlPara.swAlmPwrLimitStartTempVal = (SWORD)I2C_uwMControlRead[11];
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -267,19 +266,19 @@ void mn_voParaUpdate(void)
|
|
|
{
|
|
|
if (cp_stFlg.ParaMInfoUpdateFlg == TRUE)
|
|
|
{
|
|
|
- cp_stMotorPara.swMotrPolePairs = MC_UpcInfo.stMotorInfo.uwPolePairs;
|
|
|
- cp_stMotorPara.swRsOhm = MC_UpcInfo.stMotorInfo.uwRsmOhm;
|
|
|
- cp_stMotorPara.swLdmH = MC_UpcInfo.stMotorInfo.uwLduH;
|
|
|
- cp_stMotorPara.swLqmH = MC_UpcInfo.stMotorInfo.uwLquH;
|
|
|
- cp_stMotorPara.swFluxWb = MC_UpcInfo.stMotorInfo.uwFluxmWb;
|
|
|
- cp_stMotorPara.swIdMaxA = MC_UpcInfo.stMotorInfo.uwIdMaxA;
|
|
|
- cp_stMotorPara.swIdMinA = MC_UpcInfo.stMotorInfo.uwIdMinA;
|
|
|
- cp_stMotorPara.swRSpeedRpm = MC_UpcInfo.stMotorInfo.uwRSpdRpm;
|
|
|
- cp_stMotorPara.swRPwrWt = MC_UpcInfo.stMotorInfo.uwRPwrWt;
|
|
|
- cp_stMotorPara.swRIarmsA = MC_UpcInfo.stMotorInfo.uwRCurA;
|
|
|
- cp_stMotorPara.swRUdcV = MC_UpcInfo.stMotorInfo.uwRVolV;
|
|
|
- cp_stMotorPara.swJD = MC_UpcInfo.stMotorInfo.uwJD;
|
|
|
- cp_stMotorPara.swTorMax = MC_UpcInfo.stMotorInfo.uwTorMaxNm;
|
|
|
+ cp_stMotorPara.swMotrPolePairs = (SWORD)MC_UpcInfo.stMotorInfo.uwPolePairs;
|
|
|
+ cp_stMotorPara.swRsOhm = (SWORD)MC_UpcInfo.stMotorInfo.uwRsmOhm;
|
|
|
+ cp_stMotorPara.swLdmH = (SWORD)MC_UpcInfo.stMotorInfo.uwLduH;
|
|
|
+ cp_stMotorPara.swLqmH = (SWORD)MC_UpcInfo.stMotorInfo.uwLquH;
|
|
|
+ cp_stMotorPara.swFluxWb = (SWORD)MC_UpcInfo.stMotorInfo.uwFluxmWb;
|
|
|
+ cp_stMotorPara.swIdMaxA = (SWORD)MC_UpcInfo.stMotorInfo.uwIdMaxA;
|
|
|
+ cp_stMotorPara.swIdMinA = (SWORD)MC_UpcInfo.stMotorInfo.uwIdMinA;
|
|
|
+ cp_stMotorPara.swRSpeedRpm = (SWORD)MC_UpcInfo.stMotorInfo.uwRSpdRpm;
|
|
|
+ cp_stMotorPara.swRPwrWt = (SWORD)MC_UpcInfo.stMotorInfo.uwRPwrWt;
|
|
|
+ cp_stMotorPara.swRIarmsA = (SWORD)MC_UpcInfo.stMotorInfo.uwRCurA;
|
|
|
+ cp_stMotorPara.swRUdcV = (SWORD)MC_UpcInfo.stMotorInfo.uwRVolV;
|
|
|
+ cp_stMotorPara.swJD = (SWORD)MC_UpcInfo.stMotorInfo.uwJD;
|
|
|
+ cp_stMotorPara.swTorMax = (SWORD)MC_UpcInfo.stMotorInfo.uwTorMaxNm;
|
|
|
|
|
|
cp_stFlg.ParaMotorDriveUpdateFinishFlg = TRUE;
|
|
|
cp_stFlg.ParaMInfoUpdateFlg = FALSE;
|
|
@@ -310,14 +309,14 @@ void mn_voParaUpdate(void)
|
|
|
cp_stFlg.SpiOffsetFirstSetFlg = MC_UpcInfo.stTestParaInfo.uwSPIOffsetFirstSetFlg;
|
|
|
spi_stResolverOut.swSpiThetaOffsetOrignPu = MC_UpcInfo.stMContorlInfo.uwSPIPosOffsetOrigin;
|
|
|
spi_stResolverOut.swSpiThetaOffsetPu = MC_UpcInfo.stMContorlInfo.uwSPIPosOffsetNow;
|
|
|
- cp_stMotorPara.swIpeakMaxA = MC_UpcInfo.stMContorlInfo.uwIPeakMaxA;
|
|
|
- cp_stControlPara.swAlmOverCurrentVal = MC_UpcInfo.stMContorlInfo.uwAlamOCurA;
|
|
|
- cp_stControlPara.swAlmOverVolVal3 = MC_UpcInfo.stMContorlInfo.uwAlamOVolV;
|
|
|
- cp_stControlPara.swAlmUnderVolVal2 = MC_UpcInfo.stMContorlInfo.uwAlamUVolV;
|
|
|
- cp_stControlPara.swAlmOverSpdVal = MC_UpcInfo.stMContorlInfo.uwAlamOverSpdRpm;
|
|
|
- cp_stControlPara.swAlmOverHeatCeVal = MC_UpcInfo.stMContorlInfo.uwAlamOverHeatCe;
|
|
|
- cp_stControlPara.swAlmRecOHeatVal = MC_UpcInfo.stMContorlInfo.uwAlamRecHeatCe;
|
|
|
- cp_stControlPara.swAlmPwrLimitStartTempVal = MC_UpcInfo.stMContorlInfo.uwPwrLimitStartCe;
|
|
|
+ cp_stMotorPara.swIpeakMaxA = (SWORD)MC_UpcInfo.stMContorlInfo.uwIPeakMaxA;
|
|
|
+ cp_stControlPara.swAlmOverCurrentVal = (SWORD)MC_UpcInfo.stMContorlInfo.uwAlamOCurA;
|
|
|
+ cp_stControlPara.swAlmOverVolVal3 = (SWORD)MC_UpcInfo.stMContorlInfo.uwAlamOVolV;
|
|
|
+ cp_stControlPara.swAlmUnderVolVal2 = (SWORD)MC_UpcInfo.stMContorlInfo.uwAlamUVolV;
|
|
|
+ cp_stControlPara.swAlmOverSpdVal = (SWORD)MC_UpcInfo.stMContorlInfo.uwAlamOverSpdRpm;
|
|
|
+ cp_stControlPara.swAlmOverHeatCeVal = (SWORD)MC_UpcInfo.stMContorlInfo.uwAlamOverHeatCe;
|
|
|
+ cp_stControlPara.swAlmRecOHeatVal = (SWORD)MC_UpcInfo.stMContorlInfo.uwAlamRecHeatCe;
|
|
|
+ cp_stControlPara.swAlmPwrLimitStartTempVal = (SWORD)MC_UpcInfo.stMContorlInfo.uwPwrLimitStartCe;
|
|
|
|
|
|
cp_stFlg.ParaMotorDriveUpdateFinishFlg = TRUE;
|
|
|
cp_stFlg.ParaMCInfoUpdateFlg = FALSE;
|
|
@@ -364,31 +363,31 @@ void mn_voParaUpdate(void)
|
|
|
|
|
|
if(cp_stFlg.TestParaInfoUpdateFlg == TRUE)
|
|
|
{
|
|
|
- cp_stControlPara.swAlignCurAp = MC_UpcInfo.stTestParaInfo.uwInitPosCurAmp;
|
|
|
- cp_stControlPara.swDragVolAp = MC_UpcInfo.stTestParaInfo.uwVFControlVolAmp;
|
|
|
- cp_stControlPara.swDragCurAp = MC_UpcInfo.stTestParaInfo.uwIFControlCurAmp;
|
|
|
- cp_stControlPara.swDragSpdHz = MC_UpcInfo.stTestParaInfo.uwVFIFTargetFreHz;
|
|
|
-
|
|
|
- cp_stControlPara.swSpeedAccRate = MC_UpcInfo.stTestParaInfo.uwSpeedLoopAccRate;
|
|
|
- cp_stControlPara.swSpeedDccRate = MC_UpcInfo.stTestParaInfo.uwSpeedLoopDecRate;
|
|
|
- cp_stControlPara.swAsrPIBandwidth = MC_UpcInfo.stTestParaInfo.uwSpeedLoopBandWidthHz;
|
|
|
- cp_stControlPara.swAsrPIM = MC_UpcInfo.stTestParaInfo.uwSpeedLoopCoefM;
|
|
|
-
|
|
|
- cp_stControlPara.swAcrPIBandwidth = MC_UpcInfo.stTestParaInfo.uwCuerrentLoopBandWidthHz;
|
|
|
- cp_stControlPara.swAcrRaCoef = MC_UpcInfo.stTestParaInfo.uwCurrentLoopCoefM;
|
|
|
-
|
|
|
- cp_stControlPara.swObsFluxPICrossfreHz = MC_UpcInfo.stTestParaInfo.uwFluxObsBandWidthHz;
|
|
|
- cp_stControlPara.swObsFluxPIDampratio = MC_UpcInfo.stTestParaInfo.uwFluxObsCoefM;
|
|
|
- cp_stControlPara.swObsSpdPLLBandWidthHz = MC_UpcInfo.stTestParaInfo.uwThetaObsPLLBandWidthHz;
|
|
|
- cp_stControlPara.swObsSpdPLLM = MC_UpcInfo.stTestParaInfo.uwThetaObsPLLCoefM;
|
|
|
-
|
|
|
- cp_stMotorPara.swJD = MC_UpcInfo.stTestParaInfo.uwJm;
|
|
|
- cp_stControlPara.swPWMMaxDuty = MC_UpcInfo.stTestParaInfo.uwPWMMaxDuty;
|
|
|
- cp_stControlPara.swPWM7to5Duty = MC_UpcInfo.stTestParaInfo.uwPWM7to5Duty;
|
|
|
- cp_stControlPara.swPwrLimitValWt = MC_UpcInfo.stTestParaInfo.uwPwrLimit;
|
|
|
- cp_stControlPara.swPwrLimitErrWt = MC_UpcInfo.stTestParaInfo.uwPwrLimitError;
|
|
|
- cp_stControlPara.swPwrLimitKpPu = MC_UpcInfo.stTestParaInfo.uwPwrLimitKp;
|
|
|
- cp_stControlPara.swPwrLimitKiPu = MC_UpcInfo.stTestParaInfo.uwPwrLimitKi;
|
|
|
+ cp_stControlPara.swAlignCurAp = (SWORD)MC_UpcInfo.stTestParaInfo.uwInitPosCurAmp;
|
|
|
+ cp_stControlPara.swDragVolAp = (SWORD)MC_UpcInfo.stTestParaInfo.uwVFControlVolAmp;
|
|
|
+ cp_stControlPara.swDragCurAp = (SWORD)MC_UpcInfo.stTestParaInfo.uwIFControlCurAmp;
|
|
|
+ cp_stControlPara.swDragSpdHz = (SWORD)MC_UpcInfo.stTestParaInfo.uwVFIFTargetFreHz;
|
|
|
+
|
|
|
+ cp_stControlPara.swSpeedAccRate = (SWORD)MC_UpcInfo.stTestParaInfo.uwSpeedLoopAccRate;
|
|
|
+ cp_stControlPara.swSpeedDccRate = (SWORD)MC_UpcInfo.stTestParaInfo.uwSpeedLoopDecRate;
|
|
|
+ cp_stControlPara.swAsrPIBandwidth = (SWORD)MC_UpcInfo.stTestParaInfo.uwSpeedLoopBandWidthHz;
|
|
|
+ cp_stControlPara.swAsrPIM = (SWORD)MC_UpcInfo.stTestParaInfo.uwSpeedLoopCoefM;
|
|
|
+
|
|
|
+ cp_stControlPara.swAcrPIBandwidth = (SWORD)MC_UpcInfo.stTestParaInfo.uwCuerrentLoopBandWidthHz;
|
|
|
+ cp_stControlPara.swAcrRaCoef = (SWORD)MC_UpcInfo.stTestParaInfo.uwCurrentLoopCoefM;
|
|
|
+
|
|
|
+ cp_stControlPara.swObsFluxPICrossfreHz = (SWORD)MC_UpcInfo.stTestParaInfo.uwFluxObsBandWidthHz;
|
|
|
+ cp_stControlPara.swObsFluxPIDampratio = (SWORD)MC_UpcInfo.stTestParaInfo.uwFluxObsCoefM;
|
|
|
+ cp_stControlPara.swObsSpdPLLBandWidthHz = (SWORD)MC_UpcInfo.stTestParaInfo.uwThetaObsPLLBandWidthHz;
|
|
|
+ cp_stControlPara.swObsSpdPLLM = (SWORD)MC_UpcInfo.stTestParaInfo.uwThetaObsPLLCoefM;
|
|
|
+
|
|
|
+ cp_stMotorPara.swJD = (SWORD)MC_UpcInfo.stTestParaInfo.uwJm;
|
|
|
+ cp_stControlPara.swPWMMaxDuty = (SWORD)MC_UpcInfo.stTestParaInfo.uwPWMMaxDuty;
|
|
|
+ cp_stControlPara.swPWM7to5Duty = (SWORD)MC_UpcInfo.stTestParaInfo.uwPWM7to5Duty;
|
|
|
+ cp_stControlPara.swPwrLimitValWt = (SWORD)MC_UpcInfo.stTestParaInfo.uwPwrLimit;
|
|
|
+ cp_stControlPara.swPwrLimitErrWt = (SWORD)MC_UpcInfo.stTestParaInfo.uwPwrLimitError;
|
|
|
+ cp_stControlPara.swPwrLimitKpPu = (SWORD)MC_UpcInfo.stTestParaInfo.uwPwrLimitKp;
|
|
|
+ cp_stControlPara.swPwrLimitKiPu = (SWORD)MC_UpcInfo.stTestParaInfo.uwPwrLimitKi;
|
|
|
|
|
|
cp_stFlg.ParaMotorDriveUpdateFinishFlg = TRUE;
|
|
|
// cp_stFlg.TestParaInfoUpdateFlg = FALSE;
|
|
@@ -407,19 +406,19 @@ void mn_voEEUperParaUpdate(void)
|
|
|
{
|
|
|
if (MC_UpcInfo.stMotorInfo.uwSaveFlg == TRUE)
|
|
|
{
|
|
|
- Syspara2.stMotorPara.uwPolePairs.uwReal = cp_stMotorPara.swMotrPolePairs;
|
|
|
- Syspara2.stMotorPara.uwRsmOhm.uwReal = cp_stMotorPara.swRsOhm;
|
|
|
- Syspara2.stMotorPara.uwLduH.uwReal = cp_stMotorPara.swLdmH;
|
|
|
- Syspara2.stMotorPara.uwLquH.uwReal = cp_stMotorPara.swLqmH;
|
|
|
- Syspara2.stMotorPara.uwFluxmWb.uwReal = cp_stMotorPara.swFluxWb;
|
|
|
- Syspara2.stMotorPara.uwIdMaxA.uwReal = cp_stMotorPara.swIdMaxA;
|
|
|
- Syspara2.stMotorPara.uwIdMinA.uwReal = cp_stMotorPara.swIdMinA;
|
|
|
- Syspara2.stMotorPara.uwRSpdRpm.uwReal = cp_stMotorPara.swRSpeedRpm;
|
|
|
- Syspara2.stMotorPara.uwRPwrWt.uwReal = cp_stMotorPara.swRPwrWt;
|
|
|
- Syspara2.stMotorPara.uwRCurA.uwReal = cp_stMotorPara.swRIarmsA;
|
|
|
- Syspara2.stMotorPara.uwRVolV.uwReal = cp_stMotorPara.swRUdcV;
|
|
|
- Syspara2.stMotorPara.uwJD.uwReal = cp_stMotorPara.swJD;
|
|
|
- Syspara2.stMotorPara.uwTorMaxNm.uwReal = cp_stMotorPara.swTorMax;
|
|
|
+ Syspara2.stMotorPara.uwPolePairs.uwReal = (UWORD)cp_stMotorPara.swMotrPolePairs;
|
|
|
+ Syspara2.stMotorPara.uwRsmOhm.uwReal = (UWORD)cp_stMotorPara.swRsOhm;
|
|
|
+ Syspara2.stMotorPara.uwLduH.uwReal = (UWORD)cp_stMotorPara.swLdmH;
|
|
|
+ Syspara2.stMotorPara.uwLquH.uwReal = (UWORD)cp_stMotorPara.swLqmH;
|
|
|
+ Syspara2.stMotorPara.uwFluxmWb.uwReal = (UWORD)cp_stMotorPara.swFluxWb;
|
|
|
+ Syspara2.stMotorPara.uwIdMaxA.uwReal = (UWORD)cp_stMotorPara.swIdMaxA;
|
|
|
+ Syspara2.stMotorPara.uwIdMinA.uwReal = (UWORD)cp_stMotorPara.swIdMinA;
|
|
|
+ Syspara2.stMotorPara.uwRSpdRpm.uwReal = (UWORD)cp_stMotorPara.swRSpeedRpm;
|
|
|
+ Syspara2.stMotorPara.uwRPwrWt.uwReal = (UWORD)cp_stMotorPara.swRPwrWt;
|
|
|
+ Syspara2.stMotorPara.uwRCurA.uwReal = (UWORD)cp_stMotorPara.swRIarmsA;
|
|
|
+ Syspara2.stMotorPara.uwRVolV.uwReal = (UWORD)cp_stMotorPara.swRUdcV;
|
|
|
+ Syspara2.stMotorPara.uwJD.uwReal = (UWORD)cp_stMotorPara.swJD;
|
|
|
+ Syspara2.stMotorPara.uwTorMaxNm.uwReal = (UWORD)cp_stMotorPara.swTorMax;
|
|
|
}
|
|
|
Syspara2.stBikePara.swDeltPerimeter.swReal = ass_stParaCong.swDeltPerimeter;
|
|
|
if (MC_UpcInfo.stBikeInfo.uwSaveFlg == TRUE)
|
|
@@ -443,14 +442,14 @@ void mn_voEEUperParaUpdate(void)
|
|
|
Syspara2.stMControlPara.SpiOffsetFirstSetFlg.uwReal = cp_stFlg.SpiOffsetFirstSetFlg;
|
|
|
Syspara2.stMControlPara.uwSPIPosOffsetOrigin.uwReal = spi_stResolverOut.swSpiThetaOffsetOrignPu;
|
|
|
Syspara2.stMControlPara.uwSPIPosOffsetNow.uwReal = spi_stResolverOut.swSpiThetaOffsetPu;
|
|
|
- Syspara2.stMControlPara.uwIPeakMaxA.uwReal = cp_stMotorPara.swIpeakMaxA;
|
|
|
- Syspara2.stMControlPara.uwAlamOCurA.uwReal = cp_stControlPara.swAlmOverCurrentVal;
|
|
|
- Syspara2.stMControlPara.uwAlamOVolV.uwReal = cp_stControlPara.swAlmOverVolVal3;
|
|
|
- Syspara2.stMControlPara.uwAlamUVolV.uwReal = cp_stControlPara.swAlmUnderVolVal2;
|
|
|
- Syspara2.stMControlPara.uwAlamOverSpdRpm.uwReal = cp_stControlPara.swAlmOverSpdVal;
|
|
|
- Syspara2.stMControlPara.uwAlamOverHeatCe.uwReal = cp_stControlPara.swAlmOverHeatCeVal;
|
|
|
- Syspara2.stMControlPara.uwAlamRecHeatCe.uwReal = cp_stControlPara.swAlmRecOHeatVal;
|
|
|
- Syspara2.stMControlPara.uwPwrLimitStartCe.uwReal = cp_stControlPara.swAlmPwrLimitStartTempVal;
|
|
|
+ Syspara2.stMControlPara.uwIPeakMaxA.uwReal = (UWORD)cp_stMotorPara.swIpeakMaxA;
|
|
|
+ Syspara2.stMControlPara.uwAlamOCurA.uwReal = (UWORD)cp_stControlPara.swAlmOverCurrentVal;
|
|
|
+ Syspara2.stMControlPara.uwAlamOVolV.uwReal = (UWORD)cp_stControlPara.swAlmOverVolVal3;
|
|
|
+ Syspara2.stMControlPara.uwAlamUVolV.uwReal = (UWORD)cp_stControlPara.swAlmUnderVolVal2;
|
|
|
+ Syspara2.stMControlPara.uwAlamOverSpdRpm.uwReal = (UWORD)cp_stControlPara.swAlmOverSpdVal;
|
|
|
+ Syspara2.stMControlPara.uwAlamOverHeatCe.uwReal = (UWORD)cp_stControlPara.swAlmOverHeatCeVal;
|
|
|
+ Syspara2.stMControlPara.uwAlamRecHeatCe.uwReal = (UWORD)cp_stControlPara.swAlmRecOHeatVal;
|
|
|
+ Syspara2.stMControlPara.uwPwrLimitStartCe.uwReal = (UWORD)cp_stControlPara.swAlmPwrLimitStartTempVal;
|
|
|
}
|
|
|
if (MC_UpcInfo.stSensorInfo.uwSaveFlg == TRUE)
|
|
|
{
|
|
@@ -573,7 +572,6 @@ void mn_voSoftwareInit(void)
|
|
|
adc_voSampleInit();
|
|
|
adc_voSampleCoef(&adc_stCof);
|
|
|
/* UART init */
|
|
|
- //uart_voApplInit();
|
|
|
uart_voMonitorInit();
|
|
|
}
|
|
|
|
|
@@ -588,9 +586,9 @@ void mn_voSoftwareInit(void)
|
|
|
************************************************************************/
|
|
|
void mn_voMtParInit(void)
|
|
|
{
|
|
|
- mn_swIdTurn1Pu = ((SLONG)M_LD_TURN1_ID_AP << 14) / cof_uwIbAp; // Q14, saturation current of Ld
|
|
|
+ mn_swIdTurn1Pu = (SWORD)(((SLONG)M_LD_TURN1_ID_AP << 14) / (SWORD)cof_uwIbAp); // Q14, saturation current of Ld
|
|
|
mn_slLdTurn1Pu = ((SLONG)M_LD_TURN1_LD_MH << 10) / cof_uwLbHm; // Q10, saturation inductance of Ld
|
|
|
- mn_swIdTurn2Pu = ((SLONG)M_LD_TURN2_ID_AP << 14) / cof_uwIbAp; // Q14, saturation current of Ld
|
|
|
+ mn_swIdTurn2Pu = (SWORD)(((SLONG)M_LD_TURN2_ID_AP << 14) / (SWORD)cof_uwIbAp); // Q14, saturation current of Ld
|
|
|
mn_slLdTurn2Pu = ((SLONG)M_LD_TURN2_LD_MH << 10) / cof_uwLbHm; // Q10, saturation inductance of Ld
|
|
|
if (mn_swIdTurn1Pu == mn_swIdTurn2Pu)
|
|
|
{
|
|
@@ -598,12 +596,12 @@ void mn_voMtParInit(void)
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- mn_swKLdSat = ((mn_slLdTurn2Pu - mn_slLdTurn1Pu) << 10) / (mn_swIdTurn2Pu - mn_swIdTurn1Pu); // Q10
|
|
|
+ mn_swKLdSat = (SWORD)(((mn_slLdTurn2Pu - mn_slLdTurn1Pu) << 10) / (mn_swIdTurn2Pu - mn_swIdTurn1Pu)); // Q10
|
|
|
}
|
|
|
|
|
|
- mn_swIqTurn1Pu = ((SLONG)M_LQ_TURN1_IQ_AP << 14) / cof_uwIbAp; // Q14, saturation current of Lq
|
|
|
+ mn_swIqTurn1Pu = (SWORD)(((SLONG)M_LQ_TURN1_IQ_AP << 14) / (SWORD)cof_uwIbAp); // Q14, saturation current of Lq
|
|
|
mn_slLqTurn1Pu = ((SLONG)M_LQ_TURN1_LQ_MH << 10) / cof_uwLbHm; // Q10, saturation inductance of Lq
|
|
|
- mn_swIqTurn2Pu = ((SLONG)M_LQ_TURN2_IQ_AP << 14) / cof_uwIbAp; // Q14, saturation current of Lq
|
|
|
+ mn_swIqTurn2Pu = (SWORD)(((SLONG)M_LQ_TURN2_IQ_AP << 14) / (SWORD)cof_uwIbAp); // Q14, saturation current of Lq
|
|
|
mn_slLqTurn2Pu = ((SLONG)M_LQ_TURN2_LQ_MH << 10) / cof_uwLbHm; // Q10, saturation inductance of Lq
|
|
|
if (mn_swIqTurn1Pu == mn_swIqTurn2Pu)
|
|
|
{
|
|
@@ -611,7 +609,7 @@ void mn_voMtParInit(void)
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- mn_swKLqSat = ((mn_slLqTurn2Pu - mn_slLqTurn1Pu) << 10) / (mn_swIqTurn2Pu - mn_swIqTurn1Pu); // Q10
|
|
|
+ mn_swKLqSat = (SWORD)(((mn_slLqTurn2Pu - mn_slLqTurn1Pu) << 10) / (mn_swIqTurn2Pu - mn_swIqTurn1Pu)); // Q10
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -629,7 +627,7 @@ void mn_voMcParInit(void)
|
|
|
align_voInit();
|
|
|
|
|
|
// Align Parameters
|
|
|
- mn_uwAlignCurPu = CUR_AP2PU(cp_stControlPara.swAlignCurAp); // Q14
|
|
|
+ mn_uwAlignCurPu = (UWORD)CUR_AP2PU(cp_stControlPara.swAlignCurAp); // Q14
|
|
|
mn_ulAlignRampTbcCt = TBC_MS2CT(cp_stControlPara.swAlignRampTMms);
|
|
|
mn_ulAlignHoldTbcCt = TBC_MS2CT(cp_stControlPara.swAlignHoldTMms);
|
|
|
if (mn_ulAlignRampTbcCt == 0)
|
|
@@ -647,8 +645,8 @@ void mn_voMcParInit(void)
|
|
|
mn_slAlignAngInit = ANG_DEG2PU(cp_stControlPara.swAlignAngInitDeg);
|
|
|
|
|
|
// Open Drag Parameters
|
|
|
- mn_uwDragCurPu = CUR_AP2PU(cp_stControlPara.swDragCurAp); // Q14
|
|
|
- mn_swDragSpdPu = SPD_HZ2PU(cp_stControlPara.swDragSpdHz); // Q15
|
|
|
+ mn_uwDragCurPu = (UWORD)CUR_AP2PU(cp_stControlPara.swDragCurAp); // Q14
|
|
|
+ mn_swDragSpdPu = (SWORD)SPD_HZ2PU(cp_stControlPara.swDragSpdHz); // Q15
|
|
|
mn_ulDragSpdRampTbcCt = TBC_MS2CT(cp_stControlPara.swDragSpdRampTMms);
|
|
|
if (mn_ulDragSpdRampTbcCt == 0)
|
|
|
{
|
|
@@ -677,7 +675,7 @@ void mn_voMcParInit(void)
|
|
|
}
|
|
|
}
|
|
|
// Stop Parameters
|
|
|
- mn_swStopSpdRefPu = SPD_RPM2PU(cp_stControlPara.swStopSpdRefRpm);
|
|
|
+ mn_swStopSpdRefPu = (SWORD)SPD_RPM2PU(cp_stControlPara.swStopSpdRefRpm);
|
|
|
}
|
|
|
|
|
|
/***************************************************************
|