📄 end.lst
字号:
C51 COMPILER V8.09 END 11/28/2004 05:44:22 PAGE 1
C51 COMPILER V8.09, COMPILATION OF MODULE END
OBJECT MODULE PLACED IN End.OBJ
COMPILER INVOKED BY: D:\Keil\C51\BIN\C51.EXE End.c BROWSE DEBUG OBJECTEXTEND
line level source
1 #include<reg52.h>
2 #include"I2C.h"
3 #include"ZLG7290.h"
4
5 #define uchar unsigned char
6 #define uint unsigned int
7
8 #define N 50
9
10 sbit wr=P2^5;
11 sbit chab=P2^7; //接口定义
12 sbit cs=P2^6;
13
14 uint Ph=0;
15 uchar Amp=10;
16 uchar chPA=2; //相幅转换;
17
18 uchar code Sin[N]={64,72,80,88,95,102,108,114,118,122,125,127,127,127,126,124,120,116,111,105,98,91,84,76,
-68,59,51,43,36,29,22,16,11,7,3,1,0,0,0,2,5,9,13,19,25,32,39,47,55,63};
19 uchar SinB[N]={0};
20
21 /*延时0.01s*/
22 void Delay(unsigned int t)
23 {
24 1 do
25 1 {
26 2 TH0 = 0xDC;
27 2 TL0 = 0x00;
28 2 TR0 = 1;
29 2 while ( !TF0 );
30 2 TF0 = 0;
31 2 TR0 = 0;
32 2 } while (--t);
33 1 }
34
35 /*全部清显示*/
36 void ClearAll()
37 {
38 1 uchar i;
39 1 for (i=0;i<8;i++)
40 1 ZLG7290_Download(i,0,0,31);
41 1 }
42
43 /*系统初始化*/
44 void SystemInit()
45 {
46 1 I2C_Init();
47 1 TMOD = 0x01;
48 1 Delay(30);
49 1 }
50
51 /*显示相位*/
52 void DisplayPhase()
53 { if(Ph==0)ZLG7290_Download(7,0,0,0);
54 1 else if(Ph<100){ZLG7290_Download(7,0,0,Ph/10);ZLG7290_Download(6,0,0,0);}
C51 COMPILER V8.09 END 11/28/2004 05:44:22 PAGE 2
55 1 else {ZLG7290_Download(7,0,0,Ph/100);ZLG7290_Download(6,0,0,Ph/10%10);ZLG7290_Download(5,0,0,0);}
56 1 }
57
58 /*显示振幅*/
59 void DisplayAmp()
60 {
61 1 ZLG7290_Download(2,1,0,Amp/10);
62 1 ZLG7290_Download(1,0,0,Amp%10);
63 1 ZLG7290_Download(0,0,0,0);
64 1 }
65
66 /*移相*/
67 void PhaseUp()
68 {uint i,j;uchar temp;
69 1 if(Ph!=330)
70 1 {Ph=Ph+30;
71 2 for(j=0;j<4;j++)
72 2 {temp=SinB[N-1];
73 3 for(i=N-1;i>0;i--)
74 3 {SinB[i]=SinB[i-1];
75 4 }
76 3 SinB[0]=temp;
77 3 }
78 2 }
79 1 else{Ph=0;for(i=0;i<N;i++)SinB[i]=(int)((float)Sin[i]*(float)(Amp)/10.0); }
80 1 }
81 void PhaseDn()
82 {uint i,j;uchar temp;
83 1 if(Ph>=30)
84 1 {Ph=Ph-30;
85 2 for(j=0;j<4;j++)
86 2 { temp=SinB[0];
87 3 for(i=0;i<N;i++)
88 3 {SinB[i]=SinB[i+1];
89 4 }
90 3 SinB[N-1]=temp;
91 3 }
92 2 }
93 1 }
94
95 /*变幅*/
96 void AmpUp()
97 {
98 1 uint i;
99 1 if(Amp<20)
100 1 {
101 2 Amp=Amp+2;
102 2 for(i=0;i<N;i++)
103 2 {
104 3 SinB[i]=(int)(SinB[i]*(float)(Amp)/(float)(Amp-2));
105 3 }
106 2 }
107 1
108 1 }
109 void AmpDn()
110 {
111 1 uint i;
112 1 if(Amp>2)
113 1 {
114 2 Amp=Amp-2;
115 2 for(i=0;i<N;i++)
116 2 {
C51 COMPILER V8.09 END 11/28/2004 05:44:22 PAGE 3
117 3 SinB[i]=(int)(SinB[i]*(float)(Amp)/(float)(Amp+2));
118 3 }
119 2 }
120 1
121 1 }
122
123 /*重置*/
124 void reset()
125 { uint i;
126 1 Ph=0;Amp=10;
127 1 for(i=0;i<N;i++)
128 1 SinB[i]=Sin[i];
129 1 //
130 1 }
131
132
133
134 /*测试按键功能*/
135 void KeyT()interrupt 0
136 {
137 1 unsigned char KeyValue;
138 1 ClearAll();
139 1 ZLG7290_ReadReg(ZLG7290_Key,&KeyValue);
140 1
141 1 switch(KeyValue)
142 1 {case 1:chPA=(chPA+1)%3;break;
143 2 case 2:switch(chPA)
144 2 {case 2:break;
145 3 case 0:PhaseUp();break;
146 3 case 1:AmpUp();break;
147 3 }break;
148 2 case 3:switch(chPA)
149 2 {case 2:break;
150 3 case 0:PhaseDn();break;
151 3 case 1:AmpDn();break;
152 3 }break;
153 2 case 4:reset();break;
154 2 }
155 1 DisplayPhase();DisplayAmp();
156 1 ZLG7290_WriteReg(ZLG7290_FlashOnOff,0x11);
157 1 if(chPA==0)ZLG7290_Flash(0xf0);
158 1 else if(chPA==1)ZLG7290_Flash(0x0f);
159 1 else ZLG7290_Flash(0x00);
160 1
161 1 }
162
163 void main()
164 { uchar i;
165 1 EA = 0;
166 1 IT0 = 1; //负边沿触发中断
167 1 EX0 = 1; //允许外部中断
168 1 EA = 1;
169 1 SystemInit();
170 1 ClearAll();
171 1 DisplayPhase();DisplayAmp();
172 1 ZLG7290_Flash(0x00);
173 1
174 1 for(i=0;i<N;i++)SinB[i]=Sin[i];
175 1
176 1 cs=0;wr=1;chab=1;i=0;
177 1
178 1 while(1)
C51 COMPILER V8.09 END 11/28/2004 05:44:22 PAGE 4
179 1 {
180 2 wr=1;
181 2 chab=!chab;
182 2 if(chab==0)P0=Sin[i];
183 2 else P0=SinB[i];
184 2 wr=0 ;
185 2 if(chab){i++; if(i>=N)i=0; }
186 2 }
187 1 }
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 999 ----
CONSTANT SIZE = 50 ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = 54 9
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 + -