Ver código fonte

V0.2.0.11-MS 1、增加95、96两帧数据上传;2、修改绝缘电阻无法正确上传的问题;3、增加SOC模型;4、修改Ah积分结果,由SOC模型结果取代CJ的demo算法;5、增加SOC模型的存储量,起始地址为400,增加备用SN号存储功能(EOL及OTA时存入);6、修改EEPROM写入频率,当历程增加500m及以上时存入,降低EEPROM写入频率;7、增加调试信息上传(BCU 中的soc、ah、kw)

BJQX-ZHENGCHAO\Zhengchao 1 ano atrás
pai
commit
198c029174

+ 3 - 3
.cproject

@@ -30,8 +30,8 @@
 							<targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF" id="cdt.managedbuild.targetPlatform.gnu.cross.64147430" isAbstract="false" osList="all" superClass="cdt.managedbuild.targetPlatform.gnu.cross"/>
 							<builder buildPath="${workspace_loc:/S32K146_4G}/Debug_FLASH" id="com.freescale.s32ds.cross.gnu.builder.466747471" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="FSL Make Builder" superClass="com.freescale.s32ds.cross.gnu.builder"/>
 							<tool id="com.nxp.s32ds.cle.arm.mbs.arm32.bare.gnu.9.2.tool.c.compiler.1980082058" name="Standard S32DS C Compiler" superClass="com.nxp.s32ds.cle.arm.mbs.arm32.bare.gnu.9.2.tool.c.compiler">
-								<option defaultValue="gnu.c.optimization.level.none" id="gnu.c.compiler.option.optimization.level.1168627068" name="Optimization Level" superClass="gnu.c.compiler.option.optimization.level" useByScannerDiscovery="false" value="gnu.c.optimization.level.none" valueType="enumerated"/>
-								<option defaultValue="gnu.c.debugging.level.max" id="gnu.c.compiler.option.debugging.level.1120041103" name="Debug Level" superClass="gnu.c.compiler.option.debugging.level" useByScannerDiscovery="false" value="gnu.c.debugging.level.max" valueType="enumerated"/>
+								<option defaultValue="gnu.c.optimization.level.none" id="gnu.c.compiler.option.optimization.level.1168627068" name="Optimization Level" superClass="gnu.c.compiler.option.optimization.level" useByScannerDiscovery="false" value="gnu.c.optimization.level.size" valueType="enumerated"/>
+								<option defaultValue="gnu.c.debugging.level.max" id="gnu.c.compiler.option.debugging.level.1120041103" name="Debug Level" superClass="gnu.c.compiler.option.debugging.level" useByScannerDiscovery="false" value="gnu.c.debugging.level.none" valueType="enumerated"/>
 								<option id="com.freescale.s32ds.cross.gnu.tool.c.compiler.option.optimization.functionsections.1916093778" name="Function sections (-ffunction-sections)" superClass="com.freescale.s32ds.cross.gnu.tool.c.compiler.option.optimization.functionsections" useByScannerDiscovery="true" value="false" valueType="boolean"/>
 								<option id="com.freescale.s32ds.cross.gnu.tool.c.compiler.option.optimization.datasections.499071697" name="Data sections (-fdata-sections)" superClass="com.freescale.s32ds.cross.gnu.tool.c.compiler.option.optimization.datasections" useByScannerDiscovery="true" value="false" valueType="boolean"/>
 								<option id="com.freescale.s32ds.cross.gnu.tool.c.compiler.option.debugging.format.155687014" name="Debug format" superClass="com.freescale.s32ds.cross.gnu.tool.c.compiler.option.debugging.format" useByScannerDiscovery="true"/>
@@ -150,7 +150,7 @@
 							<tool id="com.nxp.s32ds.cle.arm.mbs.arm32.bare.tool.archiver.50914677" name="Standard S32DS Archiver" superClass="com.nxp.s32ds.cle.arm.mbs.arm32.bare.tool.archiver"/>
 							<tool id="com.nxp.s32ds.cle.arm.mbs.arm32.bare.tool.assembler.339533218" name="Standard S32DS Assembler" superClass="com.nxp.s32ds.cle.arm.mbs.arm32.bare.tool.assembler">
 								<option id="com.freescale.s32ds.cross.gnu.tool.assembler.usepreprocessor.608521688" name="Use preprocessor" superClass="com.freescale.s32ds.cross.gnu.tool.assembler.usepreprocessor" useByScannerDiscovery="false" value="true" valueType="boolean"/>
-								<option defaultValue="gnu.c.debugging.level.max" id="com.freescale.s32ds.cross.gnu.tool.assembler.option.debugging.level.935781758" name="Debug Level" superClass="com.freescale.s32ds.cross.gnu.tool.assembler.option.debugging.level" useByScannerDiscovery="false" valueType="enumerated"/>
+								<option defaultValue="gnu.c.debugging.level.max" id="com.freescale.s32ds.cross.gnu.tool.assembler.option.debugging.level.935781758" name="Debug Level" superClass="com.freescale.s32ds.cross.gnu.tool.assembler.option.debugging.level" useByScannerDiscovery="false" value="gnu.c.debugging.level.none" valueType="enumerated"/>
 								<option id="com.nxp.s32ds.cle.arm.mbs.arm32.bare.tool.assembler.option.target.libraries.2115819142" name="Libraries support" superClass="com.nxp.s32ds.cle.arm.mbs.arm32.bare.tool.assembler.option.target.libraries" useByScannerDiscovery="false" value="com.nxp.s32ds.cle.arm.mbs.arm32.bare.tool.assembler.option.target.libraries.newlib_nano_noio" valueType="enumerated"/>
 								<option id="com.nxp.s32ds.cle.arm.mbs.arm32.bare.tool.assembler.option.target.sysroot.1519150514" name="Sysroot" superClass="com.nxp.s32ds.cle.arm.mbs.arm32.bare.tool.assembler.option.target.sysroot" useByScannerDiscovery="false" value="--sysroot=&quot;${S32DS_ARM32_NEWLIB_DIR}&quot;" valueType="string"/>
 								<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="gnu.both.asm.option.include.paths.763521555" name="Include paths (-I)" superClass="gnu.both.asm.option.include.paths" useByScannerDiscovery="false" valueType="includePath">

+ 2 - 2
Project_Settings/Debugger/S32K146_4G_Debug_FLASH_PNE.launch

@@ -97,7 +97,7 @@
 <stringAttribute key="com.pemicro.debug.gdbjtag.pne.ml.CYCLONE_IP" value=""/>
 <booleanAttribute key="com.pemicro.debug.gdbjtag.pne.ml.DO_RESET_DELAY" value="false"/>
 <intAttribute key="com.pemicro.debug.gdbjtag.pne.ml.INTERFACE_PORT" value="0"/>
-<stringAttribute key="com.pemicro.debug.gdbjtag.pne.ml.INTERFACE_PORT_STRING" value=""/>
+<stringAttribute key="com.pemicro.debug.gdbjtag.pne.ml.INTERFACE_PORT_STRING" value="USB1"/>
 <stringAttribute key="com.pemicro.debug.gdbjtag.pne.ml.NETWORK_CARD_IP" value=""/>
 <stringAttribute key="com.pemicro.debug.gdbjtag.pne.ml.POWER_DOWN_DELAY" value="250"/>
 <booleanAttribute key="com.pemicro.debug.gdbjtag.pne.ml.POWER_OFF" value="false"/>
@@ -216,5 +216,5 @@
 </listAttribute>
 <stringAttribute key="org.eclipse.dsf.launch.MEMORY_BLOCKS" value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;memoryBlockExpressionList context=&quot;reserved-for-future-use&quot;&gt;&#13;&#10;&lt;gdbmemoryBlockExpression address=&quot;536806032&quot; label=&quot;RX_Buffer[UART_LPUART2]&quot;/&gt;&#13;&#10;&lt;gdbmemoryBlockExpression address=&quot;536823956&quot; label=&quot;GpsBufferGet&quot;/&gt;&#13;&#10;&lt;gdbmemoryBlockExpression address=&quot;255&quot; label=&quot;SocketId&quot;/&gt;&#13;&#10;&lt;/memoryBlockExpressionList&gt;&#13;&#10;"/>
 <stringAttribute key="process_factory_id" value="org.eclipse.cdt.dsf.gdb.GdbProcessFactory"/>
-<stringAttribute key="saved_expressions&lt;seperator&gt;Unknown" value="0x1fffbdd3,0x1fffbdcb,0x1fffbe4b,0x1fffbd8d,0x1fffbe20,0x1fff0508,0x1fff0501,0x1fff0500,0x1fffc158,0x1fffc170,0x1fffc198,0x1fffc518,0x1fffc148,0x1fffc1e0,0x1fffc230"/>
+<stringAttribute key="saved_expressions&lt;seperator&gt;Unknown" value="0x1fffbe4b,0x1fffbd8d,0x1fffbe20,0x1fff0508,0x1fff0501,0x1fff0500,0x1fffc158,0x1fffc170,0x1fffc198,0x1fffc518,0x1fffc148,0x1fffc1e0,0x1fffc230,14000000,0x14000000"/>
 </launchConfiguration>

+ 17 - 12
Project_Settings/Linker_Files/linker_flash_s32k146.ld

@@ -31,13 +31,18 @@
 
 MEMORY
 {         
-    int_flash_interrupts    : ORIGIN = 0x00000000, LENGTH = 0x00000400    /* 1K */    /* Do not change this section */
-    int_flash_config        : ORIGIN = 0x00000400, LENGTH = 0x00000010    /* 16bytes */ /* Do not change this section */
-    int_flash               : ORIGIN = 0x00000410, LENGTH = 0x000FFBF0    /* ~1.0MB */ 
+    int_flash_interrupts    : ORIGIN = 0x00014200, LENGTH = 0x00000400    /* 1K */    /* Do not change this section */
+   /* int_flash_config        : ORIGIN = 0x00000400, LENGTH = 0x00000010    /* 16bytes */ /* Do not change this section */
+     int_flash               : ORIGIN = 0x00014600, LENGTH = 0x000EBA00    /* ~1.0MB */ 
+/*	int_flash_interrupts    : ORIGIN = 0x00080200, LENGTH = 0x00000400	/**/
+/*	int_flash               : ORIGIN = 0x00080600, LENGTH = 0x0007FA00	/**/
+	
+	m_flexram				: ORIGIN = 0x14000000, LENGTH = 0x00001000	
     int_sram_results        : ORIGIN = 0x1FFF0000, LENGTH = 0x00000100    /* 256bytes */
     int_sram                : ORIGIN = 0x1FFF0100, LENGTH = 0x0001DF00    /* ~120K */
-    int_sram_stack_c0       : ORIGIN = 0x2000E000, LENGTH = 0x00001000    /* 4K  */
-    ram_rsvd2               : ORIGIN = 0x2000F000, LENGTH = 0             /* End of SRAM */
+    int_sram_stack_c0       : ORIGIN = 0x2000E000, LENGTH = 0x00001000 - 0x10    /* 4K  */
+    ram_rsvd2               : ORIGIN = 0x2000EFF0, LENGTH = 0             /* End of SRAM */
+    ExchangeInfo            : ORIGIN = 0x2000EFF0, LENGTH = 0x10          
 }
 
 
@@ -51,20 +56,19 @@ SECTIONS
    {						
     	*(.eeprom)			
     } >m_flexram			
-    
 	.flash_interrupts :
 	{
-		. = ALIGN(4096);
+		. = ALIGN(512);
         __interrupts_rom_start = .;
         KEEP(*(.intc_vector))    
-        . = ALIGN(4);
+        . = ALIGN(512);
         __interrupts_rom_end = .;
 	} > int_flash_interrupts
 	
-	.flash_config :
-	{
-		KEEP(*(.flash_config))
-	} > int_flash_config
+/*	.flash_config :				*/
+/*	{							*/
+/*		KEEP(*(.flash_config))	*/
+/*	} > int_flash_config		*/
 	
 	.flash :
 	{
@@ -111,6 +115,7 @@ SECTIONS
 		__DATA_ROM = .;
 	} > int_flash
     
+    
     . = ALIGN(4);
     PROVIDE(__exidx_start = .);
     .ARM.exidx :

+ 12 - 17
Project_Settings/Linker_Files/linker_flash_s32k146.ldota → Project_Settings/Linker_Files/linker_flash_s32k146.ldlocal

@@ -31,18 +31,13 @@
 
 MEMORY
 {         
-    int_flash_interrupts    : ORIGIN = 0x00014200, LENGTH = 0x00000400    /* 1K */    /* Do not change this section */
-   /* int_flash_config        : ORIGIN = 0x00000400, LENGTH = 0x00000010    /* 16bytes */ /* Do not change this section */
-     int_flash               : ORIGIN = 0x00014600, LENGTH = 0x000EBA00    /* ~1.0MB */ 
-/*	int_flash_interrupts    : ORIGIN = 0x00080200, LENGTH = 0x00000400	/**/
-/*	int_flash               : ORIGIN = 0x00080600, LENGTH = 0x0007FA00	/**/
-	
-	m_flexram				: ORIGIN = 0x14000000, LENGTH = 0x00001000	
+    int_flash_interrupts    : ORIGIN = 0x00000000, LENGTH = 0x00000400    /* 1K */    /* Do not change this section */
+    int_flash_config        : ORIGIN = 0x00000400, LENGTH = 0x00000010    /* 16bytes */ /* Do not change this section */
+    int_flash               : ORIGIN = 0x00000410, LENGTH = 0x000FFBF0    /* ~1.0MB */ 
     int_sram_results        : ORIGIN = 0x1FFF0000, LENGTH = 0x00000100    /* 256bytes */
     int_sram                : ORIGIN = 0x1FFF0100, LENGTH = 0x0001DF00    /* ~120K */
-    int_sram_stack_c0       : ORIGIN = 0x2000E000, LENGTH = 0x00001000 - 0x10    /* 4K  */
-    ram_rsvd2               : ORIGIN = 0x2000EFF0, LENGTH = 0             /* End of SRAM */
-    ExchangeInfo            : ORIGIN = 0x2000EFF0, LENGTH = 0x10          
+    int_sram_stack_c0       : ORIGIN = 0x2000E000, LENGTH = 0x00001000    /* 4K  */
+    ram_rsvd2               : ORIGIN = 0x2000F000, LENGTH = 0             /* End of SRAM */
 }
 
 
@@ -56,19 +51,20 @@ SECTIONS
    {						
     	*(.eeprom)			
     } >m_flexram			
+    
 	.flash_interrupts :
 	{
-		. = ALIGN(512);
+		. = ALIGN(4096);
         __interrupts_rom_start = .;
         KEEP(*(.intc_vector))    
-        . = ALIGN(512);
+        . = ALIGN(4);
         __interrupts_rom_end = .;
 	} > int_flash_interrupts
 	
-/*	.flash_config :				*/
-/*	{							*/
-/*		KEEP(*(.flash_config))	*/
-/*	} > int_flash_config		*/
+	.flash_config :
+	{
+		KEEP(*(.flash_config))
+	} > int_flash_config
 	
 	.flash :
 	{
@@ -115,7 +111,6 @@ SECTIONS
 		__DATA_ROM = .;
 	} > int_flash
     
-    
     . = ALIGN(4);
     PROVIDE(__exidx_start = .);
     .ARM.exidx :

+ 63 - 61
code/BCU/BBox_Bcu.c

@@ -15,7 +15,7 @@ void BBox_BCU_Task(void *pvParameters)
 	static boolean_T Flg;
 	//鍚姩寤惰繜娌″仛
     PROC_RTE_STATE_SWITCH(PROCESS_STATE_INIT);
-    while (TRUE)
+    while (true)
     {
         switch (gProcess_Rte_Task)
         {
@@ -30,7 +30,7 @@ void BBox_BCU_Task(void *pvParameters)
         //============================宸ヤ綔妯″紡==========================
         case PROCESS_STATE_WORK:
         {
-			if (TimerCounter % 100 == 0)
+			if (TimerCounter % 100 == 0 && BBox_DataReadyFlag==1)
 			{
 				IH_Data_Update();
 				/*
@@ -49,7 +49,7 @@ void BBox_BCU_Task(void *pvParameters)
 				ihd_V_battU_T1 = 0;
 				*/
 //				Dio_WriteChannel(DioConf_DioChannel_PTE7_GPIO_OUT_MCU_LED3, STD_OFF);
-//				BCU_step();
+				BCU_step();
 				//
 				if (socd_flg_EEsave == 1)
 				{
@@ -79,81 +79,83 @@ void BBox_BCU_Task(void *pvParameters)
 
 void BCUEEDataRead(void)
 {
-	memset(rtev_flg_EESt, 0, sizeof(rtev_flg_EESt));
+//	memset(rtev_flg_EESt, 0, sizeof(rtev_flg_EESt));
     //时间
-	ihd_tm_yearEi =    BcuAppSaveDataInfo.ihd_tm_yearE;
-	ihd_tm_monthEi =    BcuAppSaveDataInfo.ihd_tm_monthE;
-	ihd_tm_dayEi   =    BcuAppSaveDataInfo.ihd_tm_dayE;
-	ihd_tm_hourEi =    BcuAppSaveDataInfo.ihd_tm_hourE;
-	ihd_tm_minEi =    BcuAppSaveDataInfo.ihd_tm_minE;
-	ihd_tm_secEi =    BcuAppSaveDataInfo.ihd_tm_secE;
+	ihd_tm_yearEi =   BcuSaveDataInfo.BcuAppSaveDataInfo.ihd_tm_yearE;
+	ihd_tm_monthEi =  BcuSaveDataInfo.BcuAppSaveDataInfo.ihd_tm_monthE;
+	ihd_tm_dayEi   =  BcuSaveDataInfo.BcuAppSaveDataInfo.ihd_tm_dayE;
+	ihd_tm_hourEi =   BcuSaveDataInfo.BcuAppSaveDataInfo.ihd_tm_hourE;
+	ihd_tm_minEi =    BcuSaveDataInfo.BcuAppSaveDataInfo.ihd_tm_minE;
+	ihd_tm_secEi =    BcuSaveDataInfo.BcuAppSaveDataInfo.ihd_tm_secE;
     //SOC
-	socd_pct_bcuSocEi = BcuAppSaveDataInfo.socd_pct_bcuSocE;
-	socd_pct_battSocEi = BcuAppSaveDataInfo.socd_pct_battSocE;
+	socd_pct_bcuSocEi = BcuSaveDataInfo.BcuAppSaveDataInfo.socd_pct_bcuSocE;
+	socd_pct_battSocEi = BcuSaveDataInfo.BcuAppSaveDataInfo.socd_pct_battSocE;
     /*/SOH
-	sohd_flg_countEi = BcuAppSaveDataInfo.sohd_flg_countE;
-	sohd_Q_chrgEi = BcuAppSaveDataInfo.sohd_Q_chrgE;
-	memcpy(sohv_Q_cellCapEi, BcuAppSaveDataInfo.sohv_Q_cellCapE, sizeof(sohv_Q_cellCapEi));
-	memcpy(sohv_V_cellUEi, BcuAppSaveDataInfo.sohv_V_cellUE, sizeof(sohv_V_cellUEi));
-	memcpy(sohv_Q_packCapEi, BcuAppSaveDataInfo.sohv_Q_packCapE, sizeof(sohv_Q_packCapEi));
+	sohd_flg_countEi = BcuSaveDataInfo.BcuAppSaveDataInfo.sohd_flg_countE;
+	sohd_Q_chrgEi = BcuSaveDataInfo.BcuAppSaveDataInfo.sohd_Q_chrgE;
+	memcpy(sohv_Q_cellCapEi, BcuSaveDataInfo.BcuAppSaveDataInfo.sohv_Q_cellCapE, sizeof(sohv_Q_cellCapEi));
+	memcpy(sohv_V_cellUEi, BcuSaveDataInfo.BcuAppSaveDataInfo.sohv_V_cellUE, sizeof(sohv_V_cellUEi));
+	memcpy(sohv_Q_packCapEi, BcuSaveDataInfo.BcuAppSaveDataInfo.sohv_Q_packCapE, sizeof(sohv_Q_packCapEi));
     //SOR
-	memcpy(sorv_ohm_cellREi, BcuAppSaveDataInfo.sorv_ohm_cellRE, sizeof(sorv_ohm_cellREi));
+	memcpy(sorv_ohm_cellREi, BcuSaveDataInfo.BcuAppSaveDataInfo.sorv_ohm_cellRE, sizeof(sorv_ohm_cellREi));
     //BLC
-	memcpy(blcv_Q_totalCpEi, BcuAppSaveDataInfo.blcv_Q_totalCpE, sizeof(blcv_Q_totalCpEi));
-	memcpy(blcv_Q_reqCpEi, BcuAppSaveDataInfo.blcv_Q_reqCpE, sizeof(blcv_Q_reqCpEi));
+	memcpy(blcv_Q_totalCpEi, BcuSaveDataInfo.BcuAppSaveDataInfo.blcv_Q_totalCpE, sizeof(blcv_Q_totalCpEi));
+	memcpy(blcv_Q_reqCpEi, BcuSaveDataInfo.BcuAppSaveDataInfo.blcv_Q_reqCpE, sizeof(blcv_Q_reqCpEi));
 	//ISC
-	iscd_tm_chrgEi = BcuAppSaveDataInfo.iscd_tm_chrgE;
-	iscd_tm_staticEi = BcuAppSaveDataInfo.iscd_tm_staticE;
-	memcpy(iscv_ohm_chrgEi, BcuAppSaveDataInfo.iscv_ohm_chrgE, sizeof(iscv_ohm_chrgEi));
-	memcpy(iscv_ohm_staticEi, BcuAppSaveDataInfo.iscv_ohm_staticE, sizeof(iscv_ohm_staticEi));
-	memcpy(iscv_Q_chrgEi, BcuAppSaveDataInfo.iscv_Q_chrgE, sizeof(iscv_Q_chrgEi));
-	memcpy(iscv_Q_staticEi, BcuAppSaveDataInfo.iscv_Q_staticE, sizeof(iscv_Q_staticEi));
+	iscd_tm_chrgEi = BcuSaveDataInfo.BcuAppSaveDataInfo.iscd_tm_chrgE;
+	iscd_tm_staticEi = BcuSaveDataInfo.BcuAppSaveDataInfo.iscd_tm_staticE;
+	memcpy(iscv_ohm_chrgEi, BcuSaveDataInfo.BcuAppSaveDataInfo.iscv_ohm_chrgE, sizeof(iscv_ohm_chrgEi));
+	memcpy(iscv_ohm_staticEi, BcuSaveDataInfo.BcuAppSaveDataInfo.iscv_ohm_staticE, sizeof(iscv_ohm_staticEi));
+	memcpy(iscv_Q_chrgEi, BcuSaveDataInfo.BcuAppSaveDataInfo.iscv_Q_chrgE, sizeof(iscv_Q_chrgEi));
+	memcpy(iscv_Q_staticEi, BcuSaveDataInfo.BcuAppSaveDataInfo.iscv_Q_staticE, sizeof(iscv_Q_staticEi));
 	*///DAM
-	damd_Q_totalChrgCpEi  = BcuAppSaveDataInfo.damd_Q_totalChrgCpE;
-	damd_E_totalChrgEngEi  = BcuAppSaveDataInfo.damd_E_totalChrgEngE;
-	damd_Q_totalRegenCpEi  = BcuAppSaveDataInfo.damd_Q_totalRegenCpE;
-	damd_E_totalRegenEngEi  = BcuAppSaveDataInfo.damd_E_totalRegenEngE;
-	damd_Q_totalDisChrgCpEi  = BcuAppSaveDataInfo.damd_Q_totalDisChrgCpE;
-	damd_E_totalDisChrgEngEi  = BcuAppSaveDataInfo.damd_E_totalDisChrgEngE;
+	damd_Q_totalChrgCpEi  = BcuSaveDataInfo.BcuAppSaveDataInfo.damd_Q_totalChrgCpE;
+	damd_E_totalChrgEngEi  = BcuSaveDataInfo.BcuAppSaveDataInfo.damd_E_totalChrgEngE;
+	damd_Q_totalRegenCpEi  = BcuSaveDataInfo.BcuAppSaveDataInfo.damd_Q_totalRegenCpE;
+	damd_E_totalRegenEngEi  = BcuSaveDataInfo.BcuAppSaveDataInfo.damd_E_totalRegenEngE;
+	damd_Q_totalDisChrgCpEi  = BcuSaveDataInfo.BcuAppSaveDataInfo.damd_Q_totalDisChrgCpE;
+	damd_E_totalDisChrgEngEi  = BcuSaveDataInfo.BcuAppSaveDataInfo.damd_E_totalDisChrgEngE;
 }
 
 
 void BCUEEDataSave(void)
 {
-	BcuAppSaveDataInfo.bcuSaveFlg = TRUE;
+	BcuSaveDataInfo.BcuAppSaveDataInfo.bcuSaveFlg = TRUE;
     //
-	BcuAppSaveDataInfo.ihd_tm_yearE = ihd_tm_yearEo;
-	BcuAppSaveDataInfo.ihd_tm_monthE = ihd_tm_monthEo;
-	BcuAppSaveDataInfo.ihd_tm_dayE = ihd_tm_dayEo;
-	BcuAppSaveDataInfo.ihd_tm_hourE = ihd_tm_hourEo;
-	BcuAppSaveDataInfo.ihd_tm_minE = ihd_tm_minEo;
-	BcuAppSaveDataInfo.ihd_tm_secE = ihd_tm_secEo;
+	BcuSaveDataInfo.BcuAppSaveDataInfo.ihd_tm_yearE = ihd_tm_yearEo;
+	BcuSaveDataInfo.BcuAppSaveDataInfo.ihd_tm_monthE = ihd_tm_monthEo;
+	BcuSaveDataInfo.BcuAppSaveDataInfo.ihd_tm_dayE = ihd_tm_dayEo;
+	BcuSaveDataInfo.BcuAppSaveDataInfo.ihd_tm_hourE = ihd_tm_hourEo;
+	BcuSaveDataInfo.BcuAppSaveDataInfo.ihd_tm_minE = ihd_tm_minEo;
+	BcuSaveDataInfo.BcuAppSaveDataInfo.ihd_tm_secE = ihd_tm_secEo;
     //SOC
-	BcuAppSaveDataInfo.socd_pct_bcuSocE = socd_pct_bcuSocEo;
-	BcuAppSaveDataInfo.socd_pct_battSocE = socd_pct_battSocEo;
+	BcuSaveDataInfo.BcuAppSaveDataInfo.socd_pct_bcuSocE = socd_pct_bcuSocEo;
+	BcuSaveDataInfo.BcuAppSaveDataInfo.socd_pct_battSocE = socd_pct_battSocEo;
     /*/SOH
-	BcuAppSaveDataInfo.sohd_flg_countE = sohd_flg_countEo;
-	BcuAppSaveDataInfo.sohd_Q_chrgE = sohd_Q_chrgEo;
-	memcpy(BcuAppSaveDataInfo.sohv_Q_cellCapE, sohv_Q_cellCapEo,sizeof(sohv_Q_cellCapEo));
-	memcpy(BcuAppSaveDataInfo.sohv_V_cellUE,sohv_V_cellUEo, sizeof(sohv_V_cellUEo));
-	memcpy(BcuAppSaveDataInfo.sohv_Q_packCapE,sohv_Q_packCapEo, sizeof(sohv_Q_packCapEo));
+	BcuSaveDataInfo.BcuAppSaveDataInfo.sohd_flg_countE = sohd_flg_countEo;
+	BcuSaveDataInfo.BcuAppSaveDataInfo.sohd_Q_chrgE = sohd_Q_chrgEo;
+	memcpy(BcuSaveDataInfo.BcuAppSaveDataInfo.sohv_Q_cellCapE, sohv_Q_cellCapEo,sizeof(sohv_Q_cellCapEo));
+	memcpy(BcuSaveDataInfo.BcuAppSaveDataInfo.sohv_V_cellUE,sohv_V_cellUEo, sizeof(sohv_V_cellUEo));
+	memcpy(BcuSaveDataInfo.BcuAppSaveDataInfo.sohv_Q_packCapE,sohv_Q_packCapEo, sizeof(sohv_Q_packCapEo));
     //SOR
-	memcpy(BcuAppSaveDataInfo.sorv_ohm_cellRE,sorv_ohm_cellREo, sizeof(sorv_ohm_cellREo));
+	memcpy(BcuSaveDataInfo.BcuAppSaveDataInfo.sorv_ohm_cellRE,sorv_ohm_cellREo, sizeof(sorv_ohm_cellREo));
     //BLC
-	memcpy(BcuAppSaveDataInfo.blcv_Q_totalCpE, blcv_Q_totalCpEo,sizeof(blcv_Q_totalCpEo));
-	memcpy(BcuAppSaveDataInfo.blcv_Q_reqCpE, blcv_Q_reqCpEo,sizeof(blcv_Q_reqCpEo));
+	memcpy(BcuSaveDataInfo.BcuAppSaveDataInfo.blcv_Q_totalCpE, blcv_Q_totalCpEo,sizeof(blcv_Q_totalCpEo));
+	memcpy(BcuSaveDataInfo.BcuAppSaveDataInfo.blcv_Q_reqCpE, blcv_Q_reqCpEo,sizeof(blcv_Q_reqCpEo));
 	//ISC
-	BcuAppSaveDataInfo.iscd_tm_chrgE = iscd_tm_chrgEo;
-	BcuAppSaveDataInfo.iscd_tm_staticE = iscd_tm_staticEo;
-	memcpy(BcuAppSaveDataInfo.iscv_ohm_chrgE, iscv_ohm_chrgEo,sizeof(iscv_ohm_chrgEo));
-	memcpy(BcuAppSaveDataInfo.iscv_ohm_staticE, iscv_ohm_staticEo,sizeof(iscv_ohm_staticEo));
-	memcpy(BcuAppSaveDataInfo.iscv_Q_chrgE, iscv_Q_chrgEo,sizeof(iscv_Q_chrgEo));
-	memcpy(BcuAppSaveDataInfo.iscv_Q_staticE, iscv_Q_staticEo,sizeof(iscv_Q_staticEo));
+	BcuSaveDataInfo.BcuAppSaveDataInfo.iscd_tm_chrgE = iscd_tm_chrgEo;
+	BcuSaveDataInfo.BcuAppSaveDataInfo.iscd_tm_staticE = iscd_tm_staticEo;
+	memcpy(BcuSaveDataInfo.BcuAppSaveDataInfo.iscv_ohm_chrgE, iscv_ohm_chrgEo,sizeof(iscv_ohm_chrgEo));
+	memcpy(BcuSaveDataInfo.BcuAppSaveDataInfo.iscv_ohm_staticE, iscv_ohm_staticEo,sizeof(iscv_ohm_staticEo));
+	memcpy(BcuSaveDataInfo.BcuAppSaveDataInfo.iscv_Q_chrgE, iscv_Q_chrgEo,sizeof(iscv_Q_chrgEo));
+	memcpy(BcuSaveDataInfo.BcuAppSaveDataInfo.iscv_Q_staticE, iscv_Q_staticEo,sizeof(iscv_Q_staticEo));
 	*///DAM
-	BcuAppSaveDataInfo.damd_Q_totalChrgCpE = damd_Q_totalChrgCpEo;
-	BcuAppSaveDataInfo.damd_E_totalChrgEngE = damd_E_totalChrgEngEo;
-	BcuAppSaveDataInfo.damd_Q_totalRegenCpE = damd_Q_totalRegenCpEo;
-	BcuAppSaveDataInfo.damd_E_totalRegenEngE = damd_E_totalRegenEngEo;
-	BcuAppSaveDataInfo.damd_Q_totalDisChrgCpE = damd_Q_totalDisChrgCpEo;
-	BcuAppSaveDataInfo.damd_E_totalDisChrgEngE = damd_E_totalDisChrgEngEo;
+	BcuSaveDataInfo.BcuAppSaveDataInfo.damd_Q_totalChrgCpE = damd_Q_totalChrgCpEo;
+	BcuSaveDataInfo.BcuAppSaveDataInfo.damd_E_totalChrgEngE = damd_E_totalChrgEngEo;
+	BcuSaveDataInfo.BcuAppSaveDataInfo.damd_Q_totalRegenCpE = damd_Q_totalRegenCpEo;
+	BcuSaveDataInfo.BcuAppSaveDataInfo.damd_E_totalRegenEngE = damd_E_totalRegenEngEo;
+	BcuSaveDataInfo.BcuAppSaveDataInfo.damd_Q_totalDisChrgCpE = damd_Q_totalDisChrgCpEo;
+	BcuSaveDataInfo.BcuAppSaveDataInfo.damd_E_totalDisChrgEngE = damd_E_totalDisChrgEngEo;
+
+
 }

+ 4 - 4
code/BCU/BCUModel/BCUDisp.c

@@ -74,12 +74,12 @@ boolean_T rtev_flg_EESt[4];
 real32_T socd_Q_dMax;
 real32_T socd_Q_dMin;
 boolean_T socd_flg_EEsave;
-real32_T socd_pct_ahSoc;
-real32_T socd_pct_battSoc;
+real32_T socd_pct_ahSoc;  //
+real32_T socd_pct_battSoc;//
 real32_T socd_pct_battSocEi;
 real32_T socd_pct_battSocEo;
-real32_T socd_pct_bcuSoc;
+real32_T socd_pct_bcuSoc;//
 real32_T socd_pct_bcuSocEi;
 real32_T socd_pct_bcuSocEo;
-real32_T socd_pct_ekfSoc;
+real32_T socd_pct_ekfSoc;//
 real32_T sohd_pct_bcuSoh;

+ 1 - 1
code/BCU/BCUModel/DAM.c

@@ -32,7 +32,7 @@ void DAM(void)
 
   if (DAM_DW.UnitDelay_DSTATE == 1.0) {
     uint8_T rtb_Merge10;
-    if (ihv_flg_EESt[5]) {
+    if (ihv_flg_EESt[3]) {
       DAM_B.Merge = 0.0F;
       DAM_B.Merge1 = 0.0F;
       DAM_B.Merge2 = 0.0F;

+ 20 - 13
code/app/AppGlobalVar.c

@@ -18,15 +18,15 @@
 
 #define defaultSn "ZLTEST00000000002"
 
-//#define APP_RELEASE
+#define APP_RELEASE
 
 #ifdef APP_RELEASE
 const char WebSiteName[] = "\"iotp.fast-fun.cn\"";
 uint16 WebSitePort = 8712;
 #define EEP_START_SEC_VAR_INIT_8_NO_CACHEABLE
 #include "Eep_MemMap.h"
-AppConfigBody AppConfigInfo = {false, false, {defaultSn}, {0}};
-BcuAppSaveBody BcuAppSaveDataInfo = {0};
+AppConfigBody AppConfigInfo = {false, true, {defaultSn}, {0}};
+BcuSaveType BcuSaveDataInfo = {0};
 #define EEP_STOP_SEC_VAR_INIT_8_NO_CACHEABLE
 #include "Eep_MemMap.h"
 #else
@@ -35,13 +35,13 @@ uint16 WebSitePort = 8812;
 #define EEP_START_SEC_VAR_INIT_8_NO_CACHEABLE
 #include "Eep_MemMap.h"
 AppConfigBody AppConfigInfo = {false, true, {defaultSn}, {0}};
-BcuAppSaveBody BcuAppSaveDataInfo = {0};
+BcuAppSaveBody BcuSaveDataInfo = {0};
 #define EEP_STOP_SEC_VAR_INIT_8_NO_CACHEABLE
 #include "Eep_MemMap.h"
 #endif
 
 //*全局变量*//
-const uint32 AppSwVersion = 0x0002000A;
+const uint32 AppSwVersion = 0x0002000B;
 const uint8 DataModuleType = 0x02; // 01=NB,02-4G
 const uint16 HwVersion = 0x0102;
 const uint32 BlSwVersion = 0x00000002;
@@ -57,6 +57,7 @@ uint8 Fota_update_flag = 0;
 boolean Fota_Process_Going = false;
 uint8 Fota_error_flag = 0;
 uint8 DeviceErrNum = 0;
+uint8 globalSaveFlag = 0;
 /*GPS*/
 QueueHandle_t GpsDataQueueHandle;
 sint16 xyzData[3] = {0};
@@ -319,29 +320,35 @@ UINT16 BMS_SingleCharCapy = 0x00;				// 单次充电Ah 数,,Re-0.1,Off-0,Ah
 UINT16 BMS_HVVolt = 0x00;						// BMS当前电压,,Re-1,Off-0,
 UINT16 TMS_ReqPow = 0x00;						// TMS需求功率,65535:无效,Re-0.1,Off-0,Kw
 UINT32 BMS_TotalCharEngy = 0x00;				// 累计充入kWh 数,,Re-0.1,Off-0,KWh
-UINT32 BMS_TotalDisCharEngy = 0x00;				// 累计放出kWh 数,,Re-0.1,Off-0,KWh
+UINT32 BMS_TotalDischarEngy = 0x00;				// 累计放出kWh 数,,Re-0.1,Off-0,KWh
 UINT32 BMS_TotalBackCharEngy = 0x00;			// 累计动能回馈充入kWh 数,,Re-0.1,Off-0,KWh
 UINT32 BMS_TotalStaCharEngy = 0x00;				// 累计换电站充入kWh 数,,Re-0.1,Off-0,KWh
 UINT32 BMS_TotalGunCharEngy = 0x00;				// 累计插枪充电充入kWh 数,,Re-0.1,Off-0,KWh
 UINT32 BMS_TotalGunCharCapy = 0x00;				// 累计插枪充电充入Ah 数,,Re-0.1,Off-0,Ah
 UINT32 BMS_TotalCharCapy = 0x00;				// 累计充入Ah 数,,Re-0.1,Off-0,Ah
-UINT32 BMS_TotalDisCharCapy = 0x00;				// 累计放出Ah 数,,Re-0.1,Off-0,Ah
+UINT32 BMS_TotalDischarCapy = 0x00;				// 累计放出Ah 数,,Re-0.1,Off-0,Ah
 UINT32 BMS_TotalBackCharCapy = 0x00;			// 累计动能回馈充入Ah 数,,Re-0.1,Off-0,Ah
 UINT32 BMS_TotalStaCharCapy = 0x00;				// 累计换电站充入Ah 数,,Re-0.1,Off-0,Ah
 
 
 
+
 /************************************************************
  *BBox计算变量定义区
  ************************************************************/
+UINT8 BBox_DataReadyFlag = 0;
 UINT8 BBox_PackSOC = 0x00;						//BBox计算SOC,Re-0.4,Off-0;
 UINT8 BBox_PackSOH = 0x00;						//BBox计算SOH,Re-1,Off-0;
-UINT32 BBox_TotalDischarCapy = 0x00;			//BBox计算累计放电Ah,Re-0.1,Off-0,Ah
-UINT32 BBox_TotalCharCapy = 0x00;				//BBox计算累计充电Ah,Re-0.1,Off-0,Ah
-UINT32 BBox_TotalBackCharCapy = 0x00;			//BBox计算累计动能回收Ah,Re-0.1,Off-0,Ah
-UINT32 BBox_TotalDischarEngy = 0x00;			//BBox计算累计放电能量,Re-0.1,Off-0,Kwh
-UINT32 BBox_TotalCharEngy = 0x00;				//BBox计算累计充电能量,Re-0.1,Off-0,Kwh
-UINT32 BBox_TotalBackCharEngy = 0x00;			//BBox计算累计动能回收能量,Re-0.1,Off-0,Kwh
+UINT32 BBox_TotalCharEngy = 0x00;				// 累计充入kWh 数,,Re-0.1,Off-0,KWh
+UINT32 BBox_TotalDischarEngy = 0x00;				// 累计放出kWh 数,,Re-0.1,Off-0,KWh
+UINT32 BBox_TotalBackCharEngy = 0x00;			// 累计动能回馈充入kWh 数,,Re-0.1,Off-0,KWh
+UINT32 BBox_TotalStaCharEngy = 0x00;				// 累计换电站充入kWh 数,,Re-0.1,Off-0,KWh
+UINT32 BBox_TotalGunCharEngy = 0x00;				// 累计插枪充电充入kWh 数,,Re-0.1,Off-0,KWh
+UINT32 BBox_TotalGunCharCapy = 0x00;				// 累计插枪充电充入Ah 数,,Re-0.1,Off-0,Ah
+UINT32 BBox_TotalCharCapy = 0x00;				// 累计充入Ah 数,,Re-0.1,Off-0,Ah
+UINT32 BBox_TotalDischarCapy = 0x00;				// 累计放出Ah 数,,Re-0.1,Off-0,Ah
+UINT32 BBox_TotalBackCharCapy = 0x00;			// 累计动能回馈充入Ah 数,,Re-0.1,Off-0,Ah
+UINT32 BBox_TotalStaCharCapy = 0x00;				// 累计换电站充入Ah 数,,Re-0.1,Off-0,Ah
 UINT32 BBox_Dq_Dv_MAX = 0x00;					//BBox计算dq/dv_MAX,Re-0.001,Off-0,Ah/10mV
 UINT32 BBox_Dq_Dv_MIN = 0x00;					//BBox计算dq/dv_MIN,Re-0.001,Off-0,Ah/10mV
 

+ 28 - 7
code/app/AppGlobalVar.h

@@ -77,6 +77,7 @@ extern char ImeiNum[15];
 extern char IccidNum[20];
 extern uint8 TcpWorkState;
 extern uint8 DeviceErrNum;
+extern uint8 globalSaveFlag;
 typedef struct _AppEppType
 {
     uint32 battDischrgAccCap;//单位mah
@@ -85,6 +86,8 @@ typedef struct _AppEppType
     uint32 battChrgAccEnrg;//单位wh
     uint16 battCycleTimes;
     uint32 AccMileage;
+    uint32 battBackChrgAccCap;	//动能回收安时 mah
+    uint32 battBackChrgAccEngy;	//动能回收能量
 } AppEppBody;
 typedef struct _AppConfigType
 {
@@ -96,6 +99,13 @@ typedef struct _AppConfigType
 } AppConfigBody;
 extern AppConfigBody AppConfigInfo;
 
+
+typedef struct _BcuSaveHader
+{
+	uint8 crc;
+}BcuSaveHader;
+
+
 typedef struct _BcuAppSaveType
 {
 	//real time
@@ -116,8 +126,14 @@ typedef struct _BcuAppSaveType
 	float damd_Q_totalDisChrgCpE;
 	float damd_E_totalDisChrgEngE;
 } BcuAppSaveBody;
-extern BcuAppSaveBody BcuAppSaveDataInfo;
 
+typedef struct _BcuSaveType
+{
+	BcuSaveHader header;
+	BcuAppSaveBody BcuAppSaveDataInfo;
+}BcuSaveType;
+
+extern BcuSaveType BcuSaveDataInfo;
 
 #ifdef APP_CAN_ENABLE
 extern uint8 vehicleStatus;
@@ -319,13 +335,13 @@ extern UINT16 BMS_SingleCharCapy;
 extern UINT16 BMS_HVVolt;
 extern UINT16 TMS_ReqPow;
 extern UINT32 BMS_TotalCharEngy;
-extern UINT32 BMS_TotalDisCharEngy;
+extern UINT32 BMS_TotalDischarEngy;
 extern UINT32 BMS_TotalBackCharEngy;
 extern UINT32 BMS_TotalStaCharEngy;
 extern UINT32 BMS_TotalGunCharEngy;
 extern UINT32 BMS_TotalGunCharCapy;
 extern UINT32 BMS_TotalCharCapy;
-extern UINT32 BMS_TotalDisCharCapy;
+extern UINT32 BMS_TotalDischarCapy;
 extern UINT32 BMS_TotalBackCharCapy;
 extern UINT32 BMS_TotalStaCharCapy;
 #endif
@@ -333,14 +349,19 @@ extern UINT32 BMS_TotalStaCharCapy;
 /************************************************************
  *BBox计算变量定义区
  ************************************************************/
+extern UINT8 BBox_DataReadyFlag;
 extern UINT8 BBox_PackSOC;
 extern UINT8 BBox_PackSOH;
-extern UINT32 BBox_TotalDischarCapy;
-extern UINT32 BBox_TotalCharCapy;
-extern UINT32 BBox_TotalBackCharCapy;
-extern UINT32 BBox_TotalDischarEngy;
 extern UINT32 BBox_TotalCharEngy;
+extern UINT32 BBox_TotalDischarEngy;
 extern UINT32 BBox_TotalBackCharEngy;
+extern UINT32 BBox_TotalStaCharEngy;
+extern UINT32 BBox_TotalGunCharEngy;
+extern UINT32 BBox_TotalGunCharCapy;
+extern UINT32 BBox_TotalCharCapy;
+extern UINT32 BBox_TotalDischarCapy;
+extern UINT32 BBox_TotalBackCharCapy;
+extern UINT32 BBox_TotalStaCharCapy;
 extern UINT32 BBox_Dq_Dv_MAX;
 extern UINT32 BBox_Dq_Dv_MIN;
 

+ 267 - 223
code/app/AppTaskCan.c

@@ -15,7 +15,7 @@ static uint8 BattSendFlg = 0;
 static void UDSAnsFunc(uint8 *rawData);
 static void UdsAns(bool PosFlg, uint8 UdsService, uint8 UdsSubService, uint8 Idx, uint8 *AnsData, uint8 AnsDataLen);
 static void BattSendFunc(void);
-static void CalAccAhFunc(void);
+static void CalAccAhFunc(bool isSaveFlag);
 void CanTask(void *pvParameters)
 {
 	uint32 timerCANIdle = 0x00;
@@ -60,46 +60,86 @@ void CanTask(void *pvParameters)
 				timerCANIdle = 0;
 				xSemaphoreGive(sleep_mutex);
 			}
+			if(BMS_MinCellVolt != 0 && BMS_MaxCellVolt != 0 && BMS_AverCellVolt !=0 && BMS_MinCellVolt != 0xFFFF && BMS_MaxCellVolt != 0xFFFF && BMS_AverCellVolt !=0xFFFF)
+			{
+				BBox_DataReadyFlag = 1;
+			}
 		} while (ret == pdPASS);
 		if ((TimerCounter - timerCounterNow) >= 100)
 		{
 			timerCANIdle = timerCANIdle + 100;
 			BcuRxDiagnose();
 			timerCounterNow = TimerCounter;
-			//累计放电Ah和充电Ah积分计算
-			CalAccAhFunc();
+
+//			static uint8 counter1 = 0;
+//			bool flag = false;
+//			counter1++;
+//			if(counter1>=100) // 10s
+//			{
+//				flag = true;
+//			}
+//			//累计放电Ah和充电Ah积分计算
+//			CalAccAhFunc(flag);
+//			flag = false;
 		}
 	}
 }
-static void CalAccAhFunc(void)//100ms运行一次
+static void CalAccAhFunc(bool isSaveFlag)//100ms运行一次
 {
 	static float tmp_DischrgAh = 0;//mah
 	static float tmp_ChrgAh = 0;//mah
-	if(BcuRxLongError[3]==0)
+	static float tmp_BackChrgAh = 0;
+	if(BcuRxShortError[3]==0)
 	{
 		if(BMS_CharSt==1)//充电计算
 		{
-			tmp_ChrgAh = tmp_ChrgAh + (float)(abs(BMS_PackCurr - 10000)/360);
+			tmp_ChrgAh = tmp_ChrgAh + (float)(abs(BMS_PackCurr/10 - 1000)/360);
 		}
-		else if(BMS_Mode==2)//放电计算
+		else if(BMS_PackCurr > 10000 && BMS_PackCurr!=0xFFFF)//放电计算
 		{
 			tmp_DischrgAh = tmp_DischrgAh + (float)(abs(BMS_PackCurr - 10000)/360);
 		}
-		if(tmp_ChrgAh>1000)
+		else if(BMS_PackCurr < 10000 && BMS_PackCurr > 0)	//动能回收计算
+		{
+			tmp_BackChrgAh += (float)(abs(BMS_PackCurr - 10000)/360);
+		}
+
+		if((tmp_ChrgAh>=1000) && isSaveFlag)
 		{
 			AppConfigInfo.AppDataInfo.battChrgAccCap = AppConfigInfo.AppDataInfo.battChrgAccCap + (uint32)tmp_ChrgAh;
 			tmp_ChrgAh = 0;
-			AppConfigInfo.appSaveFlg = 1;
+
+			if(globalSaveFlag == 0)
+			{
+				AppConfigInfo.appSaveFlg = 1;
+				globalSaveFlag = 1;
+			}
+
 		}
-		if(tmp_DischrgAh>1000)
+		if(tmp_DischrgAh>=1000 && isSaveFlag)
 		{
 			AppConfigInfo.AppDataInfo.battDischrgAccCap = AppConfigInfo.AppDataInfo.battDischrgAccCap + (uint32)tmp_DischrgAh;
 			tmp_DischrgAh = 0;
-			AppConfigInfo.appSaveFlg = 1;
+			if(globalSaveFlag == 0)
+			{
+				AppConfigInfo.appSaveFlg = 1;
+				globalSaveFlag = 1;
+			}
+		}
+		if(tmp_BackChrgAh >= 1000 && isSaveFlag)
+		{
+			AppConfigInfo.AppDataInfo.battBackChrgAccCap = AppConfigInfo.AppDataInfo.battBackChrgAccCap + (uint32)tmp_BackChrgAh;
+			tmp_BackChrgAh = 0;
+			if(globalSaveFlag == 0)
+			{
+				AppConfigInfo.appSaveFlg = 1;
+				globalSaveFlag = 1;
+			}
 		}
 	}
-	BMS_TotalCharCapy = AppConfigInfo.AppDataInfo.battChrgAccCap/100;
-	BMS_TotalDisCharCapy = AppConfigInfo.AppDataInfo.battDischrgAccCap/100;
+	BMS_TotalCharCapy 		=  AppConfigInfo.AppDataInfo.battChrgAccCap/100;
+	BMS_TotalDischarCapy 	=  AppConfigInfo.AppDataInfo.battDischrgAccCap/100;
+	BMS_TotalBackCharCapy 	=  AppConfigInfo.AppDataInfo.battBackChrgAccCap/100;
 }
 // 注意解码超限问题
 void BcuDecodeFunction(uint32 ID, uint8 *rawData)
@@ -204,6 +244,7 @@ void BcuDecodeFunction(uint32 ID, uint8 *rawData)
 		BMS_NegIns = (UINT16)(((*(UINT8 *)(rawData + 2)) | (*(UINT8 *)(rawData + 3) << 8)) & 0xFFFF);
 		BMS_BattVolt = (UINT16)(((*(UINT8 *)(rawData + 4)) | (*(UINT8 *)(rawData + 5) << 8)) & 0xFFFF);
 		BMS_LinkVolt = (UINT16)(((*(UINT8 *)(rawData + 6)) | (*(UINT8 *)(rawData + 7) << 8)) & 0xFFFF);
+		BMS_SysInsRes = min(BMS_PosIns,BMS_NegIns);
 		BcuRxFlag[5] = 0x01;
 		break;
 	case 0x1884D0F3:
@@ -232,22 +273,22 @@ void BcuDecodeFunction(uint32 ID, uint8 *rawData)
 		BcuRxFlag[8] = 0x01;
 		break;
 	case 0x1887D0F3:
-		BMS_CharReqVolt = (UINT16)(((*(UINT8 *)(rawData + 0)) | (*(UINT8 *)(rawData + 1) << 8)) & 0xFFFF);
-		BMS_CharReqCurr = (UINT16)(((*(UINT8 *)(rawData + 2)) | (*(UINT8 *)(rawData + 3) << 8)) & 0xFFFF);
-		BMS_SysInsRes = (UINT16)(((*(UINT8 *)(rawData + 4)) | (*(UINT8 *)(rawData + 5) << 8)) & 0xFFFF);
-		BMS_InsDeteSt = (UINT8)(((*(UINT8 *)(rawData + 6))) & 0x1);
-		BMS_FtCharInsLow = (UINT8)(((*(UINT8 *)(rawData + 6)) >> 1) & 0x1);
-		BMS_FtCurrSenr = (UINT8)(((*(UINT8 *)(rawData + 6)) >> 2) & 0x1);
-		BMS_FtHeatingFilm = (UINT8)(((*(UINT8 *)(rawData + 6)) >> 3) & 0x1);
-		BMS_FtMainLoopPreChar = (UINT8)(((*(UINT8 *)(rawData + 6)) >> 4) & 0x1);
-		BMS_FtAuxLoopPreChar = (UINT8)(((*(UINT8 *)(rawData + 6)) >> 5) & 0x1);
-		BMS_FtACANLost = (UINT8)(((*(UINT8 *)(rawData + 6)) >> 6) & 0x1);
-		BMS_FtDCDC = (UINT8)(((*(UINT8 *)(rawData + 6)) >> 7) & 0x1);
-		BMS_FtSOCDif = (UINT8)(((*(UINT8 *)(rawData + 7))) & 0x1);
-		BMS_FtCellOverDisChar = (UINT8)(((*(UINT8 *)(rawData + 7)) >> 1) & 0x1);
-		BMS_FtCharOver = (UINT8)(((*(UINT8 *)(rawData + 7)) >> 2) & 0x3);
-		BMS_FtContDisCharCurrOverLoad = (UINT8)(((*(UINT8 *)(rawData + 7)) >> 4) & 0x3);
-		BMS_FtContCharCurrOverLoad = (UINT8)(((*(UINT8 *)(rawData + 7)) >> 6) & 0x3);
+//		BMS_CharReqVolt = (UINT16)(((*(UINT8 *)(rawData + 0)) | (*(UINT8 *)(rawData + 1) << 8)) & 0xFFFF);
+//		BMS_CharReqCurr = (UINT16)(((*(UINT8 *)(rawData + 2)) | (*(UINT8 *)(rawData + 3) << 8)) & 0xFFFF);
+//		BMS_SysInsRes = (UINT16)(((*(UINT8 *)(rawData + 4)) | (*(UINT8 *)(rawData + 5) << 8)) & 0xFFFF);
+//		BMS_InsDeteSt = (UINT8)(((*(UINT8 *)(rawData + 6))) & 0x1);
+//		BMS_FtCharInsLow = (UINT8)(((*(UINT8 *)(rawData + 6)) >> 1) & 0x1);
+//		BMS_FtCurrSenr = (UINT8)(((*(UINT8 *)(rawData + 6)) >> 2) & 0x1);
+//		BMS_FtHeatingFilm = (UINT8)(((*(UINT8 *)(rawData + 6)) >> 3) & 0x1);
+//		BMS_FtMainLoopPreChar = (UINT8)(((*(UINT8 *)(rawData + 6)) >> 4) & 0x1);
+//		BMS_FtAuxLoopPreChar = (UINT8)(((*(UINT8 *)(rawData + 6)) >> 5) & 0x1);
+//		BMS_FtACANLost = (UINT8)(((*(UINT8 *)(rawData + 6)) >> 6) & 0x1);
+//		BMS_FtDCDC = (UINT8)(((*(UINT8 *)(rawData + 6)) >> 7) & 0x1);
+//		BMS_FtSOCDif = (UINT8)(((*(UINT8 *)(rawData + 7))) & 0x1);
+//		BMS_FtCellOverDisChar = (UINT8)(((*(UINT8 *)(rawData + 7)) >> 1) & 0x1);
+//		BMS_FtCharOver = (UINT8)(((*(UINT8 *)(rawData + 7)) >> 2) & 0x3);
+//		BMS_FtContDisCharCurrOverLoad = (UINT8)(((*(UINT8 *)(rawData + 7)) >> 4) & 0x3);
+//		BMS_FtContCharCurrOverLoad = (UINT8)(((*(UINT8 *)(rawData + 7)) >> 6) & 0x3);
 		BcuRxFlag[9] = 0x01;
 		break;
 	case 0x1888D0F3:
@@ -433,31 +474,31 @@ void BcuDecodeFunction(uint32 ID, uint8 *rawData)
 		break;
 	case 0x18F1D0F3:
 		BMS_TotalCharEngy = (UINT32)(((*(UINT8 *)(rawData + 0)) | (*(UINT8 *)(rawData + 1) << 8) | (*(UINT8 *)(rawData + 2) << 16) | (*(UINT8 *)(rawData + 3) << 24)) & 0xFFFFFF);
-		BMS_TotalDisCharEngy = (UINT32)(((*(UINT8 *)(rawData + 3)) | (*(UINT8 *)(rawData + 4) << 8) | (*(UINT8 *)(rawData + 5) << 16) | (*(UINT8 *)(rawData + 6) << 24)) & 0xFFFFFF);
+		BMS_TotalDischarEngy = (UINT32)(((*(UINT8 *)(rawData + 3)) | (*(UINT8 *)(rawData + 4) << 8) | (*(UINT8 *)(rawData + 5) << 16) | (*(UINT8 *)(rawData + 6) << 24)) & 0xFFFFFF);
 		BMS_SingleCharEngy = (UINT16)(((*(UINT8 *)(rawData + 6)) | (*(UINT8 *)(rawData + 7) << 8)) & 0xFFFF);
 		BcuRxFlag[21] = 0x01;
 		break;
 	case 0x18F2D0F3:
-		BMS_TotalBackCharEngy = (UINT32)(((*(UINT8 *)(rawData + 0)) | (*(UINT8 *)(rawData + 1) << 8) | (*(UINT8 *)(rawData + 2) << 16) | (*(UINT8 *)(rawData + 3) << 24)) & 0xFFFFFF);
-		BMS_TotalStaCharEngy = (UINT32)(((*(UINT8 *)(rawData + 3)) | (*(UINT8 *)(rawData + 4) << 8) | (*(UINT8 *)(rawData + 5) << 16) | (*(UINT8 *)(rawData + 6) << 24)) & 0xFFFFFF);
+		BMS_TotalBackCharEngy = (UINT32)(((*(UINT8 *)(rawData + 0)) | (*(UINT8 *)(rawData + 1) << 8) | (*(UINT8 *)(rawData + 2) << 16)) & 0xFFFFFF);  //byte1~byte3
+		BMS_TotalStaCharEngy = (UINT32)(((*(UINT8 *)(rawData + 3)) | (*(UINT8 *)(rawData + 4) << 8) | (*(UINT8 *)(rawData + 5) << 16)) & 0xFFFFFF); //byte4~byte6
 		BcuRxFlag[22] = 0x01;
 		break;
 	case 0x18F3D0F3:
-		BMS_TotalGunCharEngy = (UINT32)(((*(UINT8 *)(rawData + 0)) | (*(UINT8 *)(rawData + 1) << 8) | (*(UINT8 *)(rawData + 2) << 16) | (*(UINT8 *)(rawData + 3) << 24)) & 0xFFFFFF);
-		BMS_TotalGunCharCapy = (UINT32)(((*(UINT8 *)(rawData + 3)) | (*(UINT8 *)(rawData + 4) << 8) | (*(UINT8 *)(rawData + 5) << 16) | (*(UINT8 *)(rawData + 6) << 24)) & 0xFFFFFF);
+		BMS_TotalGunCharEngy = (UINT32)(((*(UINT8 *)(rawData + 0)) | (*(UINT8 *)(rawData + 1) << 8) | (*(UINT8 *)(rawData + 2) << 16)) & 0xFFFFFF); //byte1~byte3
+//		BMS_TotalGunCharCapy = (UINT32)(((*(UINT8 *)(rawData + 3)) | (*(UINT8 *)(rawData + 4) << 8) | (*(UINT8 *)(rawData + 5) << 16) | (*(UINT8 *)(rawData + 6) << 24)) & 0xFFFFFF);
 		BcuRxFlag[23] = 0x01;
 		break;
 	case 0x18F4D0F3:
-		BMS_TotalCharCapy = (UINT32)(((*(UINT8 *)(rawData + 0)) | (*(UINT8 *)(rawData + 1) << 8) | (*(UINT8 *)(rawData + 2) << 16) | (*(UINT8 *)(rawData + 3) << 24)) & 0xFFFFFF);
-		BMS_TotalDisCharCapy = (UINT32)(((*(UINT8 *)(rawData + 3)) | (*(UINT8 *)(rawData + 4) << 8) | (*(UINT8 *)(rawData + 5) << 16) | (*(UINT8 *)(rawData + 6) << 24)) & 0xFFFFFF);
+		BMS_TotalCharCapy = (UINT32)(((*(UINT8 *)(rawData + 0)) | (*(UINT8 *)(rawData + 1) << 8) | (*(UINT8 *)(rawData + 2) << 16) ) & 0xFFFFFF); //byte1~byte3
+//		BMS_TotalDischarCapy = (UINT32)(((*(UINT8 *)(rawData + 3)) | (*(UINT8 *)(rawData + 4) << 8) | (*(UINT8 *)(rawData + 5) << 16) | (*(UINT8 *)(rawData + 6) << 24)) & 0xFFFFFF);
 		BMS_SingleCharCapy = (UINT16)(((*(UINT8 *)(rawData + 6)) | (*(UINT8 *)(rawData + 7) << 8)) & 0xFFFF);
 		BcuRxFlag[24] = 0x01;
 		break;
 	case 0x18F5D0F3:
-		BMS_TotalBackCharCapy = (UINT32)(((*(UINT8 *)(rawData + 0)) | (*(UINT8 *)(rawData + 1) << 8) | (*(UINT8 *)(rawData + 2) << 16) | (*(UINT8 *)(rawData + 3) << 24)) & 0xFFFFFF);
-		BMS_TotalStaCharCapy = (UINT32)(((*(UINT8 *)(rawData + 3)) | (*(UINT8 *)(rawData + 4) << 8) | (*(UINT8 *)(rawData + 5) << 16) | (*(UINT8 *)(rawData + 6) << 24)) & 0xFFFFFF);
-		BMS_HVBranNum = (UINT8)(((*(UINT8 *)(rawData + 6))) & 0xFF);
-		BMS_SingleHVBranchCellNum = (UINT8)(((*(UINT8 *)(rawData + 7))) & 0xFF);
+//		BMS_TotalBackCharCapy = (UINT32)(((*(UINT8 *)(rawData + 0)) | (*(UINT8 *)(rawData + 1) << 8) | (*(UINT8 *)(rawData + 2) << 16) | (*(UINT8 *)(rawData + 3) << 24)) & 0xFFFFFF);
+//		BMS_TotalStaCharCapy = (UINT32)(((*(UINT8 *)(rawData + 3)) | (*(UINT8 *)(rawData + 4) << 8) | (*(UINT8 *)(rawData + 5) << 16) | (*(UINT8 *)(rawData + 6) << 24)) & 0xFFFFFF);
+//		BMS_HVBranNum = (UINT8)(((*(UINT8 *)(rawData + 6))) & 0xFF);
+//		BMS_SingleHVBranchCellNum = (UINT8)(((*(UINT8 *)(rawData + 7))) & 0xFF);
 		BcuRxFlag[25] = 0x01;
 		break;
 	case 0x18FF45F4:
@@ -717,8 +758,11 @@ static void UDSAnsFunc(uint8 *rawData)
 				if (deviceSnRecvFlg == 0x1F)
 				{
 					deviceSnRecvFlg = 0;
-					AppConfigInfo.appSaveFlg = true;
 					AppConfigInfo.eolFlg = true;
+					AppConfigInfo.appSaveFlg = false;
+					HAL_EEP_Write(200, (uint8 *)&AppConfigInfo, sizeof(AppConfigInfo));
+					AppConfigInfo.appSaveFlg = true;
+
 				}
 				break;
 			}
@@ -911,7 +955,7 @@ void BcuRxDiagnose(void) // 100ms调用一次
 {
 
 	static UINT32 TimeCounter = 0;	// ms
-	TimeCounter = TimeCounter + 10; //
+	TimeCounter = TimerCounter; //
 	for (UINT8 i = 0; i < sizeof(BcuInTable) / 4; i++)
 	{
 		if (BcuRxFlag[i] == 1) // received msg, and clear the error conter
@@ -932,12 +976,12 @@ void BcuRxDiagnose(void) // 100ms调用一次
 		}
 		else if (BcuRxErrorCounter[i] >= 13)
 		{
-			BcuRxShortError[i] = 0;
+			BcuRxShortError[i] = 1;
 			BcuRxLongError[i] = 1;
-//			BcuRxMsgSetInvalidValue(BcuInTable[i]);
-			BcuRxErrorCounter[i] = 0;
+			BcuRxMsgSetInvalidValue(BcuInTable[i]);
+//			BcuRxErrorCounter[i] = 0;
 		}
-		else if (BcuRxErrorCounter[i] == 0xFF)
+		if (BcuRxErrorCounter[i] == 0xFF)
 		{
 			BcuRxErrorCounter[i] = 0xFE;
 		}
@@ -1013,98 +1057,98 @@ void BcuRxMsgSetInvalidValue(uint32 ID)
 	switch (ID)
 	{
 	case 0x1801D0F3:
-		BMS_ReqVIN = 0xFF;
-		BMS_ReqHVOff = 0xFF;
+//		BMS_ReqVIN = 0xFF;
+//		BMS_ReqHVOff = 0xFF;
 		break;
 	case 0x1801D8F3:
-		BMS_SoftwareVersion = 0xFFFF;
-		BMS_HardwareVersion = 0xFFFF;
-		BMS_ProtocolEditionH = 0xFF;
-		BMS_ProtocolEditionL = 0xFF;
+//		BMS_SoftwareVersion = 0xFFFF;
+//		BMS_HardwareVersion = 0xFFFF;
+//		BMS_ProtocolEditionH = 0xFF;
+//		BMS_ProtocolEditionL = 0xFF;
 		break;
 	case 0x1880D0F3:
-		BMS_CharDevNum = 0xFF;
-		BMS_FtPosRly = 0xFF;
-		BMS_FtNegRly = 0xFF;
-		BMS_FtPosCharRly1 = 0xFF;
-		BMS_FtNegCharRly1 = 0xFF;
-		BMS_FtPosCharRly2 = 0xFF;
-		BMS_FtNegCharRly2 = 0xFF;
-		BMS_FtHeatRly1 = 0xFF;
-		BMS_FtHeatRly2 = 0xFF;
-		BMS_StPosRly = 0xFF;
-		BMS_StNegRly = 0xFF;
-		BMS_StPreCharRly = 0xFF;
-		BMS_StPosCharRly1 = 0xFF;
-		BMS_StNegCharRly1 = 0xFF;
-		BMS_StPosCharRly2 = 0xFF;
-		BMS_StNegCharRly2 = 0xFF;
-		BMS_FtAuxRelayWeld = 0xFF;
-		BMS_BraOpenCirc = 0xFF;
-		BMS_FtBackCharCurrOutLim = 0xFF;
-		BMS_FtPosRlyOpen = 0xFF;
-		BMS_FtNegRlyOpen = 0xFF;
-		BMS_FtPosCharRly1Open = 0xFF;
-		BMS_FtPosCharRly2Open = 0xFF;
-		BMS_FtNegCharRly1Open = 0xFF;
-		BMS_FtNegCharRly2Open = 0xFF;
-		BMS_FtTMSContClose = 0xFF;
-		BMS_FtTMSContOpen = 0xFF;
-		BMS_FtTMS = 0xFF;
-		BMS_Ft24VSpy = 0xFF;
-		BMS_FtPACKSelfProt = 0xFF;
-		BMS_FtCharSockTempOver = 0xFF;
-		BMS_FtTempOutCtrl = 0xFF;
-		BMS_StPosHeatRly = 0xFF;
-		BMS_StNegHeatRly = 0xFF;
-		BMS_CharSysNum = 0xFF;
-		BMS_FtCode = 0xFF;
+//		BMS_CharDevNum = 0xFF;
+//		BMS_FtPosRly = 0xFF;
+//		BMS_FtNegRly = 0xFF;
+//		BMS_FtPosCharRly1 = 0xFF;
+//		BMS_FtNegCharRly1 = 0xFF;
+//		BMS_FtPosCharRly2 = 0xFF;
+//		BMS_FtNegCharRly2 = 0xFF;
+//		BMS_FtHeatRly1 = 0xFF;
+//		BMS_FtHeatRly2 = 0xFF;
+//		BMS_StPosRly = 0xFF;
+//		BMS_StNegRly = 0xFF;
+//		BMS_StPreCharRly = 0xFF;
+//		BMS_StPosCharRly1 = 0xFF;
+//		BMS_StNegCharRly1 = 0xFF;
+//		BMS_StPosCharRly2 = 0xFF;
+//		BMS_StNegCharRly2 = 0xFF;
+//		BMS_FtAuxRelayWeld = 0xFF;
+//		BMS_BraOpenCirc = 0xFF;
+//		BMS_FtBackCharCurrOutLim = 0xFF;
+//		BMS_FtPosRlyOpen = 0xFF;
+//		BMS_FtNegRlyOpen = 0xFF;
+//		BMS_FtPosCharRly1Open = 0xFF;
+//		BMS_FtPosCharRly2Open = 0xFF;
+//		BMS_FtNegCharRly1Open = 0xFF;
+//		BMS_FtNegCharRly2Open = 0xFF;
+//		BMS_FtTMSContClose = 0xFF;
+//		BMS_FtTMSContOpen = 0xFF;
+//		BMS_FtTMS = 0xFF;
+//		BMS_Ft24VSpy = 0xFF;
+//		BMS_FtPACKSelfProt = 0xFF;
+//		BMS_FtCharSockTempOver = 0xFF;
+//		BMS_FtTempOutCtrl = 0xFF;
+//		BMS_StPosHeatRly = 0xFF;
+//		BMS_StNegHeatRly = 0xFF;
+//		BMS_CharSysNum = 0xFF;
+//		BMS_FtCode = 0xFF;
 		break;
 	case 0x1881D0F3:
-		BMS_ST1CheckSum = 0xFF;
-		BMS_ST1Counter = 0xFF;
-		BMS_Mode = 0xFF;
-		BMS_AuxRlySt = 0xFF;
-		BMS_BattBalaSt = 0xFF;
-		BMS_CharGunSt = 0xFF;
-		BMS_CharMode = 0xFF;
-		BMS_CharSt = 0xFF;
-		BMS_FtLvl = 0xFF;
-		BMS_FtCellTempDiff = 0xFF;
-		BMS_FtCellTempHigh = 0xFF;
-		BMS_FtPACKOverVolt = 0xFF;
-		BMS_FtPACKUndeVolt = 0xFF;
-		BMS_FtSOCLow = 0xFF;
-		BMS_FtCellOverVolt = 0xFF;
-		BMS_FtCellUndeVolt = 0xFF;
-		BMS_FtIns = 0xFF;
-		BMS_FtCellOverVoltDiff = 0xFF;
-		BMS_FtCharCurrOver = 0xFF;
-		BMS_FtDisCharCurrOver = 0xFF;
-		BMS_FtCellTempLow = 0xFF;
-		BMS_FtBranVoltDifOver = 0xFF;
-		BMS_FtBMSHardWare = 0xFF;
-		BMS_FtSOCHigh = 0xFF;
-		BMS_FtSOCJump = 0xFF;
-		BMS_FtInCom = 0xFF;
-		BMS_FtSysMism = 0xFF;
-		BMS_FtHvIntLock = 0xFF;
-		BMS_FtSmoke = 0xFF;
-		BMS_FtFire = 0xFF;
-		BMS_FtNum = 0xFF;
+//		BMS_ST1CheckSum = 0xFF;
+//		BMS_ST1Counter = 0xFF;
+//		BMS_Mode = 0xFF;
+//		BMS_AuxRlySt = 0xFF;
+//		BMS_BattBalaSt = 0xFF;
+//		BMS_CharGunSt = 0xFF;
+//		BMS_CharMode = 0xFF;
+		BMS_CharSt = 0x02;
+//		BMS_FtLvl = 0xFF;
+//		BMS_FtCellTempDiff = 0xFF;
+//		BMS_FtCellTempHigh = 0xFF;
+//		BMS_FtPACKOverVolt = 0xFF;
+//		BMS_FtPACKUndeVolt = 0xFF;
+//		BMS_FtSOCLow = 0xFF;
+//		BMS_FtCellOverVolt = 0xFF;
+//		BMS_FtCellUndeVolt = 0xFF;
+//		BMS_FtIns = 0xFF;
+//		BMS_FtCellOverVoltDiff = 0xFF;
+//		BMS_FtCharCurrOver = 0xFF;
+//		BMS_FtDisCharCurrOver = 0xFF;
+//		BMS_FtCellTempLow = 0xFF;
+//		BMS_FtBranVoltDifOver = 0xFF;
+//		BMS_FtBMSHardWare = 0xFF;
+//		BMS_FtSOCHigh = 0xFF;
+//		BMS_FtSOCJump = 0xFF;
+//		BMS_FtInCom = 0xFF;
+//		BMS_FtSysMism = 0xFF;
+//		BMS_FtHvIntLock = 0xFF;
+//		BMS_FtSmoke = 0xFF;
+//		BMS_FtFire = 0xFF;
+//		BMS_FtNum = 0xFF;
 		break;
 	case 0x1882D0F3:
-		BMS_PackSOC = 0xFF;
-		BMS_PackSOH = 0xFF;
-		BMS_PackCurr = 0xFFFF;
-		BMS_MaxCharCurr = 0xFFFF;
-		BMS_MaxDisCharCurr = 0xFFFF;
+//		BMS_PackSOC = 0xFF;
+//		BMS_PackSOH = 0xFF;
+		BMS_PackCurr = 0x2710;
+//		BMS_MaxCharCurr = 0xFFFF;
+//		BMS_MaxDisCharCurr = 0xFFFF;
 		break;
 	case 0x1883D0F3:
 		BMS_PosIns = 0xFFFF;
 		BMS_NegIns = 0xFFFF;
-		BMS_BattVolt = 0xFFFF;
-		BMS_LinkVolt = 0xFFFF;
+//		BMS_BattVolt = 0xFFFF;
+//		BMS_LinkVolt = 0xFFFF;
 		break;
 	case 0x1884D0F3:
 		BMS_MaxCellTemp = 0xFF;
@@ -1129,95 +1173,95 @@ void BcuRxMsgSetInvalidValue(uint32 ID)
 		BMS_ContDisCharCurr = 0xFFFF;
 		break;
 	case 0x1887D0F3:
-		BMS_CharReqVolt = 0xFFFF;
-		BMS_CharReqCurr = 0xFFFF;
-		BMS_SysInsRes = 0xFFFF;
-		BMS_InsDeteSt = 0xFF;
-		BMS_FtCharInsLow = 0xFF;
-		BMS_FtCurrSenr = 0xFF;
-		BMS_FtHeatingFilm = 0xFF;
-		BMS_FtMainLoopPreChar = 0xFF;
-		BMS_FtAuxLoopPreChar = 0xFF;
-		BMS_FtACANLost = 0xFF;
-		BMS_FtDCDC = 0xFF;
-		BMS_FtSOCDif = 0xFF;
-		BMS_FtCellOverDisChar = 0xFF;
-		BMS_FtCharOver = 0xFF;
-		BMS_FtContDisCharCurrOverLoad = 0xFF;
-		BMS_FtContCharCurrOverLoad = 0xFF;
+//		BMS_CharReqVolt = 0xFFFF;
+//		BMS_CharReqCurr = 0xFFFF;
+//		BMS_SysInsRes = 0xFFFF;
+//		BMS_InsDeteSt = 0xFF;
+//		BMS_FtCharInsLow = 0xFF;
+//		BMS_FtCurrSenr = 0xFF;
+//		BMS_FtHeatingFilm = 0xFF;
+//		BMS_FtMainLoopPreChar = 0xFF;
+//		BMS_FtAuxLoopPreChar = 0xFF;
+//		BMS_FtACANLost = 0xFF;
+//		BMS_FtDCDC = 0xFF;
+//		BMS_FtSOCDif = 0xFF;
+//		BMS_FtCellOverDisChar = 0xFF;
+//		BMS_FtCharOver = 0xFF;
+//		BMS_FtContDisCharCurrOverLoad = 0xFF;
+//		BMS_FtContCharCurrOverLoad = 0xFF;
 		break;
 	case 0x1888D0F3:
-		BMS_MaxDisCharPwr = 0xFFFF;
-		BMS_MaxCharPwr = 0xFFFF;
-		BMS_ContDisCharPwr = 0xFFFF;
-		BMS_ContCharPwr = 0xFFFF;
+//		BMS_MaxDisCharPwr = 0xFFFF;
+//		BMS_MaxCharPwr = 0xFFFF;
+//		BMS_ContDisCharPwr = 0xFFFF;
+//		BMS_ContCharPwr = 0xFFFF;
 		break;
 	case 0x1889D0F3:
-		BMS_InstEngyCons = 0xFFFF;
-		BMS_TotalEngyCons = 0xFFFF;
-		BMS_SOE = 0xFFFF;
-		BMS_RmanCharTime = 0xFFFF;
+//		BMS_InstEngyCons = 0xFFFF;
+//		BMS_TotalEngyCons = 0xFFFF;
+//		BMS_SOE = 0xFFFF;
+//		BMS_RmanCharTime = 0xFFFF;
 		break;
 	case 0x188AD0F3:
-		BMS_Gun1DCNegTemp = 0xFF;
-		BMS_Gun1DCPosTemp = 0xFF;
-		BMS_Gun2DCNegTemp = 0xFF;
-		BMS_Gun2DCPosTemp = 0xFF;
-		BMS_CurrHeatSt = 0xFF;
-		BMS_CurrCoolSt = 0xFF;
-		BMS_FtCharCnct = 0xFF;
-		BMS_FtOverDisCharCurrDuringChar = 0xFF;
-		BMS_FtCharNTC = 0xFF;
-		BMS_FtELock = 0xFF;
-		BMS_CharNum = 0xFFFF;
+//		BMS_Gun1DCNegTemp = 0xFF;
+//		BMS_Gun1DCPosTemp = 0xFF;
+//		BMS_Gun2DCNegTemp = 0xFF;
+//		BMS_Gun2DCPosTemp = 0xFF;
+//		BMS_CurrHeatSt = 0xFF;
+//		BMS_CurrCoolSt = 0xFF;
+//		BMS_FtCharCnct = 0xFF;
+//		BMS_FtOverDisCharCurrDuringChar = 0xFF;
+//		BMS_FtCharNTC = 0xFF;
+//		BMS_FtELock = 0xFF;
+//		BMS_CharNum = 0xFFFF;
 		break;
 	case 0x18C1D0F3:
-		BMS_CellVoltFramNum = 0xFF;
-		memset(canRecvFramNum,0x00,sizeof(canRecvFramNum));
-		BMS_CellRecvFlg = 0;
-		for (UINT16 i = 0; i < sizeof(BMS_CellVolt) / 2; i++)
-		{
-			BMS_CellVolt[i] = 0xFFFF;
-		}
+//		BMS_CellVoltFramNum = 0xFF;
+//		memset(canRecvFramNum,0x00,sizeof(canRecvFramNum));
+//		BMS_CellRecvFlg = 0;
+//		for (UINT16 i = 0; i < sizeof(BMS_CellVolt) / 2; i++)
+//		{
+//			BMS_CellVolt[i] = 0xFFFF;
+//		}
 		break;
 	case 0x18C2D0F3:
-		BMS_CellTempFramNum = 0xFF;
-		BMS_CSC_Code = 0xFF;
-		for (UINT8 i = 0; i < sizeof(BMS_CellTemp); i++)
-		{
-			BMS_CellTemp[i] = 0xFF;
-		}
+//		BMS_CellTempFramNum = 0xFF;
+//		BMS_CSC_Code = 0xFF;
+//		for (UINT8 i = 0; i < sizeof(BMS_CellTemp); i++)
+//		{
+//			BMS_CellTemp[i] = 0xFF;
+//		}
 		break;
 	case 0x18E1D0F3:
-		BMS_Checksum = 0xFF;
-		BMS_PackComp = 0xFF;
-		BMS_BattCodeLeng = 0xFF;
-		BMS_SN[0] = 0xFF;
-		BMS_SN[1] = 0xFF;
-		BMS_SN[2] = 0xFF;
-		BMS_SN[3] = 0xFF;
-		BMS_SN[4] = 0xFF;
-		BMS_SN[5] = 0xFF;
+//		BMS_Checksum = 0xFF;
+//		BMS_PackComp = 0xFF;
+//		BMS_BattCodeLeng = 0xFF;
+//		BMS_SN[0] = 0xFF;
+//		BMS_SN[1] = 0xFF;
+//		BMS_SN[2] = 0xFF;
+//		BMS_SN[3] = 0xFF;
+//		BMS_SN[4] = 0xFF;
+//		BMS_SN[5] = 0xFF;
 		break;
 	case 0x18E2D0F3:
-		BMS_Checksum = 0xFF;
-		BMS_SN[6] = 0xFF;
-		BMS_SN[7] = 0xFF;
-		BMS_SN[8] = 0xFF;
-		BMS_SN[9] = 0xFF;
-		BMS_SN[10] = 0xFF;
-		BMS_SN[11] = 0xFF;
-		BMS_SN[12] = 0xFF;
+//		BMS_Checksum = 0xFF;
+//		BMS_SN[6] = 0xFF;
+//		BMS_SN[7] = 0xFF;
+//		BMS_SN[8] = 0xFF;
+//		BMS_SN[9] = 0xFF;
+//		BMS_SN[10] = 0xFF;
+//		BMS_SN[11] = 0xFF;
+//		BMS_SN[12] = 0xFF;
 		break;
 	case 0x18E3D0F3:
-		BMS_Checksum = 0xFF;
-		BMS_SN[13] = 0xFF;
-		BMS_SN[14] = 0xFF;
-		BMS_SN[15] = 0xFF;
-		BMS_SN[16] = 0xFF;
-		BMS_SN[17] = 0xFF;
-		BMS_SN[18] = 0xFF;
-		BMS_SN[19] = 0xFF;
+//		BMS_Checksum = 0xFF;
+//		BMS_SN[13] = 0xFF;
+//		BMS_SN[14] = 0xFF;
+//		BMS_SN[15] = 0xFF;
+//		BMS_SN[16] = 0xFF;
+//		BMS_SN[17] = 0xFF;
+//		BMS_SN[18] = 0xFF;
+//		BMS_SN[19] = 0xFF;
 		break;
 	case 0x18E4D0F3:
 		BMS_Checksum = 0xFF;
@@ -1230,11 +1274,11 @@ void BcuRxMsgSetInvalidValue(uint32 ID)
 //		BMS_SN[26] = 0xFF;
 		break;
 	case 0x18E5D0F3:
-		BMS_BattRateCap = 0xFFFF;
-		BMS_BattRateVolt = 0xFFFF;
-		BMS_BattRateEngy = 0xFFFF;
-		BMS_BattType = 0xFF;
-		BMS_CoolType = 0xFF;
+//		BMS_BattRateCap = 0xFFFF;
+//		BMS_BattRateVolt = 0xFFFF;
+//		BMS_BattRateEngy = 0xFFFF;
+//		BMS_BattType = 0xFF;
+//		BMS_CoolType = 0xFF;
 		break;
 	case 0x18E6D0F3:
 		BMS_CSC_Total = 0xFF;
@@ -1263,29 +1307,29 @@ void BcuRxMsgSetInvalidValue(uint32 ID)
 //		BMS_SingleCharCapy = 0xFFFF;
 		break;
 	case 0x18F5D0F3:
-		BMS_TotalBackCharCapy = 0xFFFFFFFF;
-		BMS_TotalStaCharCapy = 0xFFFFFFFF;
-		BMS_HVBranNum = 0xFF;
-		BMS_SingleHVBranchCellNum = 0xFF;
+//		BMS_TotalBackCharCapy = 0xFFFFFFFF;
+//		BMS_TotalStaCharCapy = 0xFFFFFFFF;
+//		BMS_HVBranNum = 0xFF;
+//		BMS_SingleHVBranchCellNum = 0xFF;
 		break;
 	case 0x18FF45F4:
-		BMS_ReqMode = 0xFF;
-		BMS_HVCmd = 0xFF;
-		BMS_ChgSts = 0xFF;
-		BMS_HVRelaySts = 0xFF;
-		BMS_HVVolt = 0xFFFF;
-		BMS_SetTemp = 0xFF;
-		BMS_Life = 0xFF;
-		BMS_CRC = 0xFF;
+//		BMS_ReqMode = 0xFF;
+//		BMS_HVCmd = 0xFF;
+//		BMS_ChgSts = 0xFF;
+//		BMS_HVRelaySts = 0xFF;
+//		BMS_HVVolt = 0xFFFF;
+//		BMS_SetTemp = 0xFF;
+//		BMS_Life = 0xFF;
+//		BMS_CRC = 0xFF;
 		break;
 	case 0x18FFC13A:
-		TMS_WorkStatus = 0xFF;
-		TMS_HVRelayST = 0xFF;
-		TMS_OutletTemp = 0xFF;
-		TMS_InletTemp = 0xFF;
-		TMS_ReqPow = 0xFFFF;
-		TMS_ErrCode = 0xFF;
-		TMS_FaultLevel = 0xFF;
+//		TMS_WorkStatus = 0xFF;
+//		TMS_HVRelayST = 0xFF;
+//		TMS_OutletTemp = 0xFF;
+//		TMS_InletTemp = 0xFF;
+//		TMS_ReqPow = 0xFFFF;
+//		TMS_ErrCode = 0xFF;
+//		TMS_FaultLevel = 0xFF;
 		break;
 	default:
 		break;

+ 10 - 2
code/app/AppTaskGps.c

@@ -183,9 +183,17 @@ void GpsDataDecode(uint8 *msg)
 				GpsInfoData.speed[0] = 0;
 				GpsInfoData.speed[1] = 0;
 			}
-			if (speedtemp >= 50 && speedtemp <= 1500)
+			if (speedtemp >= 50 && speedtemp <= 2000) //speed is between 5km/h and 200km/h is reliable
 			{
-				AppConfigInfo.appSaveFlg = true;
+				static uint16 accMileageTemp = 0;
+				accMileageTemp += speedtemp / 36;
+				if(accMileageTemp >= 500 && globalSaveFlag == 0)
+				{
+					globalSaveFlag = 1;
+					AppConfigInfo.appSaveFlg = true;
+					accMileageTemp = 0;
+				}
+
 				AppConfigInfo.AppDataInfo.AccMileage = speedtemp / 36 + AppConfigInfo.AppDataInfo.AccMileage;
 				if (AppConfigInfo.AppDataInfo.AccMileage >= 0xfffffffe)
 				{

+ 20 - 11
code/app/AppTaskMain.c

@@ -20,13 +20,16 @@ void MainTask(void *pvParameters)
 
 	sleep_mutex = xSemaphoreCreateBinary();
 
-	uint32 *eppromAddStart = 0x14000000;
-	if (*(uint8 *)(eppromAddStart) == 0xff)
-	{
-		HAL_EEP_Write(0, (uint8 *)&AppConfigInfo, sizeof(AppConfigInfo));
-	}
-	HAL_EEP_Read(0, (uint8 *)&AppConfigInfo, sizeof(AppConfigInfo));
-	HAL_EEP_Read(200, (uint8 *)&BcuAppSaveDataInfo, sizeof(BcuAppSaveDataInfo));
+
+//	HAL_EEP_Read(400, (uint8 *)&BcuSaveDataInfo, sizeof(BcuSaveDataInfo));
+//	if (*(uint8 *)(eppromAddStart + 400) == 0xff || BcuSaveDataInfo.BcuAppSaveDataInfo.CRC != bcc_chk(&(BcuAppSaveDataInfo.CRC)+1,sizeof(BcuAppSaveDataInfo)-1));
+//	{
+//		memset(&BcuAppSaveDataInfo,0,sizeof(BcuAppSaveBody));
+//		BcuAppSaveDataInfo.CRC = bcc_chk(&(BcuAppSaveDataInfo.CRC)+1,sizeof(BcuAppSaveDataInfo)-1);
+//		BcuAppSaveDataInfo.bcuSaveFlg = false;
+//		HAL_EEP_Write(400, (uint8 *)&BcuAppSaveDataInfo, sizeof(BcuAppSaveDataInfo));
+//	}
+
 	while (1)
 	{
 		vTaskDelay(pdMS_TO_TICKS(10));
@@ -41,18 +44,24 @@ void MainTask(void *pvParameters)
 		{
 			AppConfigInfo.appSaveFlg = false;
 			HAL_EEP_Write(0, (uint8 *)&AppConfigInfo, sizeof(AppConfigInfo));
+			globalSaveFlag = 0;
 		}
-		if(BcuAppSaveDataInfo.bcuSaveFlg)
+		if(BcuSaveDataInfo.BcuAppSaveDataInfo.bcuSaveFlg)
 		{
-			BcuAppSaveDataInfo.bcuSaveFlg = false;
-			HAL_EEP_Write(200, (uint8 *)&BcuAppSaveDataInfo, sizeof(BcuAppSaveDataInfo));
+			BcuSaveDataInfo.BcuAppSaveDataInfo.bcuSaveFlg = false;
+			BcuSaveDataInfo.header.crc = bcc_chk(&(BcuSaveDataInfo.BcuAppSaveDataInfo),sizeof(BcuSaveDataInfo.BcuAppSaveDataInfo));
+			HAL_EEP_Write(400, (uint8 *)&BcuSaveDataInfo, sizeof(BcuSaveDataInfo));
 		}
 		if (Fota_update_flag==1)
 		{
 			// 重启前保存数据
 			AppConfigInfo.appSaveFlg = false;
 			HAL_EEP_Write(0, (uint8 *)&AppConfigInfo, sizeof(AppConfigInfo));
-			HAL_EEP_Write(200, (uint8 *)&BcuAppSaveDataInfo, sizeof(BcuAppSaveDataInfo));
+			HAL_EEP_Write(200, (uint8 *)&AppConfigInfo, sizeof(AppConfigInfo));
+
+			BcuSaveDataInfo.BcuAppSaveDataInfo.bcuSaveFlg = false;
+			BcuSaveDataInfo.header.crc = bcc_chk(&(BcuSaveDataInfo.BcuAppSaveDataInfo),sizeof(BcuSaveDataInfo.BcuAppSaveDataInfo));
+			HAL_EEP_Write(400, (uint8 *)&BcuSaveDataInfo, sizeof(BcuSaveDataInfo));
 			SystemSoftwareReset();
 		}
 #ifndef SEGGER_RTT_PRINTF

+ 52 - 47
code/app/AppTaskUart1.c

@@ -1015,7 +1015,7 @@ void TcpDataEncode(uint8 DataIdx,uint32 *PtrSendAddr, uint16 *SendLen)
 	}
 	case DebugMsg:
 	{
-		extern char gpsTestBuffer[20];
+//		extern char gpsTestBuffer[20];
 		char rbuf[512]={0};
 		char tmp[13] = {0};
 		memcpy(tmp,BMS_SN,12);
@@ -1027,7 +1027,9 @@ void TcpDataEncode(uint8 DataIdx,uint32 *PtrSendAddr, uint16 *SendLen)
 								{%.2f,%.2f,%.2f,%.2f,%.2f;\
 								%.2f,%.2f,%.2f,%.2f,%.2f,}\
 								{%.2f,%.2f,%.2f,%.2f,%.2f;\
-								%.2f,%.2f,%.2f,%.2f,%.2f,},%s,%d,%s",
+								%.2f,%.2f,%.2f,%.2f,%.2f,},%s,%d,\
+								{%.2f,%.2f,%.2f,%.2f,\
+								%d,%d,%d,%d,%d,%d}",
 				returnFreq[0][0], returnFreq[0][1], returnFreq[0][2], returnFreq[0][3], returnFreq[0][4],
 				returnP[0][0], returnP[0][1], returnP[0][2], returnP[0][3], returnP[0][4],
 
@@ -1035,7 +1037,9 @@ void TcpDataEncode(uint8 DataIdx,uint32 *PtrSendAddr, uint16 *SendLen)
 				returnP[1][0], returnP[1][1], returnP[1][2], returnP[1][3], returnP[1][4],
 
 				returnFreq[2][0], returnFreq[2][1], returnFreq[2][2], returnFreq[2][3], returnFreq[2][4],
-				returnP[2][0], returnP[2][1], returnP[2][2], returnP[2][3], returnP[2][4],tmp,DeviceErrNum,gpsTestBuffer);
+				returnP[2][0], returnP[2][1], returnP[2][2], returnP[2][3], returnP[2][4],tmp,DeviceErrNum,
+				socd_pct_ahSoc,socd_pct_battSoc,socd_pct_bcuSoc,socd_pct_ekfSoc,
+				BBox_TotalCharEngy,BBox_TotalDischarEngy,BBox_TotalBackCharEngy,BBox_TotalCharCapy,BBox_TotalDischarCapy,BBox_TotalBackCharCapy);
 
 		BufferLen = strlen((const char *)rbuf);
 		*SendLen = BufferLen + sizeof(DebugMsgInfo);
@@ -1176,6 +1180,7 @@ void TcpDataEncode(uint8 DataIdx,uint32 *PtrSendAddr, uint16 *SendLen)
 		*(SendBuffer + 0x2F) = (BMS_BattVolt & 0xFF);
 		*(SendBuffer + 0x30) = ((BMS_PackCurr >> 8) & 0xFF); // uint16	电池包总电流,充电为负值,放电为正值 精度_0.1,偏移量_-1000,单位_A
 		*(SendBuffer + 0x31) = (BMS_PackCurr & 0xFF);
+
 		*(SendBuffer + 0x32) = ((BMS_SysInsRes >> 8) & 0xFF); // uint16	系统绝缘电阻 精度_1,偏移量_0,单位_KΩ
 		*(SendBuffer + 0x33) = (BMS_SysInsRes & 0xFF);
 		/*28 Byte 继电器状态*/
@@ -1232,42 +1237,42 @@ void TcpDataEncode(uint8 DataIdx,uint32 *PtrSendAddr, uint16 *SendLen)
 		*(SendBuffer + 0x22) = (UTC8TimeTcp.hour & 0xFF);		   // uint8	hour
 		*(SendBuffer + 0x23) = (UTC8TimeTcp.minute & 0xFF);		   // uint8	minute
 		*(SendBuffer + 0x24) = (UTC8TimeTcp.second & 0xFF);		   // uint8	second
-		*(SendBuffer + 0x25) = ((BMS_TotalCharCapy >> 24) & 0xFF); // uint32	累积充入Ah 数 精度_0.1,偏移量_0,单位_Ah
-		*(SendBuffer + 0x26) = ((BMS_TotalCharCapy >> 16) & 0xFF);
-		*(SendBuffer + 0x27) = ((BMS_TotalCharCapy >> 8) & 0xFF);
-		*(SendBuffer + 0x28) = (BMS_TotalCharCapy & 0xFF);
-		*(SendBuffer + 0x29) = ((BMS_TotalDisCharCapy >> 24) & 0xFF); // uint32	累积放出Ah 数 精度_0.1,偏移量_0,单位_Ah
-		*(SendBuffer + 0x2A) = ((BMS_TotalDisCharCapy >> 16) & 0xFF);
-		*(SendBuffer + 0x2B) = ((BMS_TotalDisCharCapy >> 8) & 0xFF);
-		*(SendBuffer + 0x2C) = (BMS_TotalDisCharCapy & 0xFF);
+		*(SendBuffer + 0x25) = ((BBox_TotalCharCapy >> 24) & 0xFF); // uint32	累积充入Ah 数 精度_0.1,偏移量_0,单位_Ah
+		*(SendBuffer + 0x26) = ((BBox_TotalCharCapy >> 16) & 0xFF);
+		*(SendBuffer + 0x27) = ((BBox_TotalCharCapy >> 8) & 0xFF);
+		*(SendBuffer + 0x28) = (BBox_TotalCharCapy & 0xFF);
+		*(SendBuffer + 0x29) = ((BBox_TotalDischarCapy >> 24) & 0xFF); // uint32	累积放出Ah 数 精度_0.1,偏移量_0,单位_Ah
+		*(SendBuffer + 0x2A) = ((BBox_TotalDischarCapy >> 16) & 0xFF);
+		*(SendBuffer + 0x2B) = ((BBox_TotalDischarCapy >> 8) & 0xFF);
+		*(SendBuffer + 0x2C) = (BBox_TotalDischarCapy & 0xFF);
 		*(SendBuffer + 0x2D) = ((BMS_TotalCharEngy >> 24) & 0xFF); // uint32	累计充入kWh 数 精度_0.1,偏移量_0,单位_KWh
 		*(SendBuffer + 0x2E) = ((BMS_TotalCharEngy >> 16) & 0xFF);
 		*(SendBuffer + 0x2F) = ((BMS_TotalCharEngy >> 8) & 0xFF);
 		*(SendBuffer + 0x30) = (BMS_TotalCharEngy & 0xFF);
-		*(SendBuffer + 0x31) = ((BMS_TotalDisCharEngy >> 24) & 0xFF); // uint32	累计放出kWh 数 精度_0.1,偏移量_0,单位_KWh
-		*(SendBuffer + 0x32) = ((BMS_TotalDisCharEngy >> 16) & 0xFF);
-		*(SendBuffer + 0x33) = ((BMS_TotalDisCharEngy >> 8) & 0xFF);
-		*(SendBuffer + 0x34) = (BMS_TotalDisCharEngy & 0xFF);
-		*(SendBuffer + 0x35) = ((BMS_TotalBackCharCapy >> 24) & 0xFF); // uint32	累计动能回馈充入Ah 数 精度_0.1,偏移量_0,单位_Ah
-		*(SendBuffer + 0x36) = ((BMS_TotalBackCharCapy >> 16) & 0xFF);
-		*(SendBuffer + 0x37) = ((BMS_TotalBackCharCapy >> 8) & 0xFF);
-		*(SendBuffer + 0x38) = (BMS_TotalBackCharCapy & 0xFF);
+		*(SendBuffer + 0x31) = ((BMS_TotalDischarEngy >> 24) & 0xFF); // uint32	累计放出kWh 数 精度_0.1,偏移量_0,单位_KWh
+		*(SendBuffer + 0x32) = ((BMS_TotalDischarEngy >> 16) & 0xFF);
+		*(SendBuffer + 0x33) = ((BMS_TotalDischarEngy >> 8) & 0xFF);
+		*(SendBuffer + 0x34) = (BMS_TotalDischarEngy & 0xFF);
+		*(SendBuffer + 0x35) = ((BBox_TotalBackCharCapy >> 24) & 0xFF); // uint32	累计动能回馈充入Ah 数 精度_0.1,偏移量_0,单位_Ah
+		*(SendBuffer + 0x36) = ((BBox_TotalBackCharCapy >> 16) & 0xFF);
+		*(SendBuffer + 0x37) = ((BBox_TotalBackCharCapy >> 8) & 0xFF);
+		*(SendBuffer + 0x38) = (BBox_TotalBackCharCapy & 0xFF);
 		*(SendBuffer + 0x39) = ((BMS_TotalBackCharEngy >> 24) & 0xFF); // uint32	累计动能回馈充入kWh 数 精度_0.1,偏移量_0,单位_KWh
 		*(SendBuffer + 0x3A) = ((BMS_TotalBackCharEngy >> 16) & 0xFF);
 		*(SendBuffer + 0x3B) = ((BMS_TotalBackCharEngy >> 8) & 0xFF);
 		*(SendBuffer + 0x3C) = (BMS_TotalBackCharEngy & 0xFF);
-		*(SendBuffer + 0x3D) = ((BMS_TotalStaCharCapy >> 24) & 0xFF); // uint32	累计换电站充入Ah 数 精度_0.1,偏移量_0,单位_Ah
-		*(SendBuffer + 0x3E) = ((BMS_TotalStaCharCapy >> 16) & 0xFF);
-		*(SendBuffer + 0x3F) = ((BMS_TotalStaCharCapy >> 8) & 0xFF);
-		*(SendBuffer + 0x40) = (BMS_TotalStaCharCapy & 0xFF);
+		*(SendBuffer + 0x3D) = ((BBox_TotalStaCharCapy >> 24) & 0xFF); // uint32	累计换电站充入Ah 数 精度_0.1,偏移量_0,单位_Ah
+		*(SendBuffer + 0x3E) = ((BBox_TotalStaCharCapy >> 16) & 0xFF);
+		*(SendBuffer + 0x3F) = ((BBox_TotalStaCharCapy >> 8) & 0xFF);
+		*(SendBuffer + 0x40) = (BBox_TotalStaCharCapy & 0xFF);
 		*(SendBuffer + 0x41) = ((BMS_TotalStaCharEngy >> 24) & 0xFF); // uint32	累计换电站充入kWh 数 精度_0.1,偏移量_0,单位_KWh
 		*(SendBuffer + 0x42) = ((BMS_TotalStaCharEngy >> 16) & 0xFF);
 		*(SendBuffer + 0x43) = ((BMS_TotalStaCharEngy >> 8) & 0xFF);
 		*(SendBuffer + 0x44) = (BMS_TotalStaCharEngy & 0xFF);
-		*(SendBuffer + 0x45) = ((BMS_TotalGunCharCapy >> 24) & 0xFF); // uint32	累计插枪充电充入Ah 数 精度_0.1,偏移量_0,单位_Ah
-		*(SendBuffer + 0x46) = ((BMS_TotalGunCharCapy >> 16) & 0xFF);
-		*(SendBuffer + 0x47) = ((BMS_TotalGunCharCapy >> 8) & 0xFF);
-		*(SendBuffer + 0x48) = (BMS_TotalGunCharCapy & 0xFF);
+		*(SendBuffer + 0x45) = ((BBox_TotalGunCharCapy >> 24) & 0xFF); // uint32	累计插枪充电充入Ah 数 精度_0.1,偏移量_0,单位_Ah
+		*(SendBuffer + 0x46) = ((BBox_TotalGunCharCapy >> 16) & 0xFF);
+		*(SendBuffer + 0x47) = ((BBox_TotalGunCharCapy >> 8) & 0xFF);
+		*(SendBuffer + 0x48) = (BBox_TotalGunCharCapy & 0xFF);
 		*(SendBuffer + 0x49) = ((BMS_TotalGunCharEngy >> 24) & 0xFF); // uint32	累计插枪充电充入kWh 数 精度_0.1,偏移量_0,单位_KWh
 		*(SendBuffer + 0x4A) = ((BMS_TotalGunCharEngy >> 16) & 0xFF);
 		*(SendBuffer + 0x4B) = ((BMS_TotalGunCharEngy >> 8) & 0xFF);
@@ -1302,13 +1307,13 @@ void TcpDataEncode(uint8 DataIdx,uint32 *PtrSendAddr, uint16 *SendLen)
 		*(SendBuffer + 0x22) = (UTC8TimeTcp.hour & 0xFF);		   // uint8	hour
 		*(SendBuffer + 0x23) = (UTC8TimeTcp.minute & 0xFF);		   // uint8	minute
 		*(SendBuffer + 0x24) = (UTC8TimeTcp.second & 0xFF);		   // uint8	second
-
-		BMS_BattVolt = 5678;
-		BMS_PackCurr = 35+10000;
-		BMS_MaxCellVolt = 4235;
-		BMS_MinCellVolt = 4123;
-		BMS_MaxCellTemp = 25+50;
-		BMS_MinCellTemp = 20+50;
+//		test data
+//		BMS_BattVolt = 5678;
+//		BMS_PackCurr = 35+10000;
+//		BMS_MaxCellVolt = 4235;
+//		BMS_MinCellVolt = 4123;
+//		BMS_MaxCellTemp = 25+50;
+//		BMS_MinCellTemp = 20+50;
 
 		*(SendBuffer + 0x25) = (BMS_BattVolt >> 8) & 0xFF;	   		// 电池包总电压
 		*(SendBuffer + 0x26) = (BMS_BattVolt & 0xFF);
@@ -1351,19 +1356,19 @@ void TcpDataEncode(uint8 DataIdx,uint32 *PtrSendAddr, uint16 *SendLen)
 		*(SendBuffer + 0x23) = (UTC8TimeTcp.minute & 0xFF);		   // uint8	minute
 		*(SendBuffer + 0x24) = (UTC8TimeTcp.second & 0xFF);		   // uint8	second
 
-
-		BMS_PackSOC = 20/0.4;
-		BMS_PackSOH = 95/0.4;
-		BBox_PackSOC = 91/0.4;
-		BBox_PackSOH = 96;
-		BBox_TotalDischarCapy = 12345;
-		BBox_TotalCharCapy 	 = 23456;
-		BBox_TotalBackCharCapy = 34567;
-		BBox_TotalDischarEngy = 45678;
-		BBox_TotalCharEngy = 56789;
-		BBox_TotalBackCharEngy= 67890;
-		BBox_Dq_Dv_MAX = 123456;
-		BBox_Dq_Dv_MIN = 111112;
+//      test data
+//		BMS_PackSOC = 20/0.4;
+//		BMS_PackSOH = 95/0.4;
+//		BBox_PackSOC = 91/0.4;
+//		BBox_PackSOH = 96;
+//		BBox_TotalDischarCapy = 12345;
+//		BBox_TotalCharCapy 	 = 23456;
+//		BBox_TotalBackCharCapy = 34567;
+//		BBox_TotalDischarEngy = 45678;
+//		BBox_TotalCharEngy = 56789;
+//		BBox_TotalBackCharEngy= 67890;
+//		BBox_Dq_Dv_MAX = 123456;
+//		BBox_Dq_Dv_MIN = 111112;
 
 		*(SendBuffer + 0x25) = (BMS_PackSOC) & 0xFF;	   		   // BMS计算SOC
 		*(SendBuffer + 0x26) = (BMS_PackSOH / 25 * 10) & 0xFF;     // SOH 精度1%

+ 56 - 5
code/hal/hal_adapter.c

@@ -1243,14 +1243,65 @@ void displayResetReasonWithLED(void)
 	bootreason = Mcu_GetResetReason();
 }
 
+void readConfigAndDataFromEEPROM(void)
+{
+	uint32 *eppromAddStart = 0x14000000;
+	if (*(uint8 *)(eppromAddStart) == 0xff)
+	{
+		HAL_EEP_Write(0, (uint8 *)&AppConfigInfo, sizeof(AppConfigInfo));
+	}
+
+	Std_ReturnType readRet = HAL_EEP_Read(0, (uint8 *)&AppConfigInfo, sizeof(AppConfigInfo));
+	if(readRet == E_NOT_OK)
+	{
+		uint8 cycleTimes = 0;
+		while(HAL_EEP_Read(200, (uint8 *)&AppConfigInfo, sizeof(AppConfigInfo))==E_NOT_OK && cycleTimes<=5) //backup data addr:200
+		{
+			cycleTimes++;
+		}
+	}
+
+	//read bcu data
+	HAL_EEP_Read(400, (uint8 *)&BcuSaveDataInfo, sizeof(BcuSaveDataInfo));
+	if(BcuSaveDataInfo.header.crc != bcc_chk(&(BcuSaveDataInfo.BcuAppSaveDataInfo),sizeof(BcuSaveDataInfo.BcuAppSaveDataInfo)))
+	{
+//		memset(&BcuSaveDataInfo,0,sizeof(BcuSaveType));
+//		BcuSaveDataInfo.BcuAppSaveDataInfo.bcuSaveFlg = false;
+//		BcuSaveDataInfo.header.crc = bcc_chk(&(BcuSaveDataInfo.BcuAppSaveDataInfo),sizeof(BcuSaveDataInfo.BcuAppSaveDataInfo));
+//		HAL_EEP_Write(400, (uint8 *)&BcuSaveDataInfo, sizeof(BcuSaveDataInfo));
+		rtev_flg_EESt[0] = 1;
+		rtev_flg_EESt[1] = 1;
+		rtev_flg_EESt[2] = 1;
+		rtev_flg_EESt[3] = 1;
+	}
+}
+
 void IH_Data_Update(void)
 {
 	ihd_pct_socCor = 0;
+
 	sohd_pct_bcuSoh = (real32_T)(BMS_PackSOH*0.4);
-	ihd_V_cellUAvrg = (real32_T)(BMS_AverCellVolt/1000.0);
-	ihd_V_cellUMax = (real32_T)(BMS_MaxCellVolt/1000.0);
-	ihd_V_cellUMin = (real32_T)(BMS_MinCellVolt/1000.0);
-	ihd_V_battU_T2 = (real32_T)(BMS_BattVolt*0.1);
+
+	if(BMS_MaxCellVolt != 0 && BMS_MaxCellVolt != 0xFFFF)
+	{
+		ihd_V_cellUMax = (real32_T)(BMS_MaxCellVolt/1000.0);
+	}
+
+	if(BMS_MinCellVolt != 0 && BMS_MinCellVolt != 0xFFFF)
+	{
+		ihd_V_cellUMin = (real32_T)(BMS_MinCellVolt/1000.0);
+	}
+
+	if(BMS_AverCellVolt != 0 && BMS_AverCellVolt != 0xFFFF)
+	{
+		ihd_V_cellUAvrg = (real32_T)(BMS_AverCellVolt/1000.0);
+	}
+
+	if(BMS_BattVolt != 0 && BMS_BattVolt != 0xFFFF)
+	{
+		ihd_V_battU_T2 = (real32_T)(BMS_BattVolt*0.1);
+	}
+
 	ihd_I_battCurr_T2 = (real32_T)(BMS_PackCurr*0.1)-1000;
 	dcmd_st_chrgSt_T2 = BMS_CharSt;
 
@@ -1270,7 +1321,7 @@ void OH_Data_Update(void)
 	BBox_TotalDischarEngy	= (uint32)(damd_E_totalDisChrgEng*10);		//累计放电电电量
 	BBox_TotalBackCharEngy 	= (uint32)(damd_E_totalRegenEng*10);		//累计回收电量
 	BBox_TotalCharCapy 		= (uint32)(damd_Q_totalChrgCp*10);			//累计充电容量
-	BBox_TotalDischarEngy 	= (uint32)(damd_Q_totalDisChrgCp*10);		//累计放电电容量
+	BBox_TotalDischarCapy 	= (uint32)(damd_Q_totalDisChrgCp*10);		//累计放电电容量
 	BBox_TotalBackCharCapy 	= (uint32)(damd_Q_totalRegenCp*10);			//累计回收容量
 }
 

+ 2 - 0
code/hal/hal_adapter.h

@@ -46,6 +46,7 @@
 #include "hal_Wdg.h"
 #include "rtwtypes.h"
 #include "BCUDisp.h"
+#include "AppFuncLib.h"
 /*适应性定义*/
 typedef unsigned char UINT8;
 typedef unsigned short UINT16;
@@ -263,6 +264,7 @@ void SystemDeinit(void);
 void MCUSleep(void);
 void MCUEnterSleep(void);
 void displayResetReasonWithLED(void);
+void readConfigAndDataFromEEPROM(void);
 
 void IH_Data_Update(void);
 void OH_Data_Update(void);

+ 5 - 1
code/main.c

@@ -73,7 +73,8 @@ int main(void)
 	volatile int exit_code = 0;
 	coreInit();
 	SystemModulesInit();
-	displayResetReasonWithLED();
+//	displayResetReasonWithLED();
+	readConfigAndDataFromEEPROM();
 #ifdef SEGGER_SYSTEMVIEW
 	SEGGER_SYSVIEW_Conf();
 	SEGGER_SYSVIEW_Start();
@@ -83,6 +84,9 @@ int main(void)
 	cm_backtrace_init(APPNAME, HARDWARE_VERSION, SOFTWARE_VERSION);
 	SEGGER_RTT_printf("boot\n");
 #endif
+
+
+
 	UartInit();
 	xTaskCreate(MainTask, (const char *const)"MainTask", 512, (void *)0, main_TASK_PRIORITY + 6, &MainTask_Handle);
 	//xTaskCreate(Uart0Task, (const char *const)"Uart0_Bms_Task", 512, (void *)0, main_TASK_PRIORITY + 2, Uart0Task_Handle);