-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMAIN.LST
executable file
·376 lines (363 loc) · 16.1 KB
/
MAIN.LST
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
C166 COMPILER V7.00, MAIN 03/15/2019 15:27:40 PAGE 1
C166 COMPILER V7.00, COMPILATION OF MODULE MAIN
OBJECT MODULE PLACED IN MAIN.OBJ
COMPILER INVOKED BY: F:\Softeware\Fury\Keil\C166\BIN\C166.EXE MAIN.C MODV2 BROWSE MODV2 DEBUG
stmt lvl source
1 //****************************************************************************
2 // @Module Project Settings
3 // @Filename MAIN.C
4 // @Project test3.dav
5 //----------------------------------------------------------------------------
6 // @Controller Infineon XC2267M-104F80
7 //
8 // @Compiler Keil
9 //
10 // @Codegenerator 2.0
11 //
12 // @Description This file contains the project initialization function.
13 //
14 //----------------------------------------------------------------------------
15 // @Date 2018/11/1 16:59:43
16 //
17 //****************************************************************************
18
19 // USER CODE BEGIN (MAIN_General,1)
20
21 // USER CODE END
22
23
24
25 //****************************************************************************
26 // @Project Includes
27 //****************************************************************************
28
29 #include "MAIN.H"
30
31 // USER CODE BEGIN (MAIN_General,2)
32
33 // USER CODE END
34
35
36 //****************************************************************************
37 // @Macros
38 //****************************************************************************
39
40 // USER CODE BEGIN (MAIN_General,3)
41
42 // USER CODE END
43
44
45 //****************************************************************************
46 // @Defines
47 //****************************************************************************
48
49 // USER CODE BEGIN (MAIN_General,4)
50
51 // USER CODE END
52
53
54 //****************************************************************************
55 // @Typedefs
C166 COMPILER V7.00, MAIN 03/15/2019 15:27:40 PAGE 2
56 //****************************************************************************
57
58 // USER CODE BEGIN (MAIN_General,5)
59
60 // USER CODE END
61
62
63 //****************************************************************************
64 // @Imported Global Variables
65 //****************************************************************************
66
67 // USER CODE BEGIN (MAIN_General,6)
68
69 // USER CODE END
70
71
72 //****************************************************************************
73 // @Global Variables
74 //****************************************************************************
75
76 // USER CODE BEGIN (MAIN_General,7)
77
78 // USER CODE END
79
80
81 //****************************************************************************
82 // @External Prototypes
83 //****************************************************************************
84
85 // USER CODE BEGIN (MAIN_General,8)
86
87 // USER CODE END
88
89
90 //****************************************************************************
91 // @Prototypes Of Local Functions
92 //****************************************************************************
93
94 // USER CODE BEGIN (MAIN_General,9)
95
96 // USER CODE END
97
98
99 //****************************************************************************
100 // @Function void MAIN_vInit(void)
101 //
102 //----------------------------------------------------------------------------
103 // @Description This function initializes the microcontroller.
104 //
105 //----------------------------------------------------------------------------
106 // @Returnvalue None
107 //
108 //----------------------------------------------------------------------------
109 // @Parameters None
110 //
111 //----------------------------------------------------------------------------
112 // @Date 2018/11/1
113 //
114 //****************************************************************************
115
116 // USER CODE BEGIN (Init,1)
117
C166 COMPILER V7.00, MAIN 03/15/2019 15:27:40 PAGE 3
118 ubyte can1_send2[8]={0xa0,0x73,0x00,0x00,0x02,0x02,0x00,0x00}; //VCU向电机控制器发送转矩或转速指令
119 /*
120 百分比 10% 20% 30% 40% 50% 60% 70% 80% 90% 99%
121 加权值 33 65 98 130 163 192 228 261 294 327
122 */
123 int gear=1,gearWeight=1;
124
125 // USER CODE END
126
127 void MAIN_vInit(void)
128 {
129 1
130 1 SCS_ErrorType Error;
131 1
132 1 // USER CODE BEGIN (Init,2)
133 1
134 1 // USER CODE END
135 1
136 1 // globally disable interrupts
137 1 PSW_IEN = 0;
138 1
139 1 /// -----------------------------------------------------------------------
140 1 /// Configuration of the System Clock:
141 1 /// -----------------------------------------------------------------------
142 1 /// - VCO clock used, input clock is connected
143 1 /// - input frequency is 8.00 MHz
144 1 /// - configured system frequency is 80.00 MHz
145 1 /// - system clock is 80.00MHz
146 1
147 1 MAIN_vUnlockProtecReg(); // unlock write security
148 1
149 1 // initialize CCU6 timer T13 for SCS driver
150 1 SCS_InitTimer();
151 1
152 1 // perform transition from base mode to normal operating mode
153 1 Error = SCS_GoFromBaseToNormalMode();
154 1
155 1 // restore CCU6 timer used by SCS driver
156 1 SCS_RestoreTimer();
157 1
158 1 // -----------------------------------------------------------------------
159 1 // Initialization of the Peripherals:
160 1 // -----------------------------------------------------------------------
161 1
162 1 // initializes the Parallel Ports
163 1 IO_vInit();
164 1
165 1 // initializes the General Purpose Timer Unit (GPT1)
166 1 GPT1_vInit();
167 1
168 1 // initializes the General Purpose Timer Unit (GPT2)
169 1 GPT2_vInit();
170 1
171 1 // initializes the Analog / Digital Converter (ADC1)
172 1 ADC1_vInit();
173 1
174 1 // initializes the MultiCAN Module (CAN)
175 1 CAN_vInit();
176 1
177 1
178 1 // -----------------------------------------------------------------------
179 1 // Initialization of the Bank Select registers:
C166 COMPILER V7.00, MAIN 03/15/2019 15:27:40 PAGE 4
180 1 // -----------------------------------------------------------------------
181 1
182 1
183 1 // USER CODE BEGIN (Init,3)
184 1
185 1 // USER CODE END
186 1
187 1 MAIN_vLockProtecReg(); // lock write security
188 1
189 1 // globally enable interrupts
190 1 PSW_IEN = 1;
191 1
192 1 } // End of function MAIN_vInit
193
194
195 //****************************************************************************
196 // @Function void MAIN_vUnlockProtecReg(void)
197 //
198 //----------------------------------------------------------------------------
199 // @Description This function makes it possible to write one protected
200 // register.
201 //
202 //----------------------------------------------------------------------------
203 // @Returnvalue None
204 //
205 //----------------------------------------------------------------------------
206 // @Parameters None
207 //
208 //----------------------------------------------------------------------------
209 // @Date 2018/11/1
210 //
211 //****************************************************************************
212
213 // USER CODE BEGIN (UnlockProtecReg,1)
214
215 // USER CODE END
216
217 void MAIN_vUnlockProtecReg(void)
218 {
219 1
220 1 SCU_SLC = 0xAAAA; // command 0
221 1 SCU_SLC = 0x5554; // command 1
222 1 SCU_SLC = 0x96FF; // command 2
223 1 SCU_SLC = 0x0000; // command 3
224 1
225 1 } // End of function MAIN_vUnlockProtecReg
226
227
228 //****************************************************************************
229 // @Function void MAIN_vLockProtecReg(void)
230 //
231 //----------------------------------------------------------------------------
232 // @Description This function makes it possible to lock one protected
233 // register.
234 //
235 //----------------------------------------------------------------------------
236 // @Returnvalue None
237 //
238 //----------------------------------------------------------------------------
239 // @Parameters None
240 //
241 //----------------------------------------------------------------------------
C166 COMPILER V7.00, MAIN 03/15/2019 15:27:40 PAGE 5
242 // @Date 2018/11/1
243 //
244 //****************************************************************************
245
246 // USER CODE BEGIN (LockProtecReg,1)
247
248 // USER CODE END
249
250 void MAIN_vLockProtecReg(void)
251 {
252 1
253 1 SCU_SLC = 0xAAAA; // command 0
254 1 SCU_SLC = 0x5554; // command 1
255 1 SCU_SLC = 0x96FF; // command 2
256 1 SCU_SLC = 0x1800; // command 3;
257 1 SCU_SLC = 0x8EFF; // command 4
258 1
259 1 } // End of function MAIN_vLockProtecReg
260
261
262 //****************************************************************************
263 // @Function void main(void)
264 //
265 //----------------------------------------------------------------------------
266 // @Description This is the main function.
267 //
268 //----------------------------------------------------------------------------
269 // @Returnvalue None
270 //
271 //----------------------------------------------------------------------------
272 // @Parameters None
273 //
274 //----------------------------------------------------------------------------
275 // @Date 2018/11/1
276 //
277 //****************************************************************************
278
279 // USER CODE BEGIN (Main,1)
280
281 // USER CODE END
282
283 void main(void)
284 {
285 1 // USER CODE BEGIN (Main,2)
286 1
287 1 // USER CODE END
288 1
289 1 MAIN_vInit();
290 1
291 1 // USER CODE BEGIN (Main,3)
292 1 /*
293 1 百分比 10% 20% 30% 40% 50% 60% 70% 80% 90% 99%
294 1 加权值 33 65 98 130 163 192 228 261 294 327
295 1 */
296 1 if(P5_IN_P10==1&&P5_IN_P11==1&&P5_IN_P13==1&&P5_IN_P15==1) {gear=1; gearWeight=2;} //20%
297 1 else if(P5_IN_P10==0&&P5_IN_P11==1&&P5_IN_P13==1&&P5_IN_P15==1) {gear=2; gearWeight=4;} //40%
298 1 else if(P5_IN_P10==1&&P5_IN_P11==0&&P5_IN_P13==1&&P5_IN_P15==1) {gear=3; gearWeight=6;} //60%
299 1 else if(P5_IN_P10==1&&P5_IN_P11==1&&P5_IN_P13==0&&P5_IN_P15==1) {gear=4; gearWeight=8;} //70%
300 1 else if(P5_IN_P10==1&&P5_IN_P11==1&&P5_IN_P13==1&&P5_IN_P15==0) {gear=5; gearWeight=9;} //80%
301 1 else if(P5_IN_P10==0&&P5_IN_P11==0&&P5_IN_P13==0&&P5_IN_P15==0) {gear=6; gearWeight=10;} //99%
302 1
303 1 else {gear=1; gearWeight=2;}
C166 COMPILER V7.00, MAIN 03/15/2019 15:27:40 PAGE 6
304 1
305 1 // USER CODE END
306 1
307 1 while(1)
308 1 {
309 2
310 2 // USER CODE BEGIN (Main,4)
311 2
312 2
313 2 // P10_OUT_P4=1;
314 2
315 2 // if(P7_IN_P2 == 0){
316 2 // P0_OUT_P5 = 1; //高边开关2 待驶指示灯亮
317 2 // P10_OUT_P3 = 1; //高边开关1 鸣笛开
318 2 // }
319 2 // else{
320 2 // P0_OUT_P5 = 0; //高边开关2 待驶指示灯灭
321 2 // P10_OUT_P3 = 0; //高边开关1 鸣笛关
322 2 // }
323 2
324 2
325 2 // USER CODE END
326 2
327 2 }
328 1
329 1 } // End of function main
330
331
332
333 // USER CODE BEGIN (MAIN_General,10)
334
335 // USER CODE END
336
MODULE INFORMATION: INITIALIZED UNINITIALIZED
CODE SIZE = 380 --------
NEAR-CONST SIZE = -------- --------
FAR-CONST SIZE = -------- --------
HUGE-CONST SIZE = -------- --------
XHUGE-CONST SIZE = -------- --------
NEAR-DATA SIZE = 12 --------
FAR-DATA SIZE = -------- --------
XHUGE-DATA SIZE = -------- --------
IDATA-DATA SIZE = -------- --------
SDATA-DATA SIZE = -------- --------
BDATA-DATA SIZE = -------- --------
HUGE-DATA SIZE = -------- --------
BIT SIZE = -------- --------
INIT'L SIZE = 24 --------
END OF MODULE INFORMATION.
C166 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)