📄 s51yk.lst
字号:
C51 COMPILER V8.02 S51YK 07/24/2009 22:56:05 PAGE 1
C51 COMPILER V8.02, COMPILATION OF MODULE S51YK
OBJECT MODULE PLACED IN s51yk.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE s51yk.c BROWSE DEBUG OBJECTEXTEND
line level source
1 #include <reg51.h>
2 #define c(x) (x*110592/120000)
3 sbit Ir_Pin=P3^2;
4 sbit beep=P3^6;
5 unsigned char code Led_Tab[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,
6 0x80,0x90,0x88,0x83,0xc6,0xa1,0x86,0x8e,0xbf}; //共阳极数码显示码0-F.
7 unsigned char code Led_Sel[]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f};
8 unsigned char Led_Buf[7]; //显示缓冲区
9 char Led_Index; //位选
10 unsigned char Ir_Buf[4]; //用于保存解码结果
11 void delay_50ms(unsigned int t)
12 {
13 1 unsigned int j;
14 1 for(;t>0;t--)
15 1 for(j=6245;j>0;j--)
16 1 {;}
17 1 }
18
19 //==============================================================
20 //数码管扫描
21 timer0() interrupt 1 using 1
22 {
23 1 TL0=65536-1000;
24 1 TH0=(65536-1000)/256; //定时器0设定约1000us中断一次,用于数码管扫描
25 1 P0=0xff;
26 1 P2=Led_Sel[Led_Index]; //位选
27 1 P0=Led_Tab[Led_Buf[Led_Index]]; //段选
28 1 if(++Led_Index>7) Led_Index=0; //八个扫描完了,到第一个数码管
29 1
30 1 }
31 //==============================================================
32 unsigned int Ir_Get_Low()
33 {
34 1 TL1=0;
35 1 TH1=0;
36 1 TR1=1;
37 1 while(!Ir_Pin && (TH1&0x80)==0);
38 1 TR1=0;
39 1 return TH1*256+TL1;
40 1 }
41 //=============================================================
42 unsigned int Ir_Get_High()
43 {
44 1 TL1=0;
45 1 TH1=0;
46 1 TR1=1;
47 1 while(Ir_Pin && (TH1&0x80)==0);
48 1 TR1=0;
49 1 return TH1*256+TL1;
50 1 }
51 //==============================================================
52 main()
53 {
54 1 unsigned int temp;
55 1 char i,j;
C51 COMPILER V8.02 S51YK 07/24/2009 22:56:05 PAGE 2
56 1 Led_Index=0;
57 1 TMOD=0x11;
58 1 TL0=65536-1000;
59 1 TH0=(65536-1000)/256; //定时器0设定约1000us中断一次,用于数码管扫描
60 1 EA=1;
61 1 ET0=1;
62 1 TR0=1;
63 1
64 1 //Led_Buf[0]=0;
65 1 //Led_Buf[1]=0;
66 1 //Led_Buf[2]=0;
67 1 //Led_Buf[3]=0; //显示区设成0
68 1 // Led_Buf[4]=0;
69 1 //Led_Buf[5]=0;
70 1 //Led_Buf[6]=0;
71 1 //Led_Buf[7]=0; //显示区设成0
72 1 do{
73 2 restart:
74 2 while(Ir_Pin);
75 2 temp=Ir_Get_Low();
76 2 if(temp<c(8500) || temp>c(9500)) continue;//引导脉冲低电平9000
77 2 temp=Ir_Get_High();
78 2 if(temp<c(4000) || temp>c(5000)) continue;//引导脉冲高电平4500
79 2 for(i=0;i<4;i++) //4个字节
80 2 for(j=0;j<8;j++) //每个字节8位
81 2 {
82 3 temp=Ir_Get_Low();
83 3 if(temp<c(200) || temp>c(800)) goto restart;
84 3 temp=Ir_Get_High();
85 3 if(temp<c(200) || temp>c(2000)) goto restart;
86 3 Ir_Buf[i]>>=1;
87 3 if(temp>c(1120)) Ir_Buf[i]|=0x80;
88 3 }
89 2 Led_Buf[0]=(Ir_Buf[0]/16)&0xf;//显示结果
90 2 Led_Buf[1]=Ir_Buf[0]&0xf; //显示结果
91 2 Led_Buf[2]=(Ir_Buf[1]/16)&0xf; //显示结果
92 2 Led_Buf[3]=Ir_Buf[1]&0xf; //显示结果
93 2 Led_Buf[4]=(Ir_Buf[2]/16)&0xf; //显示结果
94 2 Led_Buf[5]=Ir_Buf[2]&0xf; //显示结果
95 2 Led_Buf[6]=(Ir_Buf[3]/16)&0xf; //显示结果
96 2 Led_Buf[7]=Ir_Buf[3]&0xf; //显示结果
97 2 beep=0;
98 2 delay_50ms(2);
99 2 beep=1;
100 2 }
101 1 while(1);
102 1
103 1 }
104
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 507 ----
CONSTANT SIZE = 25 ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = 12 2
IDATA SIZE = ---- ----
BIT SIZE = ---- ----
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -