📄 main.ls
字号:
1 ; C Compiler for ST7 (COSMIC Software)
2 ; Generator V4.4a - 17 Dec 2001
3 ; Optimizer V4.2g - 21 Dec 2001
5 switch .data
6 0000 _KEY_CODE:
7 0000 00 dc.b 0
73 ; 57 void main(void)
73 ; 58 {
74 .text: section .text,new
75 0000 _main:
78 0000 L34:
79 ; 59 while ( !WWD_Init() );
81 0000 cd0000 call _WWD_Init
83 0003 4d tnz a
84 0004 27fa jreq L34
85 ; 60 ST7_IntPrioritySetUp();
87 0006 cd0000 call _ST7_IntPrioritySetUp
89 ; 62 State = IDLE;
91 0009 4f clr a
92 000a c70002 ld L3_State,a
93 ; 63 Power_Motor_Status = 0;
95 000d c70000 ld _Power_Motor_Status,a
96 ; 64 start_counter = 0;
98 0010 c70001 ld _start_counter,a
99 ; 65 stall_counter = 0;
101 0013 c70000 ld _stall_counter,a
102 ; 67 SCI_Config();
104 0016 cd0000 call _SCI_Config
106 ; 68 PORTS_Init(); // initialize I/O
108 0019 cd0000 call _PORTS_Init
110 ; 69 TIMA_Config(); // initialize TIMER B peripheral
112 001c cd0000 call _TIMA_Config
114 ; 70 SPI_Init();
116 001f cd0000 call _SPI_Init
118 ; 72 MTC_InitPeripheral(); // Initialize peripheral for Sensorless BLDC drive
120 0022 cd0000 call _MTC_InitPeripheral
122 ; 73 EnableInterrupts();
125 0025 9a rim
127 ; 74 PORTS_LedOn();
130 0026 cd0000 call _PORTS_LedOn
132 0029 L74:
133 ; 78 if (Chk_Timer_WDG_Elapsed() == TRUE) WWD_Refresh();
135 0029 cd0000 call _Chk_Timer_WDG_Elapsed
137 002c a101 cp a,#1
138 002e 2603 jrne L35
141 0030 cd0000 call _WWD_Refresh
143 0033 L35:
144 ; 81 if (SCI_IsReceptionCompleted() == TRUE) Resert_SCIRX_Watchdog();
146 0033 cd0000 call _SCI_IsReceptionCompleted
148 0036 a101 cp a,#1
149 0038 2603 jrne L55
152 003a cd0000 call _Resert_SCIRX_Watchdog
154 003d L55:
155 ; 83 SCI_Send_Data(); // SCI TX
157 003d cd0000 call _SCI_Send_Data
159 ; 85 if ((Get_TargetSpeed() < Freq_Min) || (Get_TargetSpeed() > Freq_Max))
161 0040 cd0000 call _Get_TargetSpeed
163 0043 a090 sub a,#144
164 0045 9f ld a,x
165 0046 a201 sbc a,#1
166 0048 250a jrult L16
168 004a cd0000 call _Get_TargetSpeed
170 004d a061 sub a,#97
171 004f 9f ld a,x
172 0050 a209 sbc a,#9
173 0052 2529 jrult L75
174 0054 L16:
175 ; 87 MotorCmd = STOP_CMD;
177 0054 4f clr a
178 0055 c70000 ld _MotorCmd,a
179 ; 88 MotorStatus=0;
181 0058 3f00 clr _MotorStatus
182 ; 89 MotorStatus_Backup = 0;
184 005a c70000 ld _MotorStatus_Backup,a
185 ; 90 start_counter = 0; // prepare for the start counter
187 005d c70001 ld _start_counter,a
188 ; 91 stall_counter = 0; // prepare for the stall counter
190 0060 c70000 ld _stall_counter,a
191 ; 92 timer_after_start = 1000; // prepare for the start-up failure
193 0063 ae03 ld x,#3
194 0065 cf0000 ld _timer_after_start,x
195 0068 a6e8 ld a,#232
196 006a c70001 ld _timer_after_start+1,a
198 006d L36:
199 ; 101 Chk_Power_Motor_Status();
201 006d cd0000 call _Chk_Power_Motor_Status
203 ; 103 if ((MotorStatus & FAULT_MSK) != 0) State = FAULT; // MOTOR_STALLED
205 0070 b600 ld a,_MotorStatus
206 0072 a5f0 bcp a,#240
207 0074 2714 jreq L76
210 0076 a606 ld a,#6
211 0078 c70002 ld L3_State,a
212 007b 200d jra L76
213 007d L75:
214 ; 96 if ((MotorStatus & FAULT_MSK) == 0)
216 007d b600 ld a,_MotorStatus
217 007f a5f0 bcp a,#240
218 0081 26ea jrne L36
219 ; 97 MotorCmd = START_CMD;
221 0083 a6ff ld a,#255
222 0085 c70000 ld _MotorCmd,a
223 0088 20e3 jra L36
224 008a L76:
225 ; 106 switch (State)
227 008a c60002 ld a,L3_State
229 008d 2718 jreq L5
230 008f 4a dec a
231 0090 272d jreq L7
232 0092 4a dec a
233 0093 2739 jreq L11
234 0095 4a dec a
235 0096 2603cc0192 jreq L51
236 009b 4a dec a
237 009c 2603cc017e jreq L31
238 00a1 4a dec a
239 00a2 2785 jreq L74
240 00a4 cc01a3 jra L12
241 00a7 L5:
242 ; 108 case IDLE:
242 ; 109 if ((MotorCmd == START_CMD) && (Timer_RestartTimerBegin() == FALSE))
244 00a7 c60000 ld a,_MotorCmd
245 00aa a1ff cp a,#255
246 00ac 2703cc0029 jrne L74
248 00b1 cd0000 call _Timer_RestartTimerBegin
250 00b4 4d tnz a
251 00b5 26f7 jrne L74
252 ; 111 State = START;
254 00b7 a601 ld a,#1
255 00b9 c70002 ld L3_State,a
256 00bc cc0029 jra L74
257 00bf L7:
258 ; 115 case START:
258 ; 116 if (MTC_StartMotor() == TRUE) State = RUN;
260 00bf cd0000 call _MTC_StartMotor
262 00c2 a101 cp a,#1
263 00c4 26f6 jrne L74
266 00c6 a602 ld a,#2
267 00c8 c70002 ld L3_State,a
268 00cb cc0029 jra L74
269 00ce L11:
270 ; 120 case RUN:
270 ; 121 // PORTS_LedOff();
270 ; 122 if (GetMotorStatus() & START_UP_FAILED) // start is failed
272 00ce cd0000 call _GetMotorStatus
274 00d1 a540 bcp a,#64
275 00d3 2728 jreq L101
276 ; 124 start_counter++;
278 00d5 c60001 ld a,_start_counter
279 00d8 4c inc a
280 00d9 c70001 ld _start_counter,a
281 ; 125 if (start_counter >= 0x03) // restarting times is high than 3
283 00dc a103 cp a,#3
284 00de 250c jrult L301
285 ; 127 State = FAULT;
287 00e0 a606 ld a,#6
288 00e2 c70002 ld L3_State,a
289 ; 128 start_counter = 0; // prepare for the start counter
291 00e5 4f clr a
292 00e6 c70001 ld _start_counter,a
294 00e9 cc0029 jra L74
295 00ec L301:
296 ; 132 MTC_StopMotor(); // prepare for starting again
298 00ec cd0000 call _MTC_StopMotor
300 ; 133 if ((u8)(GetMotorStatus() & FAULT_MSK) == 0) State = IDLE;
302 00ef cd0000 call _GetMotorStatus
304 00f2 a5f0 bcp a,#240
305 00f4 26f3 jrne L74
308 00f6 4f clr a
309 00f7 c70002 ld L3_State,a
310 00fa cc0029 jra L74
311 00fd L101:
312 ; 138 Chk_Motor_Stalled();
314 00fd cd0000 call _Chk_Motor_Stalled
316 ; 139 if ((GetMotorStatus() & MOTOR_STALLED) != 0) // motor stalled
318 0100 cd0000 call _GetMotorStatus
320 0103 a510 bcp a,#16
321 0105 2745 jreq L111
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -