📄 working.lst
字号:
C51 COMPILER V7.07 WORKING 09/25/2006 10:39:22 PAGE 1
C51 COMPILER V7.07, COMPILATION OF MODULE WORKING
OBJECT MODULE PLACED IN Working.OBJ
COMPILER INVOKED BY: C:\keil\C51\BIN\c51.exe Working.c DB OE SMALL ROM(LARGE)
stmt level source
1 /*
2 **********************************************************************************************************
-*********
3 * XingChen
4 * (c)Copyright 2004,HangZhou,China
5 * All Rights Reserved
6 * (2004/8/7)
7 *
8 *FileName : Robot Control
9 *Programmer: Beyond Z.H.
10 * Version : V1.0
11 *Finished : 2004/8/26
12 **********************************************************************************************************
-********
13 */
14 /*$PAGE*/
15 /*
16 **********************************************************************************************************
-********
17 * INCLUDE FILES
18 **********************************************************************************************************
-*********
19 */
20 #include <AT89X52.H> /* special function registers for AT89c52 device */
21 #include <math.h> /* stanard C math-file */
22 #include <stdio.h> /* standard I/O .h-file */
23 #include "working.h" /* selfdefined standard .h-file */
24
25 /*$PAGE*/
26
27
28 /*
29 **********************************************************************************************************
-********
30 * MAIN PROGRAM
31 * Description: Main program running when workpiece is ready on deferent belt(deferent_ready=ture).
32 * Call Square_Wave subroutine to generate 0.5ms square wave on P1.2 to drive
33 * electromotor,then drive deferent belt step forward. When it steps to the measure
34 * zone, it stops to be measured. Then call A_D subroutine to transform analog
35 * signals to digital signals , after then call serial subroutine to transfer
36 * digital signals to PC. Call square wave subroutine to drive deferent belt step to
37 * original position waitting for defere ready flag to run the next circle.
38 * Arguments : none
39 *
40 * Returns : none
41 **********************************************************************************************************
-*******
42 */
43 /*
44 **********************************************************************************************************
-********
45 * 通信数据格式
46 * 开中断,等待上位机送正确的命令 ’CS'(0X43 0x53) 回送’R’ (0x52)
47 * 错误的命令 ,回送‘W’ (0x57)
48 * 关中断,开始AD()和送数 0XAD,K,低8位,高8位 ,和校验,等等上位机回送‘R’ (0x52)
C51 COMPILER V7.07 WORKING 09/25/2006 10:39:22 PAGE 2
49 * 重复共做20次
50 * 工件转回后,送通知‘CE’ (0x43 0x45),回收‘R’则一次操作结束,重新开始
51 * ,10S没有正确回收,则重发通知
52 *
53 *
54 **********************************************************************************************************
-*******
55 */
56 /* private variables */
57
58 INT16U UIntCounter;
59
60 INT8U idata send[SEND_SIZE]; //
61 INT8U idata s_start ;
62 INT8U idata s_end ;
63 INT8U k ;
64
65 INT8U idata receive[RECE_SIZE];
66 INT8U idata r_start ;
67 //INT8U idata r_end ;
68 INT8U idata intcounter ; //timer0 interrupt counter
69
70 /* Functions declared */
71
72 void InitIOPort(void); // initialize I/O ports
73 void Square_Wave(void); // generate 500us square wave on P1.2
74 void Initial_Timer0(void); // initialize Timer0
75 void Time0_Interrupt(void); // interrupt subroutine
76 void delay(void); // delay subroutine
77 void A_D(void); // AD subroutine
78 //INT16U Serial(void); // serial port subroutine
79 void Serial_s(void);
80 void Serial_r(void);
81 void Serial_init(void);
82 void main(void)
83 {
84 1 // INT16U UIntForwardSteps1,UIntForwardSteps2,UIntCounter;
85 1 Serial_init();
86 1 Initial_Timer0();
87 1 for(;;){
88 2 Deferent_Ready=False; // workpiece ready flag
89 2 ES=1;
90 2 // Deferent_Ready=True;
91 2 // UIntForwardSteps = 28000; // steps per circle 28000
92 2 // UIntForwardSteps1 = 14; // steps from ready position to measure position 14000
93 2 // UIntForwardSteps2 = UIntForwardSteps-UIntForwardSteps1;
94 2
95 2 while(Deferent_Ready==False) ;
96 2 //UIntForwardSteps1=receive[0]+256*receive[1] ;
97 2 //UIntForwardSteps2 = UIntForwardSteps-UIntForwardSteps1;
98 2 ES=0;
99 2 for(UIntCounter=0;UIntCounter<=UIntForwardSteps1;++UIntCounter)
100 2 {
101 3 Square_Wave();
102 3 }
103 2 // delay(); // delay for workpieces to be measured
104 2 // A_D();
105 2 // Serial_s();
106 2 // INT8U k ;
107 2 for(k=0;k<20;k++)
108 2 { for(UIntCounter=0;UIntCounter<=iUIntForwardSteps;++UIntCounter)
109 3 {
C51 COMPILER V7.07 WORKING 09/25/2006 10:39:22 PAGE 3
110 4 Square_Wave();
111 4 }
112 3 delay(); // delay for workpieces to be measured
113 3 A_D();
114 3 Serial_s();
115 3 }
116 2 for(UIntCounter=0;UIntCounter<=UIntForwardSteps2;++UIntCounter)
117 2 {
118 3 Square_Wave();
119 3 }
120 2 Deferent_Ready=False;
121 2
122 2 SBUF='C';
123 2 while(TI==0);TI = 0;
124 2 SBUF='E';
125 2 while(TI==0);TI = 0;
126 2
127 2 while(RI==0);RI=0; // wait for PC reply ‘R’
128 2 while(SBUF!=0x52);
129 2 //ES=1;
130 2 }
131 1
132 1 }
133 /*$PAGE*/
134 /*
135 ******************************************************************************
136 Function name : InitIOPort
137 Description : initialize whole IO port Parameters
138
139 Input param : none.
140
141 Output param : none.
142
143 return : none
144 ******************************************************************************
145 */
146 void InitIOPort(void)
147 {
148 1 P1_0 = 0;
149 1 P0 = 1;
150 1
151 1 }
152 /*
153 **********************************************************************************************************
-********
154 * SQUARE WAVE GENERATE
155 * Description: Interrupt mode generate 0.25ms square wave on P1.2 to drive electromotor
156 *
157 * Arguments : none
158 *
159 * Returns : none
160 **********************************************************************************************************
-*******
161 */
162 void Square_Wave()
163 {
164 1 P1_0=0; //interrupt mode generate 0.5ms squre wave
165 1 intcounter=0;
166 1 TR0=1;
167 1 ET0=1;
168 1 EA=1;
169 1 while(intcounter!=2);
C51 COMPILER V7.07 WORKING 09/25/2006 10:39:22 PAGE 4
170 1 TR0=0;
171 1 ET0=0;
172 1
173 1 }
174 /*$PAGE*/
175 /*
176 **********************************************************************************************************
-********
177 * INITIALIZE TIMEER0
178 * Description: none
179 *
180 * Arguments : none
181 *
182 * Returns : none
183 **********************************************************************************************************
-*******
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -