?? main.lst
字號:
C51 COMPILER V6.23a MAIN 11/24/2002 21:27:04 PAGE 1
C51 COMPILER V6.23a, COMPILATION OF MODULE MAIN
OBJECT MODULE PLACED IN main.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE main.c LARGE DEBUG OBJECTEXTEND
stmt level source
1
2 #ifdef MONITOR51 /* Debugging with Monitor-51 needs */
char code reserve [3] _at_ 0x23; /* space for serial interrupt if */
#endif /* Stop Exection with Serial Intr. */
5 /* is enabled */
6 /*------------------------------------------------
7 The main C function. Program execution starts
8 here after stack initialization.
9 ------------------------------------------------*/
10 #include <stdio.h>
11 #include <reg51.h>
12 #include <math.h>
13
14 #define DEBUG
15 #define VALID 0
16 #define INVALID 1
17 #define TRUE 1
18 #define FALSE 0
19 #define ConstClockWise 1
20 #define ConstAntiClock 0
21
22 #define DELAY_VALVE 3
23
24 #define MAXSTEPS 400 //maxsteps = 360/0.9=400
25 #define HALFMAXSTEPS 200 //180 degree
26 #define ONEQUARTERSTEPS 100
27 #define THREEQUARTERSTEPS 300
28 #define OCTANT 50
29
30 #define MAXINPULSE 20
31
32
33 //#define PinZFeedBack P0_0 //input,photoelectricity signal feed back ,to know where is the 0 angle p
-osition
34 #define PinClockWiseRot P0_1 //input,ClockWise Rotate Signal
35 #define PinAntiClockRot P0_2 //input,Anti-clock-wise rotate signal
36 //#define PinInFree P0_3 //input,Rotate to Zero Angle Signal
37 #define PinDrvOPTO P1_0 //output,opto.
38 #define PinDrvFree P1_1 //output,if ,then machine is free
39 #define PinDrvAntiClock P1_2 //output,if VALID,then Drive the machine rotate ANTI-clock wise
40 #define PinDriver P1_3 //output,give Pulse to control the machine's speed
41
42 #define PinXClockWise P2_0 //input,X-array machine rotate clockwisely
43 #define PinYClockWise P2_1 //input,Y-array machine rotate clockwisely
44
45
46 #define PinLamp1 P1_4
47 #define PinLamp2 P1_5
48 #define PinLamp3 P1_6
49 #define PinLamp4 P1_7
50
51 #define PinLamp5 P2_2
52 #define PinLamp6 P2_3
53
54 #define PinLampBlink PinLamp1
C51 COMPILER V6.23a MAIN 11/24/2002 21:27:04 PAGE 2
55 #define PinRotIndicator PinLamp2
56 #define LampFatalError PinLamp4
57 #define PinLampDebug PinLamp3
58 #define LampOVErr PinLamp5
59 #define LampComm PinLamp6
60
61
62 sbit P0_0=P0^0;
63 sbit P0_1=P0^1;
64 sbit P0_2=P0^2;
65 sbit P0_3=P0^3;
66 sbit P0_4=P0^4;
67 sbit P0_5=P0^5;
68 sbit P0_6=P0^6;
69 sbit P0_7=P0^7;
70
71 sbit P1_0=P1^0;
72 sbit P1_1=P1^1;
73 sbit P1_2=P1^2;
74 sbit P1_3=P1^3;
75 sbit P1_4=P1^4;
76 sbit P1_5=P1^5;
77 sbit P1_6=P1^6;
78 sbit P1_7=P1^7;
79
80 sbit P2_0=P2^0;
81 sbit P2_1=P2^1;
82 sbit P2_2=P2^2;
83 sbit P2_3=P2^3;
84 sbit P2_4=P2^4;
85 sbit P2_5=P2^5;
86 sbit P2_6=P2^6;
87 sbit P2_7=P2^7;
88
89 sbit P3_2=P3^2;
90 sbit P3_3=P3^3;
91
92
93 bit EvTimer=FALSE;
94 bit EvRcv=FALSE;
95
96 char rcvdata=0;
97 char workmode=2;
98 int delaycount=20;
99
100 long int XPulse=0,YPulse=0;
101 long int XPulseTemp=0,YPulseTemp=0;
102
103 //用最小步數表示角度
104
105 //int debugreg[4];
106 int debugYinput=0;
107 int debugXinput=0;
108 int counter10ms=0;
109 int debugtime=0;
110
111
112 void initial(void); //初始化子程序
113 void delay(int i);
114 int FuncRotate(bit BClockWise,int step,int *PRegAngle);
115 int FuncGoAngleZ(int *PRegAngle);
116 void send(char *temp,int j);
C51 COMPILER V6.23a MAIN 11/24/2002 21:27:04 PAGE 3
117
118
119 void main(void)
120 {
121 1 int RegAngle=0,RegNewAngle=0,temp=0;
122 1 long int Xtmp=0,Ytmp=0;
123 1
124 1 initial(); //初始化子程序
125 1 PinDriver=VALID;
126 1 PinLamp1=FALSE;
127 1 PinLamp2=FALSE;
128 1 PinLamp3=FALSE;
129 1 PinLamp4=FALSE;
130 1 PinLamp5=FALSE;
131 1 PinLamp6=FALSE;
132 1
133 1 PinDrvOPTO=FALSE;
134 1 PinDrvFree=FALSE;
135 1 delay(1);
136 1
137 1 while(1)
138 1 {
139 2 while(PinInFree==VALID)
*** ERROR C202 IN LINE 139 OF MAIN.C: 'PinInFree': undefined identifier
140 2 {
141 3 TR0=0;
142 3 PinDrvFree=TRUE;
143 3 while(PinClockWiseRot==VALID)
144 3 {
145 4 PinDrvFree=FALSE;
146 4 FuncRotate(ConstClockWise,1,&RegAngle);
147 4 delay(500);
148 4 }
149 3 while(PinAntiClockRot==VALID)
150 3 {
151 4 PinDrvFree=FALSE;
152 4 FuncRotate(ConstAntiClock,1,&RegAngle);
153 4 delay(500);
154 4 }
155 3 TR0=1;
156 3 EvTimer=FALSE;
157 3 }
158 2 PinDrvFree=FALSE;
159 2 if(EvRcv)
160 2 {
161 3 delaycount=rcvdata&0x1F;
162 3 workmode=(rcvdata&0xE0)/32;
163 3 EvRcv=FALSE;
164 3 }
165 2
166 2
167 2 if (EvTimer)
168 2 {
169 3 ++debugtime;
170 3 if(debugtime==5)
171 3 {
172 4 PinLampBlink=TRUE;
173 4 }
174 3 else if(debugtime==10)
175 3 {
176 4 PinLampBlink=FALSE;
177 4 debugtime=0;
C51 COMPILER V6.23a MAIN 11/24/2002 21:27:04 PAGE 4
178 4 }
179 3
180 3 RegNewAngle=XPulse*XPulse+YPulse*YPulse;
181 3 // RegNewAngle=(int)sqrt((float)RegNewAngle);
182 3
183 3 temp=RegNewAngle-RegAngle;
184 3 if(temp>HALFMAXSTEPS)
185 3 {
186 4 temp=temp-MAXSTEPS;
187 4 }
188 3 else if(temp<-HALFMAXSTEPS)
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -