📄 main.lst
字号:
C51 COMPILER V7.06 MAIN 05/14/2007 21:18:12 PAGE 1
C51 COMPILER V7.06, COMPILATION OF MODULE MAIN
OBJECT MODULE PLACED IN main.OBJ
COMPILER INVOKED BY: D:\Programes\Keil\C51\BIN\C51.EXE main.c OPTIMIZE(0,SPEED) BROWSE DEBUG OBJECTEXTEND
stmt level source
1 /****************************************Copyright (c)**************************************************
2 ** 广州广微电子有限公司
3 ** Guangzhou Microwide Electronic Co.,Ltd.
4 ** http://www.micro-wide.com
5 **
6 **----------------------------------------File Info----------------------------------------------------
7 ** File name: main.c
8 ** Last modified Date: 2007-05-04
9 ** Last Version: 1.0
10 ** Descriptions: 32×12 LED 屏测试程序
11 **
12 **
13 **------------------------------------------------------------------------------------------------------
14 ** Created by: stars_txx
15 ** Created date: 2007-05-01
16 ** Version: 1.0
17 ** Descriptions: The original version
18 **
19 **------------------------------------------------------------------------------------------------------
20 ** Modified by:
21 ** Modified date:
22 ** Version:
23 ** Descriptions:
24 **
25 ********************************************************************************************************/
26 #include <rtx51tny.h>
27 #include <AT89X52.H>
28 #include <stdio.h>
29 #include "STC_ADC.h"
30
31 #define INIT 0 /* task number of task: init */
32 #define CHARG 1 /* task number of task: draw pix */
33 #define ADC 2 /* task number of task: pan scan */
34
35 #define CHARG_PIN P1_3
36 #define RUN_LED P1_7
37 #define CHARG_LED P1_6
38 #define ADC_VRF 2
39 #define ADC_BAT 1
40 #define ADC_CHKNUM 100
41 #define VREF_TR 0x3c
42 #define SYSCLK 5600000
43 #define OS_TICK_SEC 46
44 #define CHARG_ON 1
45 #define CHARG_OFF 0
46 #define LED_ON 0
47 #define LED_OFF 1
48
49 unsigned short VRef = 0;
50 unsigned short VBat = 0;
51 unsigned char VBatMax = 0;
52
53 sfr P1M0 =0x91;
54 sfr P1M1 =0x92;
55
C51 COMPILER V7.06 MAIN 05/14/2007 21:18:12 PAGE 2
56 //UART init, CLK=11059200, Baud = 9600bps
57 void initUart(void)
58 {
59 1 TMOD|=0x20;
60 1 SCON=0x50;
61 1 PCON|=0x80;
62 1 TH1=0xfa;
63 1 TL1=0xfa;
64 1 TR1=1;
65 1 }
66
67 char putchar (char c)
68 {
69 1 //ES=0;
70 1 SBUF=c;
71 1 while(!TI);TI=0;
72 1 //ES=1;
73 1 return c;
74 1 }
75
76 /******************************************************************************/
77 /* Task 0 'init': Initialize */
78 /******************************************************************************/
79 void init (void) _task_ INIT
80 {
81 1 /* program execution starts here */
82 1 ADC_Pin_Config(ADC_VRF);
83 1 ADC_Pin_Config(ADC_BAT);
84 1 Init_ADC_Interrupt(1);
85 1 CHARG_PIN = CHARG_ON;
86 1 CHARG_LED = LED_OFF;
87 1 P1M0 |= 0x01<<3;
88 1 P1M1 |= 0x01<<3;
89 1 initUart();
90 1 os_create_task(ADC);
91 1 os_create_task(CHARG);
92 1 os_delete_task (INIT); /* stop init task (no longer needed) */
93 1 }
94 /******************************************************************************/
95 /* Task 1 'charger control': */
96 /******************************************************************************/
97 void ChargControl (void) _task_ CHARG
98 {
99 1 unsigned char Status = 0;
100 1 unsigned short MinCout = 0;
101 1 unsigned short TotoleTime = 0;
102 1 unsigned long Index = 0;
103 1 while(1)
104 1 {
105 2 switch(Status)
106 2 {
107 3 case 0:
108 3 if(VRef > VREF_TR)
109 3 {
110 4 Status = 1;
111 4 VRef = 0;
112 4 VBat = 0;
113 4 VBatMax = 0;
114 4 TotoleTime = 0;
115 4 Index = 0;
116 4 printf("%u:Charge ON\n", Index);
117 4 }
C51 COMPILER V7.06 MAIN 05/14/2007 21:18:12 PAGE 3
118 3 break;
119 3 case 1:
120 3 if(VRef > VREF_TR)
121 3 {
122 4 CHARG_LED = LED_ON;
123 4 CHARG_PIN = CHARG_ON;
124 4 TotoleTime++;
125 4 if(VBatMax < VBat)
126 4 {
127 5 VBatMax = VBat;
128 5 MinCout = 0;
129 5 printf("%u:VBatMax UpData = 0x%x\n", Index,VBat);
130 5 }
131 4 else
132 4 {
133 5 MinCout++;
134 5 if(MinCout == 1800)
135 5 {
136 6 Status = 2;
137 6 printf("%u:Batter is Almost full\n",Index);
138 6 MinCout = 0;
139 6 os_wait2(K_SIG, 1);
140 6 printf("%u:Totole Time = %d S\n", Index,TotoleTime);
141 6
142 6 }
143 5 else
144 5 {
145 6 printf("%u:VBatMax Lock = 0x%x\n", Index,VBat);
146 6 }
147 5 }
148 4
149 4 }
150 3 else
151 3 {
152 4 CHARG_LED = LED_OFF;
153 4 printf("%u:Charging, Batter Removed\n",Index);
154 4 Status = 0;
155 4 }
156 3 break;
157 3 case 2:
158 3 if(VRef > VREF_TR)
159 3 {
160 4 if(MinCout == 0xff)
161 4 {
162 5 CHARG_LED = LED_OFF;
163 5 CHARG_PIN = CHARG_OFF;
164 5 Status = 3;
165 5 MinCout = 0;
166 5 printf("%u:Charg is Full\n",Index);
167 5 }
168 4 MinCout++;
169 4 }
170 3 else
171 3 {
172 4 CHARG_LED = LED_OFF;
173 4 printf("%u:Charg Almost Full, Batter Removed\n",Index);
174 4 MinCout=0;
175 4 Status = 0;
176 4 }
177 3 break;
178 3 case 3:
179 3 if(VBat < 0x10)
C51 COMPILER V7.06 MAIN 05/14/2007 21:18:12 PAGE 4
180 3 {
181 4 CHARG_PIN = CHARG_ON;
182 4 CHARG_LED = LED_OFF;
183 4 printf("%u:Charg Complete, Batter Removed\n",Index);
184 4 Status = 0;
185 4 }
186 3 else
187 3 {
188 4 printf("%u:Charg Complete\n",Index);
189 4 }
190 3 break;
191 3 case 4:
192 3 break;
193 3 }
194 2 Index++;
195 2 os_wait2(K_TMO, OS_TICK_SEC);
196 2 RUN_LED = ~RUN_LED;
197 2 }
198 1 }
199 /******************************************************************************/
200 /* Task 2 'ADC Check': */
201 /******************************************************************************/
202 void ADC_CHK (void) _task_ ADC
203 {
204 1 unsigned short V;
205 1 while(1)
206 1 {
207 2 unsigned char i;
208 2 V = 0;
209 2 for(i=0; i<ADC_CHKNUM; i++)
210 2 {
211 3 ADC_Start_Convt(ADC_VRF,STC_ADC_SPEED_210CLK);
212 3 os_wait2(K_SIG, 100);
213 3 V += GetADC_Reslut(ADC_VRF);
214 3 }
215 2 VRef = V/ADC_CHKNUM;
216 2 V = 0;
217 2 for(i=0; i<ADC_CHKNUM; i++)
218 2 {
219 3 ADC_Start_Convt(ADC_BAT,STC_ADC_SPEED_210CLK);
220 3 os_wait2(K_SIG, 100);
221 3 V += GetADC_Reslut(ADC_BAT);
222 3 }
223 2 VBat = V/ADC_CHKNUM;
224 2 //printf("VRef = 0x%x\n", VRef);
225 2 os_wait2(K_TMO, 10);
226 2 //printf("VBat = 0x%x\n", VBat);
227 2 os_wait2(K_TMO, 10);
228 2 }
229 1
230 1 }
231
232 void ADC_Int_Expection(void) interrupt 5
233 {
234 1 isr_ADC_GetVal();
235 1 isr_send_signal(ADC);
236 1 }
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 882 ----
CONSTANT SIZE = 252 ----
C51 COMPILER V7.06 MAIN 05/14/2007 21:18:12 PAGE 5
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = 18 ----
IDATA SIZE = ---- ----
BIT SIZE = ---- ----
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -