📄 w79e825.lst
字号:
C51 COMPILER V7.50 W79E825 11/05/2007 16:37:01 PAGE 1
C51 COMPILER V7.50, COMPILATION OF MODULE W79E825
OBJECT MODULE PLACED IN w79e825.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE w79e825.c BROWSE DEBUG OBJECTEXTEND
line level source
1 /****************************************************************************/
2 /* 深圳恒森微电子有限公司 (华邦单片机香港及中国区代理商) */
3 /* 香港恒森科技有限公司 (华邦单片机香港及中国区代理商) */
4 /* 陈文 email:chenwen@hengsen.cn (有 bug 请提交) */
5 /****************************************************************************/
6 /* 文件名: W79e825.c */
7 /* 版本 1.0 */
8 /* 创建日期: 2007-10-29 10:58 */
9 /* 概述: 本文件为 w79e825 kit demo 软件 */
10 /*--------------------------------------------------------------------------*/
11 /* 历史修改记录: */
12 /* 名字 日期 注释 */
13 /* 陈文 2007.10.28 ver 1.0 */
14 /****************************************************************************/
15 #include <w79e825.h>
16 #include <intrins.h>
17
18 #define uint8 unsigned char
19 #define uint16 unsigned int
20 #define uchar unsigned char
21 #define uint unsigned int
22
23 uint8 led[2];
24 //led code 共阳极 0 1 2 3 4 5 6 7 8 9 a b c d e f 灭
- 高位先出 bit顺序 h,g,f,e,d,c,b,a : Q1--a.....Q8--h
25 //uint8 code tab[17] = {0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,0x88,0x83,0xc6,0x0a,0x86,0x8e,0x
-ff};
26 uint8 code tab[17] = {0x41,0xf5,0x0d,0x15,0xb1,0x13,0x03,0xd5,0x01,0x11,0x81,0x83,0xc6,0x0a,0x86,0x8e,0xff
-};
27
28 sbit Csg1 = P1^6;
29 sbit Csg0 = P1^7;
30
31
32 #define nop() _nop_();_nop_();_nop_();_nop_();
33
34 void init_cpu(void);
35 void Display(void);
36 uchar key_scan(void);
37 void ADC_Select(ADC_C);
38 void ADC_EN(void);
39 void ADC_DIS(void);
40 uchar basetime;
41 uchar sec;
42 uchar min;
43 uchar adc_save;
44 uchar key_time;
45 uchar key_valume;
46
47 //每10毫秒中断一次
48 void Timer0_int(void) interrupt 1 using 1
49 {
50 1 TL0 = 0x0f;
51 1 TH0 = 0xdb;
52 1 TF0 = 0;
C51 COMPILER V7.50 W79E825 11/05/2007 16:37:01 PAGE 2
53 1
54 1 key_time++;
55 1 if(99 != basetime)
56 1 {
57 2 basetime++;
58 2 return;
59 2 }
60 1 basetime = 0;
61 1 if(59 != sec) //1分钟
62 1 {
63 2 sec++;
64 2 return;
65 2 }
66 1 else
67 1 {
68 2 sec = 0;
69 2 min++;
70 2 }
71 1 }
72
73 void main(void)
74 {
75 1 uchar sec_save;
76 1 uchar base_save;
77 1 key_time = 0;
78 1 init_cpu();
79 1 P07 = 0;
80 1 led[0] = 0;
81 1 led[1] = 0x10;
82 1 Display();
83 1 for(;;)
84 1 {
85 2 if(key_time>=2)
86 2 {
87 3 key_valume = key_scan(); //20ms
88 3 }
89 2 if(base_save != basetime)
90 2 {
91 3 base_save = basetime;
92 3 if(key_valume != 0xff)
93 3 {
94 4 led[0] = key_valume;
95 4 led[1] = 0x10;
96 4 }
97 3 Display();
98 3 }
99 2 if(sec_save != sec)
100 2 {
101 3 sec_save = sec;
102 3 P07 = (!P07);
103 3 }
104 2 }
105 1 }
106
107 void init_cpu(void)
108 {
109 1 P0M1 = 0x00;
110 1 P0M2 = 0x1f;
111 1
112 1 P0 = 0xff;
113 1 P1M1 = 0x00;
114 1 P1M2 = 0xc0;
C51 COMPILER V7.50 W79E825 11/05/2007 16:37:01 PAGE 3
115 1 P1 = 0xff;
116 1 // P2M1 = 0x03;
117 1 // P2M2 = 0;
118 1 // P2 = 0x03; //IO初始化完成
119 1
120 1 TMOD = 0x21;
121 1 SCON = 0x50; /* SCON: mode 1, 8-bit UART, enable rcvr */
122 1 TH1 = 0xfd; /* TH1: reload value for 9600 baud @ 11.0592MHz */
123 1 TL1 = 0xfd;
124 1 TR1 = 1; //T1 timer run
125 1 // ES = 1; //uart interrupt enable
126 1 EA = 1; //all interrupt enable
127 1 P1 = 0xff;
128 1
129 1 TL0 = 0x0f;
130 1 TH0 = 0xdb;
131 1 ET0 = 1;
132 1 TR0 = 1;
133 1
134 1 basetime = 0; //init timer
135 1 sec = 0;
136 1 min = 0;
137 1 }
138
139
140
141 void Display(void)
142 {
143 1 bit B_disp_flag;
144 1 uint8 temp;
145 1 Csg1 = 1;
146 1 Csg0 = 1;
147 1 if(B_disp_flag == 1)
148 1 {
149 2 B_disp_flag = 0;
150 2 temp = led[0];
151 2 temp = tab[temp];
152 2 P0 &= 0xe0;
153 2 P0 |= (temp&0x1f);
154 2 P1 &= 0xe3;
155 2 P1 |= ((temp >> 3)&0x1c);
156 2 Csg1 = 1;
157 2 Csg0 = 0;
158 2 }
159 1 else
160 1 {
161 2 B_disp_flag = 1;
162 2 temp = led[1];
163 2 temp = tab[temp];//&0xfe; //小数点
164 2 P0 &= 0xe0;
165 2 P0 |= (temp&0x1f);
166 2 P1 &= 0xe3;
167 2 P1 |= ((temp >> 3)&0x1c);
168 2 Csg0 = 1;
169 2 Csg1 = 0;
170 2 }
171 1 }
172
173
174 void ADC_Select(ADC_C)
175 {
176 1 switch(ADC_C)
C51 COMPILER V7.50 W79E825 11/05/2007 16:37:01 PAGE 4
177 1 {
178 2 case 0:P0M1|=0x08;P0M2&=0xF7;ADCCON=0;P0|=0x08;break;
179 2 case 1:P0M1|=0x10;P0M2&=0xef;ADCCON=1;P0|=0x10;break;
180 2 case 2:P0M1|=0x20;P0M2&=0xdf;ADCCON=2;P0|=0x20;break;
181 2 case 3:P0M1|=0x40;P0M2&=0xbf;ADCCON=3;P0|=0x40;break;
182 2 default: break;
183 2 }
184 1 }
185
186 void ADC_EN(void)
187 {
188 1 AUXR1|=0x04;
189 1 }
190
191 void ADC_DIS(void)
192 {
193 1 AUXR1&=0xFB;
194 1 }
195
196
197 #define k1_adc 678
198 #define k2_adc 512
199 #define k3_adc 308
200 #define k4_adc 167
201 uchar key_scan(void)
202 {
203 1 uchar adc_h,adc_l;
204 1 uint adc_data;
205 1 ADC_Select(3); //select channel
206 1 ADC_EN(); //enable adc
207 1 ADCCON = ADCCON | 0x08; //start adc
208 1 while(!(ADCCON & 0x10));//wait adc finish
209 1 adc_h = ADCH;
210 1 ADCCON = ADCCON & 0xF7; //DISABLE adc
211 1 adc_l = ADCCON;
212 1 ADC_DIS();
213 1 adc_l = adc_l>>6;
214 1 adc_data = adc_h;
215 1 adc_data = adc_data<<2;
216 1 adc_data = adc_data | adc_l;
217 1
218 1 if((adc_data>k1_adc-32)&&(adc_data<k1_adc+32)) //+/-32是电阻误差范围
219 1 {
220 2 return 1;
221 2 }
222 1 if((adc_data>k2_adc-32)&&(adc_data<k2_adc+32))
223 1 {
224 2 return 2;
225 2 }
226 1 if((adc_data>k3_adc-32)&&(adc_data<k3_adc+32))
227 1 {
228 2 return 3;
229 2 }
230 1 if((adc_data>k4_adc-32)&&(adc_data<k4_adc+32))
231 1 {
232 2 return 4;
233 2 }
234 1 return 0xff;
235 1 }
MODULE INFORMATION: STATIC OVERLAYABLE
C51 COMPILER V7.50 W79E825 11/05/2007 16:37:01 PAGE 5
CODE SIZE = 445 ----
CONSTANT SIZE = 17 ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = 8 2
IDATA SIZE = ---- ----
BIT SIZE = ---- 1
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -