📄 serires sub.lst
字号:
C51 COMPILER V7.50 SERIRES_SUB 07/16/2008 08:39:35 PAGE 1
C51 COMPILER V7.50, COMPILATION OF MODULE SERIRES_SUB
OBJECT MODULE PLACED IN serires sub.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE serires sub.c BROWSE DEBUG OBJECTEXTEND SRC(.\serires sub.SRC)
line level source
1 #include <reg54.h>
2 #include <delay subroutine.h>
3 #include <byteone.h>
4 #include <intrins.h>
5 #define uchar unsigned char
6 #define uint unsigned int
7
8 sbit BDR=P1^5;
9 sbit BDT=P3^5;
10 sbit RES=P1^7;
11 uchar xdata Eeprom[4096];
12
13 extern uchar Instruction[5];
14 /*
15 void Timer_ini()
16 {
17 TH1=0xff;
18 TL1=0x01;
19
20 TMOD=0x20;
21 SCON=0x50;
22 PCON=0x80;
23 }
24
25 void timer1_isr(void) interrupt 3 using 0
26 {
27 TH1=0x75;
28 TL1=0x5f;
29
30 }
31 void Timer_Delay(uchar TL1_value,TH1_value)
32 {
33 TR1=0;
34 TH1=TH1_value;
35 TL1=TL1_value;
36
37 TMOD=0x10;
38 TR1=1; //启动定时器1
39 while(TF1!=1);
40 // TF1=0;
41 TR1=0;
42 }*/
43
44 uint Baud_Config()
45 {
46 1 int ii;
47 1 uchar bytehh,bytell;
48 1 uint Baud_byte_r;
49 1 uint Baud_vh;
50 1 Baud_vh=1;
51 1 // Baud_vl=1;
52 1
53 1 BDT=0;
54 1 RES=0;
55 1 delay100ms();
C51 COMPILER V7.50 SERIRES_SUB 07/16/2008 08:39:35 PAGE 2
56 1 RES=1;
57 1 delay100ms();
58 1 BDT=1;
59 1 delay100ms();
60 1
61 1 Trbyte(0x90,Baud_vh,Baud_vh);
62 1 delay10ms();
63 1 for(ii=0;ii<1000;ii++)
64 1 {
65 2 delay10ms();
66 2 Baud_byte_r=Baud_vh+1;
67 2 Trbyte(0xe0,Baud_vh,Baud_vh);Trbyte(0x00,Baud_vh,Baud_vh);Trbyte(0x0b,Baud_vh,Baud_vh);//e0 00 0b
68 2 delay10us();delay10us();
69 2 bytehh=RecByte(Baud_byte_r);
70 2 bytell=RecByte(Baud_byte_r);
71 2 // output(bytell);
72 2 // delay1ms();
73 2 if(bytell!=0x00)
74 2 {
75 3 Baud_vh+=1;
76 3
77 3 // Baud_vl+=1;
78 3 continue;
79 3 }
80 2 break;
81 2 }
82 1
83 1
84 1 Trbyte(0xe4,Baud_vh,Baud_vh);Trbyte(0xff,Baud_vh,Baud_vh);Trbyte(0x01,Baud_vh,Baud_vh);//e4 ff 01
85 1 delay10us();delay10us();
86 1 bytehh=RecByte(Baud_byte_r);
87 1 bytell=RecByte(Baud_byte_r);
88 1 // output(bytell); //
89 1 if((bytell & 0xc0) == 0xc0)
90 1 {
91 2 output(0x55);
92 2 output(0xbb);
93 2 }
94 1 else
95 1 {
96 2 output(0xaa);
97 2 output(0x00);
98 2
99 2 P4 &= ~(1 << 3); //报错点亮红灯+
100 2
101 2 P4 &= ~(1 << 1);
102 2 delay200ms();delay200ms();
103 2 P4 |= (1 << 1); //蜂鸣器
104 2 delay200ms();delay200ms();
105 2 P4 &= ~(1 << 1);
106 2 delay200ms();delay200ms();
107 2 P4 |= (1 << 1); //蜂鸣器
108 2 delay200ms();delay200ms();
109 2 P4 &= ~(1 << 1);
110 2 delay200ms();delay200ms();
111 2 P4 |= (1 << 1); //蜂鸣器
112 2
113 2 #pragma asm
114 2 ljmp 8000h
115 2 #pragma endasm
116 2 }
117 1
C51 COMPILER V7.50 SERIRES_SUB 07/16/2008 08:39:35 PAGE 3
118 1 return(Baud_vh);
119 1 }
120
121 void Tr_write_sequence(uchar byte1,byte2,byte3,byte4,byte5,uint byte_config_sub)
122 {
123 1 Trbyte(byte1,byte_config_sub,byte_config_sub);
124 1 Trbyte(byte2,byte_config_sub,byte_config_sub);
125 1 Trbyte(byte3,byte_config_sub,byte_config_sub);
126 1 Trbyte(byte4,byte_config_sub,byte_config_sub);
127 1 Trbyte(byte5,byte_config_sub,byte_config_sub);
128 1 }
129
130 void Config_Eeprom(uint byte_config)
131 {
132 1 delay104us();
133 1 Tr_write_sequence(0xc0,0x00,0x12,0x41,0x41,byte_config);
134 1 delay1ms();delay1ms();
135 1
136 1 Tr_write_sequence(0xc0,0x00,0x10,0x00,0x00,byte_config);
137 1 delay1ms();delay1ms();
138 1
139 1 Tr_write_sequence(0xc0,0x01,0x10,0x05,0x05,byte_config); //4a
140 1 delay1ms();delay1ms();
141 1
142 1 Tr_write_sequence(0xc0,0x01,0x12,0x00,0x00,byte_config);
143 1 delay1ms();delay1ms();
144 1
145 1 Tr_write_sequence(0xc0,0x01,0x14,0xff,0xff,byte_config);
146 1 delay1ms();delay1ms();
147 1
148 1 // Tr_write_sequence(0xc0,0x01,0x15,0x32,0x32,byte_config);
149 1 delay1ms();delay1ms();
150 1 }
151
152 void Read_datas()
153 {
154 1 uchar addrll,addrhh;
155 1 int r_cycle;
156 1 uint Crystal,Crystal_r;
157 1 uint Data_Size_Read;
158 1 uchar byte_h,byte_l;
159 1
160 1 Crystal=Baud_Config();
161 1 Crystal_r=Crystal+1;
162 1
163 1 addrhh=Instruction[1];
164 1 addrll=Instruction[2];
165 1 Data_Size_Read=(Instruction[3])*256+Instruction[4];
166 1
167 1 //Trbyte(0x90,Crystal,Crystal);
168 1 delay10ms();
169 1 Config_Eeprom(Crystal);
170 1 delay200ms();delay200ms();delay200ms();delay200ms();delay200ms();
171 1 for(r_cycle=0;r_cycle<Data_Size_Read;r_cycle+=2)
172 1 {
173 2 Trbyte(0xe8,Crystal,Crystal);Trbyte(addrhh,Crystal,Crystal);Trbyte(addrll,Crystal,Crystal);
174 2 delay10us();delay10us();
175 2 byte_h=RecByte(Crystal_r);
176 2 byte_l=RecByte(Crystal_r);
177 2 output(byte_h);
178 2 output(byte_l);
179 2 delay104us();delay104us();
C51 COMPILER V7.50 SERIRES_SUB 07/16/2008 08:39:35 PAGE 4
180 2
181 2 addrll+=2;
182 2 if(addrll!=0)
183 2 continue;
184 2 addrhh+=1;
185 2 }
186 1 }
187
188 /*********************************************************
189 *function name :void In_datas();
190 *function describe:receive datas from the pc
191 *********************************************************/
192 void In_datas()
193 {
194 1 int j_in;
195 1 uint In_size;
196 1 In_size=(Instruction[3])*256+Instruction[4];
197 1 for(j_in=0;j_in<In_size;j_in++)
198 1 {
199 2 Eeprom[j_in]=(input());
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -