ZDBMS/output/LowPower.lst

265 lines
13 KiB
Plaintext
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

C51 COMPILER V9.01 LOWPOWER 02/19/2025 10:42:27 PAGE 1
C51 COMPILER V9.01, COMPILATION OF MODULE LOWPOWER
OBJECT MODULE PLACED IN .\output\LowPower.obj
COMPILER INVOKED BY: D:\Tool\Keil\C51\BIN\C51.EXE code_app\LowPower.c LARGE OPTIMIZE(7,SIZE) REGFILE(.\output\MCUCore_Lo
-ad.ORC) BROWSE INTVECTOR(0X1000) INCDIR(.\header_app;.\header_drv;.\code_gasguage;.\code_classb\iec60730_lib\include;.\c
-ode_classb\iec60730_proc\Include;.\code_classb\config) DEBUG OBJECTEXTEND PRINT(.\output\LowPower.lst) OBJECT(.\output\L
-owPower.obj)
line level source
1 /********************************************************************************
2 Copyright (C), Sinowealth Electronic. Ltd.
3 Author: Sino
4 Version: V0.0
5 Date: 2020/04/26
6 History:
7 V2.0 2020/04/26 Preliminary
8 ********************************************************************************/
9 #include "Main.h"
10
11
12 BOOL bSleepFlg; //系统进入IDLE标志
13 BOOL bPDFlg;
14 BOOL bWakeupFlg;
15 BOOL bPCEnterPDFlg; //PC通知系统进入SLEEP标志
16 U8 xdata ucSleepTimerCnt;
17 U8 xdata ucPDTimerCnt;
18 U8 xdata ucResetFlag;
19
20 /*************************************************************************************************
21 * 函数名: WakeUpProcess
22 * 参 数: 无
23 * 返回值: 无
24 * 描 述: 从Sleep模式唤醒可通过电流检测和按键唤醒
25 *************************************************************************************************/
26 void WakeUpProcess(void)
27 {
28 1 if(bWakeupFlg)
29 1 {
30 2 bWakeupFlg = 0;
31 2 if(bSleepFlg)
32 2 {
33 3 McuClockSet(MCU_CLK_24MHz);
34 3 IrqEn();
35 3
36 3 bSleepFlg = 0;
37 3 ucSleepTimerCnt = 0;
38 3 Delay1ms(1);
39 3
40 3 #if (UART0_DEFINE != 0)
41 3 IrqUart0En(); //开启uart0中断
42 3 #endif
43 3 IrqTimer3En(); //开启Timer3中断
44 3 McuTwiEn(); //开启MCU Twi模块
45 3
46 3 AfeAlarmDis(AFE_ALARM_SC | AFE_ALARM_OV | AFE_ALARM_CD);
47 3 AfeTempADCEn(); //开启AFE温度采集
48 3 AfeWDTEn(); //开启AFE WDT
49 3 }
50 2 ucSleepTimerCnt = 0;
51 2 ucPDTimerCnt = 0;
52 2 ucUart0TimeoutCnt = 0;
C51 COMPILER V9.01 LOWPOWER 02/19/2025 10:42:27 PAGE 2
53 2 ucUart1TimeoutCnt = 0;
54 2 ucUart2TimeoutCnt = 0;
55 2 }
56 1 }
57
58
59 /*************************************************************************************************
60 * 函数名: SystemIntoPD
61 * 参 数: 无
62 * 返回值: 无
63 * 描 述: 系统进入掉电模式
64 *************************************************************************************************/
65 void SystemIntoPD(void)
66 {
67 1 while(1)
68 1 {
69 2 McuWDTClear(); //清除看门狗
70 2
71 2 IrqDis(); //关闭中断源
72 2 // LEDAllOff(); //关闭LED显示
73 2 BlueToothPowerDis(); //关闭蓝牙模块
74 2 AFEMosCtl(0); //关闭MOS驱动
75 2
76 2 AFEEnterPD(); //关闭3.3V电源
77 2 }
78 1 }
79
80
81 /*************************************************************************************************
82 * 函数名: SystemIntoSleep
83 * 参 数: 无
84 * 返回值: 无
85 * 描 述: 低功耗处理进入IDLE或者PD
86 *************************************************************************************************/
87 void SystemIntoSleep(void)
88 {
89 1 // LEDAllOff(); //关闭LED显示
90 1 BlueToothPowerDis(); //关闭蓝牙模块
91 1 bLedDisBleFlg = 0;
92 1
93 1 AfeWDTDis(); //关闭AFE WDT
94 1 AfeTempADCDis(); //关闭AFE温度采集
95 1 AfeAlarmEn(AFE_ALARM_SC | AFE_ALARM_OV | AFE_ALARM_CD); //开启SC,OV,CD的Alarm功能
96 1 McuTwiDis(); //关闭MCU Twi模块降低功耗
97 1 McuPWM2Dis(); //关闭MCU PWM模块
98 1 if(bDSGMOS) //DSG开启时直接输出高电平
99 1 {
100 2 IO_DSG_PWM = 1;
101 2 }
102 1 else
103 1 {
104 2 IO_DSG_PWM = 0;
105 2 }
106 1 Delay1ms(1);
107 1
108 1 IrqDis(); //关闭总中断源
109 1 #if (UART0_DEFINE != 0)
110 1 IrqUart0Dis();
111 1 #endif
112 1 #if (UART1_DEFINE != 0)
IrqUart1Dis();
#endif
C51 COMPILER V9.01 LOWPOWER 02/19/2025 10:42:27 PAGE 3
115 1 #if (UART2_DEFINE != 0)
IrqUart2Dis();
#endif
118 1 IrqTimer3Dis(); //关闭Timer3中断
119 1 IrqINT4FlgClr(); //保留外部中断4清标志
120 1 McuClockSet(MCU_CLK_128KHz); //设置系统时钟为128KHz
121 1 IrqEn();
122 1
123 1 McuIntoPD(); //MCU进入PD可通过外部按键或ALARM唤醒。由于在系<E59CA8>
-辰鴖leep后可能没有关DSG MOS可能因为持续的小电流而将电芯耗空但是AFE内部预留FUSE在VDD电压低于4V时会关闭LDO使V33<33>
-系纭<E7B3BB>
124 1 }
125
126
127
128
129 /*************************************************************************************************
130 * 函数名: LowPowerCheck
131 * 参 数: 无
132 * 返回值: 无
133 * 描 述: 检测是否进入IDLE或者PD
134 *************************************************************************************************/
135 void LowPowerCheck(void)
136 {
137 1 if(bPCEnterPDFlg && (bUart0SndAckFlg||bUart1SndAckFlg||bUart2SndAckFlg)) //上位机发送
-名字强制进入PD
138 1 {
139 2 bPCEnterPDFlg = 0;
140 2 bPDFlg = 1;
141 2 }
142 1 else if(bCTO) //发生断线后延时进入PD
143 1 {
144 2 if(++ucPDTimerCnt >= E2ucLowPowerDeley)
145 2 {
146 3 ucPDTimerCnt = E2ucLowPowerDeley;
147 3 bPDFlg = 1;
148 3 }
149 2 }
150 1 else if(!bLedDisFlg) //LED显示关闭后开始检测进入低功耗
151 1 {
152 2 if(!bCHGING && !bDSGING) //非充非放状态
153 2 {
154 3 if(bUV) //发生欠压保护后延时进入PD
155 3 {
156 4 if(++ucPDTimerCnt >= E2ucLowPowerDeley)
157 4 {
158 5 ucPDTimerCnt = E2ucLowPowerDeley;
159 5 bPDFlg = 1;
160 5 }
161 4 }
162 3 else //未发生欠压保护且未发生其他保护则延时进入IDLE
163 3 {
164 4 ucPDTimerCnt = 0;
165 4 if(!(bOTC | bUTC | bOV | bOCC | bOTD | bUTD | bUV | bOCD1 | bOCD2 | bAFE_SC | bLedDisBleFl
-g))
166 4 {
167 5 if(++ucSleepTimerCnt >= E2ucLowPowerDeley)
168 5 {
169 6 ucSleepTimerCnt = E2ucLowPowerDeley;
170 6 bSleepFlg = 1;
171 6 }
172 5 }
C51 COMPILER V9.01 LOWPOWER 02/19/2025 10:42:27 PAGE 4
173 4 else
174 4 {
175 5 ucSleepTimerCnt = 0;
176 5 }
177 4 }
178 3 }
179 2 else
180 2 {
181 3 ucSleepTimerCnt = 0;
182 3 ucPDTimerCnt = 0;
183 3 }
184 2 }
185 1 else
186 1 {
187 2 ucSleepTimerCnt = 0;
188 2 ucPDTimerCnt = 0;
189 2 }
190 1 }
191
192
193 /*************************************************************************************************
194 * 函数名: LowPowerProcess
195 * 参 数: 无
196 * 返回值: 无
197 * 描 述: 低功耗处理进入IDLE或者PD
198 *************************************************************************************************/
199 void LowPowerProcess(void)
200 {
201 1 if(!bSleepFlg && !bPDFlg)
202 1 {
203 2 IrqDis();
204 2 if(!(bKeyFlg | bCaliFlg | bMcuFlashWrFlg | bWakeupFlg | bISPFlg | bTimer50msFlg | bTimer1sFlg) && (ucRes
-etFlag!=0x12))
205 2 {
206 3 IrqEn();
207 3 McuIntoIdle();
208 3 }
209 2 IrqEn();
210 2 }
211 1 else if(bPDFlg)
212 1 {
213 2 bMcuFlashWrFlg = 1;
214 2 McuFlashProcess();
215 2 SystemIntoPD();
216 2 }
217 1 else if(bSleepFlg)
218 1 {
219 2 SystemIntoSleep();
220 2 }
221 1
222 1 WakeUpProcess(); //系统从低功耗唤醒
223 1 }
224
225
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 342 ----
CONSTANT SIZE = ---- ----
XDATA SIZE = 3 ----
PDATA SIZE = ---- ----
DATA SIZE = ---- ----
C51 COMPILER V9.01 LOWPOWER 02/19/2025 10:42:27 PAGE 5
IDATA SIZE = ---- ----
BIT SIZE = 4 ----
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)