📄 hldkzqv12.lst
字号:
C51 COMPILER V7.06 HLDKZQV12 12/21/2004 08:51:33 PAGE 1
C51 COMPILER V7.06, COMPILATION OF MODULE HLDKZQV12
OBJECT MODULE PLACED IN hldkzqv12.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE hldkzqv12.c BROWSE DEBUG OBJECTEXTEND
stmt level source
1 /*############################################################################
2 鼎立照明 16级灰度护栏灯控制器程序
3 创建时间:2004-07-01
4 硬件资源:
5 RAM ADDRESS :0000H---7FFFH
6 FLASH ADDRESS:8000H---8FFFH
7 CPLD ADDRESS:9000H---FFFFH
8 RAM SIZE :32K FLASH SIZE:8MBYTE = 4K*512PAGE*4PCS
9 2004-07-09 :测试程序
10 ******************************************************************/
11 #include <reg52.h>
12 #include <intrins.h>
13 //#include <ctype.h>//字符函数
14 #include <string.h>//字符串函数
15 #include <stdio.h>//一般I/O函数
16 #include <stdlib.h>//标准函数
17 //#include <math.h>//数学函数
18 #include <absacc.h>//绝对地址
19 #include <intrins.h>//内部函数
20 #include <setjmp.h>
21 #define uchar unsigned char
22 #define uint unsigned int
23 #define byte unsigned char
24 #define word unsigned
25 #define bool bit
26 #define TRUE 1
27 #define FALSE 0
28 #define V_TH0 0xff /* 时间常数高8位 (65536-500)/256 */
29 #define V_TL0 0xff /* 时间常数低8位 (65536-500)%256 11.0592*/
30 //#define V_TH0 (65536-1536)/256
31 //#define V_TL0 (65536-1536)%256
32 #define V_TMOD 0x01 /* 定时器T0方式控制字 */
33 #define WriteDeviceAddress 0xa0
34 #define ReadDviceAddress 0xa1
35 /* 定义定时器T0的时间常数值和方式控制字 */
36
37 #define REGL XBYTE[0x9003] //控制寄存器护栏管的长度
38 #define FPGH XBYTE[0x9001] //闪存页高位
39 #define FPGL XBYTE[0x9002] //闪存页低位
40 //**********************************************
41 sbit senden=P3^2;
42 sbit SDA=P3^3;
43 sbit SCL=P3^5;
44 sbit wdgclr=P1^7;
45 //*************************************************
46 uint zhepe; //帧频
47 uint ms; //毫秒定时
48 uchar ADD; //地址
49 uchar idata send_buf[73]; //接收缓冲区
50 uchar pointer,subchk; //接收指针 和校验
51 uchar paklen; //包长
52 uint page_sta,page_end; //显示的开始帧和结束帧
53 uint dis_page; //当前显示的帧号
54 uint page; //扇区号
55 uchar bdata flag;
C51 COMPILER V7.06 HLDKZQV12 12/21/2004 08:51:33 PAGE 2
56 sbit frameok=flag^0; //rece ok
57 sbit color=flag^1; //0 sing red color 1 red green color
58 sbit rec_sta=flag^2; //1 进入接状态,不显示
59 sbit rec_end=flag^3;
60 sbit timout=flag^4;
61 //jmp_buf env;
62 //int retval;
63 /***************************************************************************/
64 void I2cDelay(unsigned int number) {
65 1 unsigned char temp;
66 1 for(;number!=0;number--,wdgclr=!wdgclr) {
67 2 for(temp=112;temp!=0;temp--) {
68 3 }
69 2 }
70 1 }
71
72 /***************************************************************************/
73 void Start() {
74 1 SDA=1;
75 1 SCL=1;
76 1 SDA=0;
77 1 SCL=0;
78 1 }
79
80 /***************************************************************************/
81 void Stop() {
82 1 SCL=0;
83 1 SDA=0;
84 1 SCL=1;
85 1 SDA=1;
86 1 }
87
88 /***************************************************************************/
89 void Ack() {
90 1 SDA=0;
91 1 SCL=1;
92 1 SCL=0;
93 1 SDA=1;
94 1 }
95
96 /***************************************************************************/
97 void NoAck() {
98 1 SDA=1;
99 1 SCL=1;
100 1 SCL=0;
101 1 }
102
103 /***************************************************************************/
104 bit TestAck() {
105 1 bit ErrorBit;
106 1 SDA=1;
107 1 SCL=1;
108 1 ErrorBit=SDA;
109 1 SCL=0;
110 1 return(ErrorBit);
111 1 }
112
113 /***************************************************************************/
114 Write8Bit(unsigned char input)
115 {
116 1 unsigned char temp;
117 1 for(temp=8;temp!=0;temp--) {
C51 COMPILER V7.06 HLDKZQV12 12/21/2004 08:51:33 PAGE 3
118 2 SDA=(bit)(input&0x80);
119 2 SCL=1;
120 2 SCL=0;
121 2 input=input<<1;
122 2 }
123 1 }
124
125 /***************************************************************************/
126 void Write24c02(unsigned char *Wdata,unsigned char RomAddress,unsigned char number) {
127 1 Start();
128 1 Write8Bit(WriteDeviceAddress);
129 1 TestAck();
130 1 Write8Bit(RomAddress);
131 1 TestAck();
132 1 for(;number!=0;number--) {
133 2 Write8Bit(*Wdata);
134 2 TestAck();
135 2 Wdata++;
136 2 }
137 1 Stop();
138 1 I2cDelay(10);
139 1 }
140
141 /***************************************************************************/
142 unsigned char Read8Bit() {
143 1 unsigned char temp,rbyte=0;
144 1 for(temp=8;temp!=0;temp--) {
145 2 SCL=1;
146 2 rbyte=rbyte<<1;
147 2 rbyte=rbyte|((unsigned char)(SDA));
148 2 SCL=0;
149 2 }
150 1 return(rbyte);
151 1 }
152
153 /***************************************************************************/
154 void Read24c02(unsigned char *RamAddress,unsigned char RomAddress,unsigned char bytes) {
155 1 // unsigned char temp,rbyte;
156 1 Start();
157 1 Write8Bit(WriteDeviceAddress);
158 1 TestAck();
159 1 Write8Bit(RomAddress);
160 1 TestAck();
161 1 Start();
162 1 Write8Bit(ReadDviceAddress);
163 1 TestAck();
164 1 while(bytes!=1) {
165 2 *RamAddress=Read8Bit();
166 2 Ack();
167 2 RamAddress++;
168 2 bytes--;
169 2 }
170 1 *RamAddress=Read8Bit();
171 1 NoAck();
172 1 Stop();
173 1 }
174
175 /***************************************************************************/
176 //*******************************************
177 //从FLASH加载数据到RAM, flash -> ram 000
178 //入口参数:帧号 取值范围:0--8095
179 //******************************************
C51 COMPILER V7.06 HLDKZQV12 12/21/2004 08:51:33 PAGE 4
180 //#pragma NOMODDP2
181 void load_data(uint page)
182 {
183 1 uchar xdata *s;
184 1 uchar xdata *sp;
185 1 uchar xdata *rp;
186 1 sp=((page<<10)&0x0fff)|0x8000;
187 1 FPGH=(page>>2)/256;FPGL=(page>>2)%256;
188 1 s=0x000;
189 1 //for(i=0;i<1024;i++)*s++=*sp++;
190 1 rp=memcpy(s,sp,1024);
191 1 }
192 /*************************************************
193
194 ************************************************/
195 void delayms( uchar ticks )
196 {
197 1 uint Count;
198 1 uchar Tick;
199 1 for (Tick=ticks;Tick>0;Tick--)
200 1 {
201 2 for (Count=0;Count<=500;Count++);
202 2 wdgclr=!wdgclr;
203 2 }
204 1
205 1 }
206 /************************************************************************/
207 /* PROCEDURE: Erase_One_Sector */
208 /* */
209 /* This procedure can be used to erase a total of 4096 bytes. */
210 /* */
211 /* Input: */
212 /* Dst DESTINATION address where the erase operation starts */
213 /* */
214 /* Output: */
215 /* NONE */
216 /************************************************************************/
217
218 void Erase_One_Sector (uint Sec)
219 {
220 1 // uchar xdata *Temp;
221 1 //Temp=0x0000;
222 1 FPGH=(page/256)&0x06;FPGL=5;
223 1 XBYTE[0x8555]=0Xaa;
224 1 FPGL=2;
225 1 XBYTE[0x8aaa]=0x55;
226 1 FPGL=5;
227 1 XBYTE[0x8555]=0X80;
228 1 FPGL=5;
229 1 XBYTE[0x8555]=0Xaa;
230 1 FPGL=2;
231 1 XBYTE[0x8aaa]=0X55;
232 1 FPGH=Sec/256;FPGL=Sec%256;
233 1 XBYTE[0x8000]=0x30;
234 1 delayms(25); /* Delay time = Tse */
235 1 }
236
237 /************************************************************************/
238 /* PROCEDURE: Check_Toggle_Ready */
239 /* */
240 /* During the internal program cycle, any consecutive read operation */
241 /* on DQ6 will produce alternating 0's and 1's (i.e. toggling between */
C51 COMPILER V7.06 HLDKZQV12 12/21/2004 08:51:33 PAGE 5
242 /* 0 and 1). When the program cycle is completed, DQ6 of the data will */
243 /* stop toggling. After the DQ6 data bit stops toggling, the device is */
244 /* ready for next operation. */
245 /* */
246 /* Input: */
247 /* Dst Must already be set-up by the caller */
248 /* */
249 /* Output: */
250 /* None */
251 /************************************************************************/
252
253 void Check_Toggle_Ready (uchar xdata *Dst)
254 {
255 1 uchar Loop = TRUE;
256 1 uchar PreData;
257 1 uchar CurrData;
258 1 unsigned int TimeOut = 0;
259 1
260 1 PreData = *Dst;
261 1 PreData = PreData & 0x40;
262 1 while ((TimeOut< 0xFFFF) && (Loop))
263 1 {
264 2 CurrData = *Dst;
265 2 CurrData = CurrData & 0x40;
266 2 if (PreData == CurrData)
267 2 Loop = FALSE; /* ready to exit the while loop */
268 2 PreData = CurrData;
269 2 TimeOut++;
270 2 wdgclr=!wdgclr;
271 2 }
272 1 }
273 /************************************************************************/
274 /* PROCEDURE: Program_One_Byte */
275 /* */
276 /* This procedure can be used to program ONE byte of data to the */
277 /* 39VF016. */
278 /* */
279 /* NOTE: It is necessary to first erase the sector containing the */
280 /* byte to be programmed. */
281 /* */
282 /* Input: */
283 /* Src The BYTE which will be written to the 39VF016 */
284 /* Dst DESTINATION address which will be written with the */
285 /* data passed in from Src */
286 /* */
287 /* Output: */
288 /* None */
289 /************************************************************************/
290
291 void Program_One_Byte (uchar Src, uchar xdata *Dst)
292 {
293 1 // uchar xdata *Temp;
294 1 uchar xdata *DestBuf;
295 1 wdgclr=!wdgclr;
296 1
297 1 DestBuf = Dst;
298 1 FPGH=(page/256)&0x06;FPGL=5;
299 1 XBYTE[0x8555]=0Xaa;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -