?? poweru.lst
字號:
文件:PowerU.c 盛群編譯器版本 3.00 頁次1
; 70: {
70 0000 __acsr EQU [023H]
70 0000 __adcr EQU [022H]
70 0000 __adrh EQU [021H]
70 0000 __adrl EQU [020H]
70 0000 __pwm0 EQU [01fH]
70 0000 __intc1 EQU [01eH]
70 0000 __ctrl1 EQU [01bH]
70 0000 __ctrl0 EQU [01aH]
70 0000 __pcpu EQU [019H]
70 0000 __pcc EQU [018H]
70 0000 __pc EQU [017H]
70 0000 __pbpu EQU [016H]
70 0000 __pbc EQU [015H]
70 0000 __pb EQU [014H]
70 0000 __pawk EQU [013H]
70 0000 __papu EQU [012H]
70 0000 __pac EQU [011H]
70 0000 __pa EQU [010H]
70 0000 __tmr0c EQU [0dH]
70 0000 __tmr0 EQU [0cH]
70 0000 __intc0 EQU [0bH]
70 0000 __status EQU [0aH]
70 0000 __wdts EQU [09H]
70 0000 __tblh EQU [08H]
70 0000 __tblp EQU [07H]
70 0000 __pcl EQU [06H]
70 0000 __acc EQU [05H]
70 0000 __mp1 EQU [03H]
70 0000 __mp0 EQU [01H]
70 0000 __iar1 EQU [02H]
70 0000 __iar0 EQU [00H]
70 0000 @All_LED_Off .SECTION 'CODE'
70 0000 PUBLIC _All_LED_Off
70 0000 _All_LED_Off PROC
; 71: LED1PORT=TURN_OFF;
71 0000 3414 CLR [014H].0
; 72: LED2PORT=TURN_OFF;
72 0001 3494 CLR [014H].1
; 73: LED3PORT=TURN_OFF;
73 0002 3514 CLR [014H].2
; 74: LED4PORT=TURN_OFF;
74 0003 3594 CLR [014H].3
; 75: LED5PORT=TURN_OFF;
75 0004 3614 CLR [014H].4
75 0005 L1:
75 0005 0003 RET
75 0006 _All_LED_Off ENDP
; 79: {
79 0000 @All_LED_ON .SECTION 'CODE'
79 0000 PUBLIC _All_LED_ON
文件:PowerU.c 盛群編譯器版本 3.00 頁次2
79 0000 _All_LED_ON PROC
; 80: LED1PORT=TURN_ON;
80 0000 3014 SET [014H].0
; 81: LED2PORT=TURN_ON;
文件:PowerU.c 盛群編譯器版本 3.00 頁次2
81 0001 3094 SET [014H].1
; 82: LED3PORT=TURN_ON;
82 0002 3114 SET [014H].2
; 83: LED4PORT=TURN_ON;
83 0003 3194 SET [014H].3
; 84: LED5PORT=TURN_ON;
84 0004 3214 SET [014H].4
84 0005 L2:
84 0005 0003 RET
84 0006 _All_LED_ON ENDP
; 88: {
88 0000 @ADC_GetBatteryData .SECTION 'CODE'
88 0000 PUBLIC _ADC_GetBatteryData
88 0000 _ADC_GetBatteryData PROC
; 89: _start=0;
89 0000 37A2 CLR [022H].7
; 90: _start=1;
90 0001 33A2 SET [022H].7
; 91: _start=0;
91 0002 37A2 CLR [022H].7
91 0003 2800 R JMP L5
91 0004 L4:
; 95: clr wdt
95 0004 0001 clr wdt
95 0005 L5:
; 92: while(_eocb==1)
92 0005 3F22 SZ [022H].6
92 0006 2800 R JMP L4
; 98: _start=0;
98 0007 37A2 CLR [022H].7
; 99: _start=1;
99 0008 33A2 SET [022H].7
; 100: _start=0;
100 0009 37A2 CLR [022H].7
100 000A 2800 R JMP L8
100 000B L7:
; 104: clr wdt
104 000B 0001 clr wdt
104 000C L8:
文件:PowerU.c 盛群編譯器版本 3.00 頁次3
; 101: while(_eocb==1)
101 000C 3F22 SZ [022H].6
101 000D 2800 R JMP L7
; 107: tempinta=_adrh;
107 000E 0721 MOV A,__adrh
107 000F 0080 R MOV _tempinta,A
107 0010 1F00 R CLR _tempinta[1]
; 108: tempinta*=16;
108 0011 1180 R SWAP _tempinta[1]
108 0012 0FF0 MOV A,0F0H
108 0013 0680 R ANDM A,_tempinta[1]
108 0014 1100 R SWAPA _tempinta
108 0015 0E0F AND A,0FH
108 0016 0580 R ORM A,_tempinta[1]
文件:PowerU.c 盛群編譯器版本 3.00 頁次3
108 0017 1180 R SWAP _tempinta
108 0018 0FF0 MOV A,0F0H
108 0019 0680 R ANDM A,_tempinta
; 109: tempinta+=_adrl/16;
109 001A 1120 SWAPA __adrl
109 001B 0E0F AND A,0FH
109 001C 0080 R MOV b0_3,A
109 001D 0700 R MOV A,b0_3
109 001E 0380 R ADDM A,_tempinta
109 001F 1F05 CLR [05H]
109 0020 1380 R ADCM A,_tempinta[1]
; 111: templonga=0x9c4000; //2500*4096=0x9c4000,由于編譯器的原因,此處不能寫成2500*4096,而要直接寫成0x9c4000
111 0021 0F00 MOV A,00h
111 0022 0080 R MOV _templonga,A
111 0023 0F40 MOV A,040h
111 0024 0080 R MOV _templonga[1],A
111 0025 0F9C MOV A,09ch
111 0026 0080 R t
_wdts=0b00000111;
// _ctrl1=0b10000101;//Enable WDT;
}
void main()
{
if(_to==0) //上電復(fù)位
{
sys_init();
All_LED_ON();
Counter_100ms_counter=0;
while(Counter_100ms_counter<30)//接上電芯后,所有LED點亮3秒后熄滅。
{
#asm
clr wdt
#endasm
}
LED6PORT_Data_SHADE=TURN_OFF;
LED6PORT=LED6PORT_Data_SHADE;
WDT_Over_Counter=0;
文件:PowerU.c 盛群編譯器版本 3.00 頁次4
battery_voltage=ADC_GetBatteryData();//執(zhí)行一次ADC轉(zhuǎn)換
Previous_Level=BATT_VOL_SEG_Just();
goto sleep;
}
main_infinity_loop:
sys_init();
if(_to==1) //watchdog time-out occurred
{
/* WDT_Over_Counter++;
if(WDT_Over_Counter>=57600) //(96小時乘3600秒)除6
{
Counter_100ms_counter=0;
while(Counter_100ms_counter<2)//等待外圍電路穩(wěn)定。
{
#asm
clr wdt
#endasm
}
battery_voltage=ADC_GetBatteryData();
tempchara=BATT_VOL_SEG_Just();
if(tempchara<Previous_Level) Previous_Level--;
WDT_Over_Counter=0;
}
if(just_discharge()==TRUE) //看門狗溢出喚醒后,若偵測到放電,則跳轉(zhuǎn)到放電處理程序
goto Discharging;
else
*/ goto sleep;
}
if(BUTTON1_NOPRESSED)//不是由按鍵喚醒的
{
Counter_100ms_counter=0;
while(Counter_100ms_counter<5)//延時0.5秒,規(guī)避插上充電器的瞬間的不穩(wěn)定。
{
#asm
clr wdt
#endasm
}
}
if(CHARGER_PLUGGED)//充電中
{
Charging:
// DISCHARGE_DISABLE;
battery_voltage=ADC_GetBatteryData();//執(zhí)行一次ADC轉(zhuǎn)換
tempchara=BATT_VOL_SEG_Just();
Previous_Level=tempchara;
Counter_1second_background=0;
for(;CHARGER_PLUGGED;)//充電中
{
if(Previous_Level<=1) Previous_Level=1;
battery_voltage=ADC_GetBatteryData();//執(zhí)行一次ADC轉(zhuǎn)換
tempchara=BATT_VOL_SEG_Just();
if(tempchara==Previous_Level) Counter_1second_background=0;
if(Counter_1second_background>120)//如果在120秒內(nèi),每次采樣得到的電壓段與之前都不一樣,則說明電壓真的改變了。
{
if(tempchara>Previous_Level)Previous_Level++;
Counter_1second_background=0;
文件:PowerU.c 盛群編譯器版本 3.00 頁次5
}
LED_ShowVoltage(Previous_Level); //電壓顯示
//充滿的判斷..........
Charge_Full_flag=FALSE;
if(CHARGER_PLUGGED && CHARGE_FULL)
{
Counter_100ms_counter=0;
Charge_Full_flag=TRUE;
while(Counter_100ms_counter<30)//_pa3處于高電平長達3秒,則判為已充滿
{
if(CHARGER_UNPLUGGED || CHARGE_UNFULL)
{
Charge_Full_flag=FALSE;
break;
}
#asm
clr wdt
#endasm
}
}
if(Charge_Full_flag==TRUE)//已經(jīng)充滿
{
All_LED_ON();
Previous_Level=4;
while(CHARGER_PLUGGED)//充滿后,等待充電器移除
{
#asm
clr wdt
#endasm
}
Counter_100ms_counter=0;
while(Counter_100ms_counter<50)//當(dāng)取下充電器后5S,LED燈全滅,MCU自動進入休眠狀態(tài)。
{
#asm
clr wdt
#endasm
}
goto sleep;
}
}
LED_ShowVoltage(Previous_Level);//非充滿的情況下取下充電器后,由于前一次跑馬完成后,LED都是熄滅的,所以在此還需再點亮
Counter_100ms_counter=0;
while(Counter_100ms_counter<50)//當(dāng)取下充電器后5S,LED燈全滅,MCU自動進入休眠狀態(tài)。
{
#asm
clr wdt
#endasm
}
goto sleep;
}
// DISCHARGE_ENABLE;
while(BUTTON1_PRESSED)//如果有Button1按下,則等其松開
{
#asm
clr wdt
#endasm
}
if(LED6_Update_flag==TRUE)
{
Counter_100ms_counter=0;
文件:PowerU.c 盛群編譯器版本 3.00 頁次6
while(Counter_100ms_counter==0);//延時一下再進入休眠,避開Button1松開時的毛刺
goto sleep;
}
battery_voltage=ADC_GetBatteryData();//執(zhí)行一次ADC轉(zhuǎn)換
tempchara=BATT_VOL_SEG_Just();
// if(tempchara<Previous_Level) Previous_Level=tempchara;//非充電狀態(tài)下,電壓只容許下降
Previous_Level=tempchara;
Voltage_Display();
while(BUTTON1_PRESSED)//如果有Button1按下,則等其松開
{
#asm
clr wdt
#endasm
}
sleep:
if(CHARGER_PLUGGED)
goto Charging;
All_LED_Off();
_adonb=1; //關(guān)閉ADC的電源
_pb5=0;
_adcr=0;
#asm
HALT //進入sleep
NOP
NOP
#endasm
//初始化ADC
_t0on=0;//停止timer0
_emi = 0; // Disable global interrupt
#asm
clr wdt
#endasm
goto main_infinity_loop;
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -