📄 acus.lst
字号:
C51 COMPILER V7.01 ACUS 11/24/2004 13:33:22 PAGE 1
C51 COMPILER V7.01, COMPILATION OF MODULE ACUS
OBJECT MODULE PLACED IN acus.OBJ
COMPILER INVOKED BY: D:\Keil\C51\BIN\C51.EXE acus.c LARGE OPTIMIZE(7,SPEED) BROWSE DEBUG OBJECTEXTEND
stmt level source
1 #include "reg935.h"
2 #include <rtx51tny.h>
3 #include <string.h>
4 #include<intrins.h>
5 /**********************************************************/
6 #define INIT 0
7 #define CLOCK 1
8 #define LIGHTS 2
9 #define KEYREAD 3
10 #define TEMPCON 4
11 #define TEMPSET 5
12 #define TIMESET 6
13 #define TIMECON 7
14 #define PWMCON 8
15 #define BLINKING 9
16 /**********************************************************/
17 #define uchar unsigned char
18 #define uint unsigned int
19 /***********************************************************/
20 #define HIGH(x) ((x>>8)&0xff)
21 #define LOW(x) (x&0xff)
22 #define OPEN 1
23 #define CLOSE 0
24 /***********************************************************/
25 #define CHANNEL1 0x01
26 #define CHANNEL2 0x02
27 #define CHANNEL3 0x03
28
29 /*******************共字符******************************/
30
31 #define LED1 0x06; // 1
32 #define LED2 0x5b; // 2
33 #define LED3 0x4f; // 3
34 #define LED4 0x66; // 4
35 #define LED5 0x6d; // 5
36 #define LED6 0x7d; // 6
37 #define LED7 0x07; //7
38 #define LED8 0x7f; //8
39 #define LED9 0x6f; //9
40 #define LEDA 0x77; //A
41 #define LED0 0x3f; //0
42 #define LEDb 0x7c; // b
43 #define LEDC 0x39; //C
44 #define LEDd 0x5e; //d
45 #define LEDE 0x79; //E
46 #define LEDF 0x71; //F
47 #define LEDP 0x3e; //P
48 #define LEDU 0x6e; //U
49 #define LEDy 0x76; //y
50 #define LEDH 0x38; //H
51 #define LEDL 0x00; //L
52
53 /*******************共阳字符******************************/
54 /*#define LED1 0xf9; // 1
55 #define LED2 0xa4; // 2
C51 COMPILER V7.01 ACUS 11/24/2004 13:33:22 PAGE 2
56 #define LED3 0xb0; // 3
57 #define LED4 0x99; // 4
58 #define LED5 0x92; // 5
59 #define LED6 0x82; // 6
60 #define LED7 0xf8; //7
61 #define LED8 0x80; //8
62 #define LED9 0x90; //9
63 #define LEDA 0x88; //A
64 #define LED0 0xc0; //0
65 #define LEDb 0x83; // b
66 #define LEDC 0xc6; //C
67 #define LEDd 0xa1; //d
68 #define LEDE 0x86; //E
69 #define LEDF 0x8e; //F
70 #define LEDP 0x8c; //P
71 #define LEDU 0xc1; //U
72 #define LEDy 0x91; //y
73 #define LEDH 0x89; //H
74 #define LEDL 0xc7; //L*/
75 static uchar xdata dispbuff[4] ={0x3f,0x3f,0x3f,0x3f}; //显示缓冲
76 static uchar idata NewsStr[4] ; //分配按键队列,第1字节为有效按键数目,
77 //static uchar idata KeyTime,KeyTask; //任务时间参数,任务内模块号
78
79 /***********************************************************/
80 #define PWM2HZ 0xffff
81 #define PWM4HZ 0x7fff
82 #define PWM8HZ 0x3fff
83 #define PWM16HZ 0x1fff
84 #define PWM32HZ 0x0fff
85 #define PWM64HZ 0x07ff
86 #define PWM128HZ 0x03ff
87 #define PWM256HZ 0x01ff
88 #define PWM512HZ 0x00ff
89 #define PWM1024HZ 0x007f
90 #define PWM2048HZ 0x003f
91 #define PWM4096HZ 0x001f
92 #define PWM8192HZ 0x000f
93 /************************************************************/
94 #define TEMPADDR 15 /*保存设定的温度EEPROM地址*/
95 #define TIMEADDR 7 /*保存设定的时间EEPROM地址*/
96 uchar idata TimeCounter=0; /* 时间按键计数器 */
97 uchar idata TempLimit=0; /*温度设定值*/
98 uchar idata TimeLimit=0; /*时间设定值*/
99 uchar idata PWMChang=0; /*PWM脉冲控制*/
100
101
102 bit TaskStart=0; /*任务开始标志*/
103 bit KeyOk=0; /*按键控制*/
104 bit TIMECONRUN =0; /*定时任务运行状态*/
105 bit ALAMECON =0;
106 /****************************************************************/
107 struct time { //时间记录结构
108 uchar hour; //小时
109 uchar min; //分
110 uchar sec; //秒
111 uchar msec; //秒调整
112 };
113 /************************************************************/
114 struct time xdata ctime = {12,0,0,0} ; /*系统时间*/
115 struct time xdata start ={ 0,0,0,0}; /*起始时间*/
116 struct time xdata end ={0,0,0,0} ; /*结束时间*/
117 /************************************************************/
C51 COMPILER V7.01 ACUS 11/24/2004 13:33:22 PAGE 3
118 sbit dq = P0^2;
119 bit flag;
120 #define NOP _nop_();_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();
121 uint idata Temperature;
122 uchar xdata temp_buff[9]; //存储读取的字节,read scratchpad为9字节,read rom ID为8字节
123 uchar xdata id_buff[8];
124 uchar *p;
125 uchar crc_data;
126 uchar code CrcTable [256]={
127 0, 94, 188, 226, 97, 63, 221, 131, 194, 156, 126, 32, 163, 253, 31, 65,
128 157, 195, 33, 127, 252, 162, 64, 30, 95, 1, 227, 189, 62, 96, 130, 220,
129 35, 125, 159, 193, 66, 28, 254, 160, 225, 191, 93, 3, 128, 222, 60, 98,
130 190, 224, 2, 92, 223, 129, 99, 61, 124, 34, 192, 158, 29, 67, 161, 255,
131 70, 24, 250, 164, 39, 121, 155, 197, 132, 218, 56, 102, 229, 187, 89, 7,
132 219, 133, 103, 57, 186, 228, 6, 88, 25, 71, 165, 251, 120, 38, 196, 154,
133 101, 59, 217, 135, 4, 90, 184, 230, 167, 249, 27, 69, 198, 152, 122, 36,
134 248, 166, 68, 26, 153, 199, 37, 123, 58, 100, 134, 216, 91, 5, 231, 185,
135 140, 210, 48, 110, 237, 179, 81, 15, 78, 16, 242, 172, 47, 113, 147, 205,
136 17, 79, 173, 243, 112, 46, 204, 146, 211, 141, 111, 49, 178, 236, 14, 80,
137 175, 241, 19, 77, 206, 144, 114, 44, 109, 51, 209, 143, 12, 82, 176, 238,
138 50, 108, 142, 208, 83, 13, 239, 177, 240, 174, 76, 18, 145, 207, 45, 115,
139 202, 148, 118, 40, 171, 245, 23, 73, 8, 86, 180, 234, 105, 55, 213, 139,
140 87, 9, 235, 181, 54, 104, 138, 212, 149, 203, 41, 119, 244, 170, 72, 22,
141 233, 183, 85, 11, 136, 214, 52, 106, 43, 117, 151, 201, 74, 20, 246, 168,
142 116, 42, 200, 150, 21, 75, 169, 247, 182, 232, 10, 84, 215, 137, 107, 53};
143
144 void DelayNS(uchar no);
145 void watchdog(void) ;
146 void Disp(uchar *i) ;
147 void CPU_init(void) ;
148 /*********************************************************/
149 void CCU_init(void);
150 void PWM_start(uint freq,uchar mod);
151 /*********************************************************/
152 void AD_init(void) ;
153 uchar AD_start(uchar channel);
154 /**********************************************************/
155 sbit tempkey=P1^3 ;
156 sbit timekey=P1^2 ;
157 sbit pwmkey =P1^4;
158 sbit timeled=P0^6;
159 sbit templed=P0^7;
160 sbit ALAME=P1^7;
161 /************************************************************
162 *Function:10us延时处理
163 *parameter:
164 *Return:
165 *Modify:
166 *************************************************************/
167 void Delay10us (uchar us)
168 {
169 1 while(us--)
170 1 {
171 2 NOP;NOP;NOP;
172 2 }
173 1 }
174 /*********************************************************
175 *名称:EEPROMwrite(unsigned int adr, unsigned char dat)
176 *功能:EEPROM写程序
177 *入口参数:adr dat
178 *出口参数:数据地址,数据
179 *********************************************************/
C51 COMPILER V7.01 ACUS 11/24/2004 13:33:22 PAGE 4
180 void EEPROMwrite(unsigned int adr, uchar dat)
181 {
182 1 EA=0; // disable Interrupts during write
183 1 DEECON=(unsigned char)((adr>>8)&0x01); // mode: write byte, set address
184 1 DEEDAT=dat; // set write data
185 1 DEEADR=(unsigned char) adr; // start write
186 1 EA=1;
187 1 while((DEECON&0x80)==0); // wait until write is complete
188 1 }
189 /*********************************************************
190 *名称:EEPROMread(unsigned int adr)
191 *功能:EEPROM读程序
192 *入口参数:无
193 *出口参数:数据地址
194 *********************************************************/
195 unsigned char EEPROMread(unsigned int adr)
196 {
197 1 DEECON=(unsigned char)((adr>>8)&0x01); // mode: read byte, set adress
198 1 DEEADR=(unsigned char) adr; // start read
199 1 while((DEECON&0x80)==0); // wait until read is complete
200 1 return DEEDAT; // return data
201 1 }
202
203 /************************************************************
204 *Function:18B20初始化
205 *parameter:
206 *Return:
207 *Modify:
208 *************************************************************/
209 bit Init18b20 (void)
210 {
211 1 dq=0;
212 1
213 1 os_wait(K_TMO,3,0);
214 1 //Delay10us(50); //delay 500 uS
215 1 dq=1;
216 1 Delay10us(9); //delay 90 uS
217 1 if(dq==1)
218 1 return 0; //detect 1820 success!
219 1 else
220 1 {os_wait(K_TMO,2,0);
221 2 //Delay10us(40);
222 2 dq = 1;
223 2 }
224 1 return 1; //detect 1820 failed!
225 1 }
226 /************************************************************
227 *Function:向18B20写入一个字节
228 *parameter:
229 *Return:
230 *Modify:
231 *************************************************************/
232 void WriteByte (uchar wr) //单字节写入
233 {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -