📄 main.lst
字号:
C51 COMPILER V7.04 MAIN 01/23/2007 12:25:24 PAGE 1
C51 COMPILER V7.04, COMPILATION OF MODULE MAIN
OBJECT MODULE PLACED IN main.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE main.c OPTIMIZE(7,SPEED) BROWSE DEBUG OBJECTEXTEND CODE
stmt level source
1 #include <common.h>
2 #include <head.h>
3 #include <STDIO.H>
4
5 void InitTimer( void )
6 {
7 1 // 定时器0停止
8 1 TR0 = 0;
9 1 TR1 = 0;
10 1
11 1 TMOD = 0x11; // 16位计数定时
12 1
13 1 PT0 = 1; // 定时器0高优先级
14 1 ET0 = 1; // 允许定时器0中断
15 1
16 1 PT1 = 1; // 定时器1高优先级
17 1 ET1 = 1; // 允许定时器1中断
18 1
19 1 EA = 1; // 开启中断
20 1 }
21
22 //u_char code cmd[] = "%01W1110013880000c35000$";
23
24 // 主程序
25 void main( void )
26 {
27 1 u_char idx;
28 1 u_short ledcnt;
29 1
30 1 ledcnt = 65535;
31 1 while( ledcnt )
32 1 {
33 2 ledcnt--;
34 2 ledcnt++;
35 2 ledcnt--;
36 2 };
37 1
38 1 P0 = 0xff;
39 1 P1 = 0xff;
40 1 P2 = 0xff;
41 1 P3 = 0xff;
42 1
43 1 // 开启内部RAM
44 1 // CHPENR = 0x87;
45 1 // CHPENR = 0x59;
46 1 // CHPCON |= 0x10;
47 1 // CHPENR = 0;
48 1
49 1 InitTimer( );
50 1 EnableSerialComm( );
51 1 /*
52 1 CommBuf.MsgCnt = 0;
53 1 for( idx = 0; idx < 21; idx++ )
54 1 {
55 1 CommBuf.MsgData[idx] = cmd[idx];
C51 COMPILER V7.04 MAIN 01/23/2007 12:25:24 PAGE 2
56 1 CommBuf.MsgCnt++;
57 1 }
58 1 idx = CalCheckCode( CommBuf.MsgData, CommBuf.MsgCnt );
59 1 CommBuf.MsgData[CommBuf.MsgCnt] = ToHexchar( idx >> 4 );
60 1 CommBuf.MsgCnt++;
61 1 CommBuf.MsgData[CommBuf.MsgCnt] = ToHexchar( idx );
62 1 CommBuf.MsgCnt++;
63 1 CommBuf.MsgData[CommBuf.MsgCnt] = '$';
64 1 CommBuf.MsgCnt++;
65 1 RecvOkFlag = 1;
66 1 */
67 1 for ( ; ; )
68 1 {
69 2 // 运行指示灯
70 2 ledcnt++;
71 2 if ( ledcnt >= 5000 )
72 2 {
73 3 ledcnt = 0;
74 3 LED = ~LED;
*** ERROR C202 IN LINE 74 OF MAIN.C: 'P3_2': undefined identifier
75 3 }
76 2
77 2 // 接收数据处理
78 2 RecvMsgProce( );
79 2
80 2 // 启动电机
81 2 StartMotor( );
82 2
83 2 // 如果定时器0已启动
84 2 if ( Timer[0].MotorIdx )
85 2 {
86 3 idx = Timer[0].MotorIdx - 1;
87 3
88 3 // 升降速方式
89 3 if ( MotorStatus[idx].UpDwon )
90 3 {
91 4 // 已到达设定频率
92 4 if ( MotorStatus[idx].Status & PLUSE_TO_FLAG_MASK )
93 4 {
94 5 // 无减速标志
95 5 if ( !(MotorStatus[idx].Status & FREQ_DWON_MASK) )
96 5 {
97 6 if ( Timer[0].CurPluseNum < Timer[0].DwonPluse )
98 6 MotorStatus[idx].Status |= FREQ_DWON_MASK;
99 6 }
100 5 else
101 5 {
102 6 if ( !Timer[0].SecConstFlag && !Timer[0].UpDwonCnt )
103 6 {
104 7 Timer[0].UpDwonCnt = (MotorStatus[idx].UpDwon & 0x0f) << 1;
105 7 Timer[0].CurFreq -= Timer[0].FreqInc;
106 7 if ( Timer[0].CurFreq < START_FREQ )
107 7 Timer[0].CurFreq = START_FREQ;
108 7
109 7 CalSecFreqTimerConst( 0 );
110 7 }
111 6 }
112 5 }
113 4 else
114 4 {
115 5 // 未到达设定频率
116 5 if ( Timer[0].CurFreq < MotorStatus[idx].SetFreq )
C51 COMPILER V7.04 MAIN 01/23/2007 12:25:24 PAGE 3
117 5 {
118 6 if ( !Timer[0].SecConstFlag && !Timer[0].UpDwonCnt )
119 6 {
120 7 Timer[0].UpDwonCnt = (MotorStatus[idx].UpDwon & 0x0f) << 1;
121 7 Timer[0].CurFreq += Timer[0].FreqInc;
122 7 if ( Timer[0].CurFreq >= MotorStatus[idx].SetFreq )
123 7 {
124 8 Timer[0].CurFreq = MotorStatus[idx].SetFreq;
125 8 MotorStatus[idx].Status |= PLUSE_TO_FLAG_MASK;
126 8 // Timer[0].DwonPluse 暂存启动总脉冲
127 8 if ( (long)MotorStatus[idx].TotalPluseCnt > (long)Timer[0].DwonPluse )
128 8 Timer[0].DwonPluse = MotorStatus[idx].TotalPluseCnt - Timer[0].DwonPluse;
129 8 else
130 8 Timer[0].DwonPluse -= MotorStatus[idx].TotalPluseCnt;
131 8 }
132 7
133 7 CalSecFreqTimerConst( 0 );
134 7 }
135 6 }
136 5 }
137 4 }
138 3 else
139 3 {
140 4 // 非升降速,如果频率已改变
141 4 if ( Timer[0].CurFreq != MotorStatus[idx].SetFreq )
142 4 {
143 5 if ( !Timer[0].SecConstFlag )
144 5 {
145 6 Timer[0].CurFreq = MotorStatus[idx].SetFreq;
146 6 CalSecFreqTimerConst( 0 );
147 6 }
148 5 }
149 4 }
150 3 }
151 2
152 2 // 如果定时器1已启动
153 2 if ( Timer[1].MotorIdx )
154 2 {
155 3 idx = Timer[1].MotorIdx - 1;
156 3
157 3 // 升降速方式
158 3 if ( MotorStatus[idx].UpDwon )
159 3 {
160 4 // 已到达设定频率
161 4 if ( MotorStatus[idx].Status & PLUSE_TO_FLAG_MASK )
162 4 {
163 5 // 无减速标志
164 5 if ( !(MotorStatus[idx].Status & FREQ_DWON_MASK) )
165 5 {
166 6 if ( Timer[1].CurPluseNum < Timer[1].DwonPluse )
167 6 MotorStatus[idx].Status |= FREQ_DWON_MASK;
168 6 }
169 5 else
170 5 {
171 6 if ( !Timer[1].SecConstFlag && !Timer[1].UpDwonCnt )
172 6 {
173 7 Timer[1].UpDwonCnt = (MotorStatus[idx].UpDwon & 0x0f) << 1;
174 7 Timer[1].CurFreq -= Timer[1].FreqInc;
175 7 if ( Timer[1].CurFreq < START_FREQ )
176 7 Timer[1].CurFreq = START_FREQ;
177 7
178 7 CalSecFreqTimerConst( 1 );
C51 COMPILER V7.04 MAIN 01/23/2007 12:25:24 PAGE 4
179 7 }
180 6 }
181 5 }
182 4 else
183 4 {
184 5 // 未到达设定频率
185 5 if ( Timer[1].CurFreq < MotorStatus[idx].SetFreq )
186 5 {
187 6 if ( !Timer[1].SecConstFlag && !Timer[1].UpDwonCnt )
188 6 {
189 7 Timer[1].UpDwonCnt = (MotorStatus[idx].UpDwon & 0x0f) << 1;
190 7 Timer[1].CurFreq += Timer[1].FreqInc;
191 7 if ( Timer[1].CurFreq >= MotorStatus[idx].SetFreq )
192 7 {
193 8 Timer[1].CurFreq = MotorStatus[idx].SetFreq;
194 8 MotorStatus[idx].Status |= PLUSE_TO_FLAG_MASK;
195 8
196 8 if ( (long)MotorStatus[idx].TotalPluseCnt > (long)Timer[1].DwonPluse )
197 8 Timer[1].DwonPluse = MotorStatus[idx].TotalPluseCnt - Timer[1].DwonPluse;
198 8 else
199 8 Timer[1].DwonPluse -= MotorStatus[idx].TotalPluseCnt;
200 8 }
201 7
202 7 CalSecFreqTimerConst( 1 );
203 7 }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -