📄 简易信号发生器.lst
字号:
C51 COMPILER V8.02 简_仔藕欧⑸_芲 11/11/2008 09:54:56 PAGE 1
C51 COMPILER V8.02, COMPILATION OF MODULE 简_仔藕欧⑸_芲
OBJECT MODULE PLACED IN 简易信号发生器.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE 简易信号发生器.c BROWSE DEBUG OBJECTEXTEND
line level source
1 #include<at89x52.h>
2 #define uchar unsigned char
3 #define uint unsigned int
4 sbit P32=P3^2;
5 sbit P33=P3^3;
6 sbit P34=P3^4;
7 sbit P35=P3^5;
8 sbit P36=P3^6;
9 sbit P37=P3^7;
10 uchar code sin[256]={0x80,0x83,0x86,0x89,0x8d,0x90,0x93,0x96,0x99,0x9c,0x9f,0xa2,0xa5,0xa8,0xab,0xae,0xb1,
-0xb4,0xb7,0xba,0xbc,0xbf,0xc2,0xc5
11 ,0xc7,0xca,0xcc,0xcf,0xd1,0xd4,0xd6,0xd8,0xda,0xdd,0xdf,0xe1,0xe3,0xe5,0xe7,0xe9,0xea,0xec,0xee,0xef,
-0xf1,0xf2,0xf4,0xf5
12 ,0xf6,0xf7,0xf8,0xf9,0xfa,0xfb,0xfc,0xfd,0xfd,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
-0xff,0xff,0xfe,0xfd
13 ,0xfd,0xfc,0xfb,0xfa,0xf9,0xf8,0xf7,0xf6,0xf5,0xf4,0xf2,0xf1,0xef,0xee,0xec,0xea,0xe9,0xe7,0xe5,0xe3,
-0xe1,0xde,0xdd,0xda
14 ,0xd8,0xd6,0xd4,0xd1,0xcf,0xcc,0xca,0xc7,0xc5,0xc2,0xbf,0xbc,0xba,0xb7,0xb4,0xb1,0xae,0xab,0xa8,0xa5,
-0xa2,0x9f,0x9c,0x99
15 ,0x96,0x93,0x90,0x8d,0x89,0x86,0x83,0x80,0x80,0x7c,0x79,0x76,0x72,0x6f,0x6c,0x69,0x66,0x63,0x60,0x5d,
-0x5a,0x57,0x55,0x51
16 ,0x4e,0x4c,0x48,0x45,0x43,0x40,0x3d,0x3a,0x38,0x35,0x33,0x30,0x2e,0x2b,0x29,0x27,0x25,0x22,0x20,0x1e,
-0x1c,0x1a,0x18,0x16
17 ,0x15,0x13,0x11,0x10,0x0e,0x0d,0x0b,0x0a,0x09,0x08,0x07,0x06,0x05,0x04,0x03,0x02,0x02,0x01,0x00,0x00,
-0x00,0x00,0x00,0x00
18 ,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x02 ,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0d,0x0e
-,0x10,0x11,0x13,0x15
19 ,0x16,0x18,0x1a,0x1c,0x1e,0x20,0x22,0x25,0x27,0x29,0x2b,0x2e,0x30,0x33,0x35,0x38,0x3a,0x3d,0x40,0x43,
-0x45,0x48,0x4c,0x4e
20 ,0x51,0x55,0x57,0x5a,0x5d,0x60,0x63,0x66 ,0x69,0x6c,0x6f,0x72,0x76,0x79,0x7c,0x80 };
21 uchar Buff[8]={0};
22 uchar code comcode[8] = {0x7f,0xbf,0xdf,0xff,0xf7,0xfb,0xfd,0xfe};
23 unsigned char LED[10]={0x3F,0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07,0x7F,0x6F};
24 uchar n=0,x=0,a=0,b=0;
25 uint m=10;
26 //
27 //
28 void Delayms(uchar n)
29 {
30 1 uchar i,j;
31 1 for(i=0;i<n;i++)
32 1 for(j=0;j<10;j++);
33 1 }
34 //
35 //
36 void sys_Init()
37 {
38 1 TMOD = 0x15;
39 1
40 1 TH0 = 0xfe;
41 1 TL0 = 0x98;
42 1
43 1 TR0 = 1;
44 1 TR1 = 1;
45 1
C51 COMPILER V8.02 简_仔藕欧⑸_芲 11/11/2008 09:54:56 PAGE 2
46 1 ET0 = 1;
47 1 ET1 = 1;
48 1
49 1
50 1 EA = 1;
51 1 }
52 //
53 //
54 void Display() //显示函数
55 {
56 1 uchar i;
57 1 for(i=0;i<8;i++)
58 1 {
59 2 P0=0x00;
60 2 P0=LED[Buff[7-i]];
61 2 P2=comcode[i];
62 2 Delayms(6);
63 2 }
64 1 }
65 //
66 //
67 void Buchang()
68 {
69 1 if(P32==0)
70 1 {
71 2 while(P32==0);
72 2 {a++;if(a>3) a=0;}
73 2 }
74 1 switch(a)
75 1 {
76 2 case 0: n=10;break;
77 2 case 1: n=20;break;
78 2 case 2: n=50;break;
79 2 case 3: n=100;break;
80 2 }
81 1 }
82 //
83 //
84 void Pinglv()
85 {
86 1 if(P33==0)
87 1 {
88 2 while(P33==0);
89 2 switch(a)
90 2 {
91 3 case 0: m=m+10;break;
92 3 case 1: m=m+20;break;
93 3 case 2: m=m+50;break;
94 3 case 3: m=m+100;break;
95 3 }
96 2 }
97 1 if(P34==0)
98 1 {
99 2 while(P34==0);
100 2 switch(a)
101 2 {
102 3 case 0: m=m-10;break;
103 3 case 1: m=m-20;break;
104 3 case 2: m=m-50;break;
105 3 case 3: m=m-100;break;
106 3 }
107 2 }
C51 COMPILER V8.02 简_仔藕欧⑸_芲 11/11/2008 09:54:56 PAGE 3
108 1 }
109 //
110 //
111 void Boxing()
112 {
113 1 if(P35==0)
114 1 {
115 2 while(P35==0);
116 2 b++;
117 2 if(b>2)
118 2 b=0;
119 2 }
120 1 if(b==0)
121 1 P1=sin[x];
122 1 if(b==1)
123 1 {
124 2 if(x<128)
125 2 P1=0x00;
126 2 else
127 2 P1=0xff;
128 2 }
129 1 if(b==2)
130 1 {
131 2 if(x<128)
132 2 P1=x;
133 2 else
134 2 P1=x-128;
135 2 }
136 1 }
137 //
138 //
139 void Huancun()
140 {
141 1 Buff[0]=m/1000;
142 1 Buff[1]=m%1000/100;
143 1 Buff[2]=m%100/10;
144 1 Buff[3]=m%10;
145 1 Buff[5]=n/100;
146 1 Buff[6]=n%100/10;
147 1 Buff[7]=n%10;
148 1 }
149 //
150 //
151 void main()
152 {
153 1 sys_Init();
154 1 P36=0;
155 1 P37=0;
156 1 while(1)
157 1 {
158 2 Delayms(n);
159 2 Huancun();
160 2 Boxing();
161 2 Pinglv();
162 2 Buchang();
163 2 Display();
164 2 }
165 1 }
166 //
167 //
168 void Timer0() interrupt 1 //定时器1
169 {
C51 COMPILER V8.02 简_仔藕欧⑸_芲 11/11/2008 09:54:56 PAGE 4
170 1 TH0 = (65535-1000000/256/m)/256;
171 1 TL0 = (65535-1000000/256/m)%256;
172 1 x++;
173 1 if(x>255)
174 1 x=0;
175 1 }
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 586 ----
CONSTANT SIZE = 264 ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = 24 ----
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 + -