- C51 COMPILER V7.50 DEMO 04/04/2005 11:43:52 PAGE 1
- C51 COMPILER V7.50, COMPILATION OF MODULE DEMO
- OBJECT MODULE PLACED IN demo.OBJ
- COMPILER INVOKED BY: C:KeilC51BINC51.EXE demo.c BROWSE DEBUG OBJECTEXTEND
- line level source
- 1 #include <reg52.h>
- 2 //#include <string.h>
- 3 //#include <stdio.h>
- 4
- 5 #define uchar unsigned char
- 6
- 7 #define EMBIT P1^1
- 8
- 9 uchar OLDEM=0;
- 10
- 11 //u2270b 读卡模块,利用T0解码
- 12
- 13 SCON |= 0xc0; //开启帧错误位。UART设置为9位。
- *** ERROR C129 IN LINE 13 OF DEMO.C: missing ';' before '|='
- 14 TCON |= 0x00;
- 15 PCON &= 0x7f;
- 16 TMOD |= 0x11; //定义T0工作模式定时器0作为双8位定时计数 器。
- 17 //TL0为8位定时/计数器通过标准定时器0控制位控制。
- 18 //TH0仅作为8位定时器,由定时器1控制位控制,此模式下定时/计数器1关闭。
- 19
- 20 bit bitchange(void)//检查数据
- 21 {
- 22 uchar outtime;
- 23 bit bitc;
- 24 bitc=1;
- 25 outtime=200;
- 26 bitchlp1:
- 27 if (((EMBIT==OLDEM) && (outtime!=0))==1)
- 28 {
- 29 outtime--;
- 30 rst_wdog();
- 31 goto bitchlp1;
- 32 }
- 33 if (outtime==0)
- 34 {
- 35 bitc=0;
- 36 }
- 37 OLDEM=EMBIT;
- 38 return bitc;
- 39 }
- 40
- 41 bit findlongpluse(void)
- 42 {
- 43 bit retbit;
- 44 retbit=1;
- 45 OLDEM=EMBIT;
- 46 TH0=0;
- 47 TL0=0;
- 48 TR0=0;
- 49 if (bitchange()==0)
- 50 {
- 51 goto errfindlong;
- 52 }
- 53 TR0=1;
- 54 findllp1:
- C51 COMPILER V7.50 DEMO 04/04/2005 11:43:52 PAGE 2
- 55 if (bitchange()==0)
- 56 {
- 57 goto errfindlong;
- 58 }
- 59 TR0=0;
- 60 if (TH0>2)
- 61 {
- 62 goto errfindlong;
- 63 }
- 64 if (TH0==2)
- 65 {
- 66 goto findllp2;
- 67 }
- 68 if ((TH0==1) && (TL0>98))
- 69 {
- 70 goto findllp2;
- 71 }
- 72 if ((TH0==0) && (TL0<100))
- 73 {
- 74 goto errfindlong;
- 75 }
- 76 TH0=0;
- 77 TL0=0;
- 78 TR0=1;
- 79 goto findllp1;
- 80 errfindlong:retbit=0;
- 81 findllp2: return retbit;
- 82 }
- 83
- 84 bit readbit(void)
- 85 {
- 86 bit retbit;
- 87 retbit=1;
- 88 TH0=0;
- 89 TL0=0;
- 90 TR0=1;
- 91 if (bitchange()==0)
- 92 {
- 93 goto errreadbit;
- 94 }
- 95 TR0=0;
- 96 if (TH0>2)
- 97 {
- 98 goto errreadbit;
- 99 }
- 100 if ((TH0==0) && (TL0<100))
- 101 {
- 102 goto errreadbit;
- 103 }
- 104 if (TH0==2)
- 105 {
- 106 goto okreadbit;
- 107 }
- 108 if ((TH0==1) && (TL0>35))
- 109 {
- 110 goto okreadbit;
- 111 }
- 112 TH0=0;
- 113 TL0=0;
- 114 TR0=1;
- 115 if (bitchange()==0)
- 116 {
- C51 COMPILER V7.50 DEMO 04/04/2005 11:43:52 PAGE 3
- 117 goto errreadbit;
- 118 }
- 119 TR0=0;
- 120 if (TH0>1)
- 121 {
- 122 goto errreadbit;
- 123 }
- 124 if ((TH0==0) && (TL0<100))
- 125 {
- 126 goto errreadbit;
- 127 }
- 128 if ((TH0==1) && (TL0>35))
- 129 {
- 130 goto errreadbit;
- 131 }
- 132 goto okreadbit;
- 133 errreadbit:retbit=0;
- 134 okreadbit:return retbit;
- 135 }
- 136
- 137 bit findbegin(void)
- 138 {
- 139 bit retbit;
- 140 uchar tempdata;
- 141 uint fk;
- 142 fk=1000;
- 143 retbit=1;
- 144 tempdata=0;
- 145 if (findlongpluse()==0)
- 146 {
- 147 goto errfindbegin;
- 148 }
- 149 findbelp1:
- 150 if (readbit()==0)
- 151 {
- 152 goto errfindbegin;
- 153 }
- 154 if (OLDEM==0)
- 155 {
- 156 if (tempdata==0xff)
- 157 {
- 158 goto okfindbegin;
- 159 }
- 160 tempdata=tempdata<<1;
- 161 tempdata=tempdata | 1;
- 162 }
- 163 else
- 164 {
- 165 tempdata=tempdata<<1;
- 166 }
- 167 fk--;
- 168 if (fk==0)
- 169 {
- 170 goto errfindbegin;
- 171 }
- 172 goto findbelp1;
- 173 errfindbegin: retbit=0;
- 174 okfindbegin:return retbit;
- 175 }
- 176
- 177 bit rdemdata(void)
- 178 {
- C51 COMPILER V7.50 DEMO 04/04/2005 11:43:52 PAGE 4
- 179 bit retbit;
- 180 uchar i;
- 181 uchar j;
- 182 uchar parity;
- 183 uchar emcheck;
- 184 emcheck=0;
- 185 retbit=1;
- 186 if (findbegin()==0)
- 187 {
- 188 goto errrdem;
- 189 }
- 190 for (j=0;j<=4;j++)
- 191 {
- 192 parity=0;
- 193 for (i=1;i<=4;i++)
- 194 {
- 195 if (readbit()==0)
- 196 {
- 197 goto errrdem;
- 198 }
- 199 emdata[j]=emdata[j]<<1;
- 200 if (OLDEM==0)
- 201 {
- 202 emdata[j]=emdata[j] | 1;
- 203 parity++;
- 204 }
- 205 }
- 206 if (readbit()==0)
- 207 {
- 208 goto errrdem;
- 209 }
- 210 if (OLDEM==0)
- 211 {
- 212 parity++;
- 213 }
- 214 if ((parity & 1)==1)
- 215 {
- 216 goto errrdem;
- 217 }
- 218 parity=0;
- 219
- 220 for (i=1;i<=4;i++)
- 221 {
- 222 if (readbit()==0)
- 223 {
- 224 goto errrdem;
- 225 }
- 226 emdata[j]=emdata[j]<<1;
- 227 if (OLDEM==0)
- 228 {
- 229 emdata[j]=emdata[j] | 1;
- 230 parity++;
- 231 }
- 232 }
- 233 if (readbit()==0)
- 234 {
- 235 goto errrdem;
- 236 }
- 237 if (OLDEM==0)
- 238 {
- 239 parity++;
- 240 }
- C51 COMPILER V7.50 DEMO 04/04/2005 11:43:52 PAGE 5
- 241 if ((parity&1)==1)
- 242 {
- 243 goto errrdem;
- 244 }
- 245 }
- 246 for (i=1;i<=5;i++)
- 247 {
- 248 if (readbit()==0)
- 249 {
- 250 goto errrdem;
- 251 }
- 252 emcheck=emcheck<<1;
- 253 if (OLDEM==0)
- 254 {
- 255 emcheck=emcheck | 1;
- 256 }
- 257 }
- 258 if ((emcheck&1)==1)
- 259 {
- 260 goto errrdem;
- 261 }
- 262 emcheck=emcheck<<3;
- 263 for (j=0;j<=3;j++)
- 264 {
- 265 parity=0;
- 266 for (i=0;i<=4;i++)
- 267 {
- 268 if (((emdata[i]<<j) & 0x80)==0x80)
- 269 {
- 270 parity++;
- 271 }
- 272 if (((emdata[i]<<j) & 0x8)==0x8)
- 273 {
- 274 parity++;
- 275 }
- 276 }
- 277 if (((emcheck<<j) & 0x80)==0x80)
- 278 {
- 279 parity++;
- 280 }
- 281 if ((parity%2)==1)
- 282 {
- 283 goto errrdem;
- 284 }
- 285 }
- 286 goto okrdemdata;
- 287 errrdem:retbit=0;
- 288 okrdemdata:return retbit;
- 289 }
- 290
- 291
- 292
- C51 COMPILATION COMPLETE. 0 WARNING(S), 1 ERROR(S)