📄 host.lst
字号:
C51 COMPILER V7.01 HOST 03/24/2005 22:10:08 PAGE 1
C51 COMPILER V7.01, COMPILATION OF MODULE HOST
OBJECT MODULE PLACED IN host.OBJ
COMPILER INVOKED BY: C:\Keil\C51\Bin\c51.exe host.c DB SB OE ROM(COMPACT) SMALL OT(6,SPEED) WL(2) RB(0)
stmt level source
1 /******************************************************************
2 程序名:host
3 功能:测量电流,并发数据发送给LED595程序,接受用户键盘输入跟设置。
4 创建时间:2004-3-30
5 作者:华明
6 ******************************************************************/
7
8 #include <reg52.h>
9 #include <intrins.h>
10 #include "host.h"
11 #include "SEGCODE.h"
12
13 #define SIZE_OF_KEYBD_MENU 30 //菜单长度
14 //#define nop2() _nop_();_nop_();
15
16 KbdTabStruct code KeyTab[SIZE_OF_KEYBD_MENU] =
17 {
18 {0, 0, 0, 0, 1, (*OptionProg)},
19 {1, 5, 2, 0, 6, (*OptionAYS)},
20 {2, 1, 3, 0, 7, (*OptionIn_Out)},
21 {3, 2, 4, 0, 9, (*OptionALR)},
22 {4, 3, 5, 0, 11, (*OptionSecr)},
23 {5, 4, 1, 0, 12, (*OptionAdBd)},
24 {6, 6, 6, 1, 1, (*AutoZero)},
25 {7, 8, 8, 2, 14, (*InputX)},
26 {8, 7, 7, 2, 15, (*OutputX)},
27 {9, 10, 10, 3, 3, (*ALROFF)},
28 {10, 9, 9, 3, 16, (*ALRON)},
29 {11,11, 11, 4, 4, (*Passward)},
30 {12,13, 13, 5, 18, (*AddrX)},
31 {13,12, 12, 5, 19, (*BaudX)},
32 {14,14, 14, 7, 20, (*Inp)},
33 {15,15, 15, 8, 21, (*Oup)},
34 {16,17, 17, 10, 22, (*ALRLX)},
35 {17,16, 16, 10, 23, (*ALRHX)},
36 {18,18, 18, 12, 24, (*Address)},
37 {19,19, 19, 13, 25, (*Baud)},
38 {20,20, 20, 14, 7, (*SetInput)},
39 {21,21, 21, 15, 26, (*SetOutput)},
40 {22,22, 22, 16, 27, (*AL_L)},
41 {23,23, 23, 17, 28, (*AL_H)},
42 {24,24, 24, 18, 19, (*SetAddress)},
43 {25,25, 25, 19, 18, (*SetBaud)},
44 {26,26, 26, 21, 29, (*Point)},
45 {27,27, 27, 22, 23, (*SetAL_L)},
46 {28,28, 28, 23, 22, (*SetAL_H)},
47 {29,29, 29, 26, 8, (*SetPoint)}
48 };
49
50 /*25045操作子程序集*/
51 /*;*******************************************************************************************
52 *
53 ;* Name: WREN_CMD
54 ;* Description: Set write enable latch
55 ;* Function: This routine sends the command to enable writes to the EEPROM memory array or
C51 COMPILER V7.01 HOST 03/24/2005 22:10:08 PAGE 2
56 ;* status register
57 ;* Calls: outbyt
58 ;* Input: None
59 ;* Outputs: None
60 ;* Register Usage: A
61 ;*******************************************************************************************
62 */
63 /*写使能子程序*/
64 void wren_cmd(void)
65 {
66 1 uchar aa;
67 1 SCK=0;/* Bring SCK low */
68 1 CS=0;/* Bring /CS low */
69 1 aa=WREN_INST;
70 1 outbyt(aa);/* Send WREN instruction */
71 1 SCK=0;/* Bring SCK low */
72 1 CS=1;/* Bring /CS high */
73 1 }
74
75
76 /*;*******************************************************************************************
77 *
78 ;* Name: WRDI_CMD
79 ;* Description: Reset write enable latch
80 ;* Function: This routine sends the command to disable writes to the EEPROM memory array or
81 ;* status register
82 ;* Calls: outbyt
83 ;* Input: None
84 ;* Outputs: None
85 ;* Register Usage: A
86 ;*******************************************************************************************
87 */
88 /*写使能复位子程序*/
89
90 //void wrdi_cmd(void)
91 //{
92 // uchar aa;
93 // SCK=0;/* Bring SCK low */
94 // CS=0;/* Bring /CS low */
95 // aa=WRDI_INST;
96 // outbyt(aa);/* Send WRDI instruction */
97 // SCK=0;/* Bring SCK low */
98 // CS=1;/* Bring /CS high */
99 //}
100
101 /*;*******************************************************************************************
102 *
103 ;* Name: WRSR_CMD
104 ;* Description: Write Status Register
105 ;* Function: This routine sends the command to write the WD0, WD1, BP0 and BP0 EEPROM
106 ;* bits in the status register
107 ;* Calls: outbyt, wip_poll
108 ;* Input: None
109 ;* Outputs: None
110 ;* Register Usage: A
111 ;*******************************************************************************************
112 */
113 /*写状态寄存器子程序*/
114 void wrsr_cmd(void)
115 {
116 1 uchar aa;
117 1 SCK=0;/* Bring SCK low */
C51 COMPILER V7.01 HOST 03/24/2005 22:10:08 PAGE 3
118 1 CS=0;/* Bring /CS low */
119 1 aa=WRSR_INST;
120 1 outbyt(aa) ;/* Send WRSR instruction */
121 1 aa=STATUS_REG;
122 1 outbyt(aa);/* Send status register */
123 1 SCK=0;/* Bring SCK low */
124 1 CS=1;/* Bring /CS high */
125 1 wip_poll();/* Poll for completion of write cycle */
126 1 }
127
128 /*;*******************************************************************************************
129 *
130 ;* Name: RDSR_CMD
131 ;* Description: Read Status Register
132 ;* Function: This routine sends the command to read the status register
133 ;* Calls: outbyt, inputbyt
134 ;* Input: None
135 ;* Outputs: A = status registerXicor Application Note AN21
136 ;* Register Usage: A
137 ;*******************************************************************************************
138 */
139 /*读状态寄存器,读出的数据放入到aa中*/
140 uchar rdsr_cmd (void)
141 {
142 1 uchar aa;
143 1 SCK=0;
144 1 CS=0;
145 1 aa=RDSR_INST;
146 1 outbyt(aa);
147 1 aa=inputbyt();
148 1 SCK=0;
149 1 CS=1;
150 1 return aa;
151 1 }
152
153 /*;*******************************************************************************************
154 *
155 ;* Name: BYTE_WRITE
156 ;* Description: Single Byte Write
157 ;* Function: This routine sends the command to write a single byte to the EEPROM memory
158 array
159 ;* Calls: outbyt, wip_poll
160 ;* Input: None
161 ;* Outputs: None
162 ;* Register Usage: A, B
163 ;*******************************************************************************************
164 */
165 /*字节写入,aa为写入的数据,dd为写入的地址,对于25045而言为000-1FF*/
166 void byte_write(aa,dd)
167 uchar aa;
168 uint dd;
169 {
170 1 SCK=0;
171 1 CS=0;
172 1 outbyt((uchar)(dd>255?(0x08|WRITE_INST):WRITE_INST));
173 1 //outbyt((((uchar)(dd-0XFF))<<3)|WRITE_INST);/* Send WRITE instruction including MSB of address */
174 1 /*将高位地址左移3位与写入先导字相或,得到正确的先导字写入25045*/
175 1 outbyt((uchar)(dd&0x00ff));
176 1 /*输出低位地址到25045*/
177 1 outbyt(aa);
178 1 /*写入数据到25045的对应单元*/
179 1 SCK=0;
C51 COMPILER V7.01 HOST 03/24/2005 22:10:08 PAGE 4
180 1 CS=1;
181 1 wip_poll();
182 1 /*检测是否写完*/
183 1 }
184
185 /*;*******************************************************************************************
186 *
187 ;* Name: BYTE_READ
188 ;* Description: Single Byte Read
189 ;* Function: This routine sends the command to read a single byte from the EEPROM memory
190 array
191 ;* Calls: outbyt, inputbyt
192 ;* Input: None
193 ;* Outputs: A = read byte
194 ;* Register Usage: A, BXicor Application Note AN21
195 ;*******************************************************************************************
196 */
197 /*字节读出,其中dd为读出的地址,返回的值为读出的数据*/
198 uchar byte_read(dd)
199 uint dd;
200 {
201 1 uchar cc;
202 1 SCK=0;
203 1 CS=0;
204 1 outbyt((uchar)(dd>255?(0x08|READ_INST):READ_INST));
205 1 //outbyt((((uchar)(dd-0XFF))<<3)|READ_INST);/* Send READ_INST instruction including MSB of address */
206 1 /*将高位地址左移3位与读出先导字相或,得到正确的先导字写入25045*/
207 1 outbyt((uchar)(dd&0x00ff));
208 1 /*输出低位地址到25045*/
209 1 cc=inputbyt();/*得到读出的数据*/
210 1 SCK=0;
211 1 CS=1;
212 1 return cc;
213 1 }
214
215 /*;*******************************************************************************************
216 *
217 ;* Name: PAGE_WRITE
218 ;* Description: Page Write
219 ;* Function: This routine sends the command to write three consecutive bytes to the EEPROM
220 ;* memory array using page mode
221 ;* Calls: outbyt, wip_poll
222 ;* Input: None
223 ;* Outputs: None
224 ;* Register Usage: A, B
225 ;*******************************************************************************************
226 */
227 /*页面写入,其中aa1,aa2,aa3,aa4为需要写入的4个数据(最大也就只能一次写入4个字,dd为写入的首地址*/
228 void page_write(aa1,aa2,aa3,aa4,dd)
229 uchar aa1,aa2,aa3,aa4;
230 uint dd;
231 {
232 1 SCK=0;
233 1 CS=0;
234 1 outbyt((uchar)(dd>255?(0x08|WRITE_INST):WRITE_INST));
235 1 //outbyt((((uchar)(dd-0XFF))<<3)|WRITE_INST);/* Send WRITE instruction including MSB of address */
236 1 /*将高位地址左移3位与写入先导字相或,得到正确的先导字写入25045*/
237 1 outbyt((uchar)(dd&0x00ff));
238 1 /*写入低位地址到25045*/
239 1 outbyt(aa1);
240 1 /*写入数据1到25045的对应单元*/
241 1 outbyt(aa2);
C51 COMPILER V7.01 HOST 03/24/2005 22:10:08 PAGE 5
242 1 /*写入数据2到25045的对应单元*/
243 1 outbyt(aa3);
244 1 /*写入数据3到25045的对应单元*/
245 1 outbyt(aa4);
246 1 /*写入数据4到25045的对应单元*/
247 1 SCK=0;
248 1 CS=1;
249 1 wip_poll();
250 1 }
251
252 /*;*******************************************************************************************
253 *
254 ;* Name: RST_WDOG
255 ;* Description: Reset Watchdog Timer
256 ;* Function: This routine resets the watchdog timer without sending a command
257 ;* Calls: None
258 ;* Input: None
259 ;* Outputs: None
260 ;* Register Usage: None
261 ;*******************************************************************************************
262 */
263 /*复位DOG*/
264 void rst_wdog (void)
265 {
266 1 CS=0;
267 1 CS=1;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -