📄 main.lst
字号:
230 1
231 1 /// ---------------------------------------------------------------------
232 1 /// Initialization of the SYSCON0 Register:
233 1 /// ---------------------------------------------------------------------
234 1
235 1 //// this register must be set in the start-up file
236 1 //// SYSCON0 = 0x0000
237 1
238 1 /// ---------------------------------------------------------------------
239 1 /// Initialization of the SYSCON1 Register:
240 1 /// ---------------------------------------------------------------------
241 1 /// clock prescaler for system is fpll / 1
C166 COMPILER V6.04, MAIN 03/25/2008 10:21:40 PAGE 5
242 1
243 1 //// this register must be set in the start-up file
244 1 //// SYSCON1 = 0x0000
245 1
246 1 /// ---------------------------------------------------------------------
247 1 /// Initialization of the SYSCON3 Register:
248 1 /// ---------------------------------------------------------------------
249 1
250 1 //// this register must be set in the start-up file
251 1 //// SYSCON3 = 0x0000
252 1
253 1 /// ---------------------------------------------------------------------
254 1 /// Initialization of EBC
255 1 /// ---------------------------------------------------------------------
256 1
257 1 //// this register must be set in the start-up file
258 1 //// EBCMOD1 = 0x0000
259 1
260 1 /// EBC is enabled
261 1 /// pin #BHE is enabled
262 1 /// #WR and #BHE retain their normal function
263 1 /// pin ALE is enabled
264 1 /// as segment address are 2 pins enabled ( A[17] .. A[16] )
265 1 /// #CS2 .. #CS0 are enabled
266 1 /// pin #READY is disabled
267 1 /// bus arbitration is disabled, P6.7 .. P6.5 may used for general
268 1 /// purpose IO
269 1
270 1 //// this register must be set in the start-up file
271 1 //// EBCMOD0 = 0x4032
272 1
273 1 /// ---------------------------------------------------------------------
274 1 /// ---------- chip select 0 is enabled ----------
275 1 /// ---------------------------------------------------------------------
276 1 /// - 16-bit Demultiplexed Bus
277 1 /// access time is controlled by bitfield PHE0
278 1
279 1 //// this register must be set in the start-up file
280 1 //// FCONCS0 = 0x0021
281 1
282 1 /// Phase A: 3 clock cycles
283 1 /// Phase B: 1 clock cycles
284 1 /// Phase C: 0 clock cycles
285 1 /// Phase D: 0 clock cycles
286 1 /// Phase E: 10 clock cycles
287 1 /// Read Phase F: 0 clock cycles
288 1 /// Write Phase F: 3 clock cycles
289 1
290 1 //// this register must be set in the start-up file
291 1 //// TCONCS0 = 0x6243
292 1
293 1 /// ---------------------------------------------------------------------
294 1 /// ---------- chip select 1 is disabled ----------
295 1 /// ---------------------------------------------------------------------
296 1
297 1
298 1 /// ---------------------------------------------------------------------
299 1 /// ---------- chip select 2 is disabled ----------
300 1 /// ---------------------------------------------------------------------
301 1
302 1
303 1 /// ---------------------------------------------------------------------
C166 COMPILER V6.04, MAIN 03/25/2008 10:21:40 PAGE 6
304 1 /// ---------- chip select 3 is disabled ----------
305 1 /// ---------------------------------------------------------------------
306 1
307 1
308 1 /// ---------------------------------------------------------------------
309 1 /// ---------- chip select 4 is disabled ----------
310 1 /// ---------------------------------------------------------------------
311 1
312 1
313 1 //// -----------------------------------------------------------------------
314 1 //// End of Important Settings for the Start-Up File
315 1 //// -----------------------------------------------------------------------
316 1
317 1
318 1 // -----------------------------------------------------------------------
319 1 // Initialization of the Peripherals:
320 1 // -----------------------------------------------------------------------
321 1
322 1 // initializes the Parallel Ports
323 1 IO_vInit();
324 1
325 1 // USER CODE BEGIN (Init,3)
326 1
327 1 // USER CODE END
328 1
329 1 // globally enable interrupts
330 1 PSW_IEN = 1;
331 1
332 1 } // End of function MAIN_vInit
333
334
335 //****************************************************************************
336 // @Function void MAIN_vUnlockProtecReg(void)
337 //
338 //----------------------------------------------------------------------------
339 // @Description This function makes it possible to write one protected
340 // register. After calling of this function and write on the
341 // protected register is the security level set to low
342 // protected mode.
343 //
344 //----------------------------------------------------------------------------
345 // @Returnvalue None
346 //
347 //----------------------------------------------------------------------------
348 // @Parameters None
349 //
350 //----------------------------------------------------------------------------
351 // @Date 2007-4-3
352 //
353 //****************************************************************************
354
355 // USER CODE BEGIN (UnlockProtecReg,1)
356
357 // USER CODE END
358
359 void MAIN_vUnlockProtecReg(void)
360 {
361 1 uword uwPASSWORD;
362 1
363 1 if((SCUSLS & 0x1800) == 0x0800) // if low protected mode
364 1 {
365 2
C166 COMPILER V6.04, MAIN 03/25/2008 10:21:40 PAGE 7
366 2 uwPASSWORD = SCUSLS & 0x00FF;
367 2 uwPASSWORD = (~uwPASSWORD) & 0x00FF;
368 2 SCUSLC = 0x8E00 | uwPASSWORD; // command 4
369 2
370 2 } // end if low protected mode
371 1
372 1 if((SCUSLS & 0x1800) == 0x1800) // if write protected mode
373 1 {
374 2 SCUSLC = 0xAAAA; // command 0
375 2 SCUSLC = 0x5554; // command 1
376 2
377 2 uwPASSWORD = SCUSLS & 0x00FF;
378 2 uwPASSWORD = (~uwPASSWORD) & 0x00FF;
379 2
380 2 SCUSLC = 0x9600 | uwPASSWORD; // command 2
381 2 SCUSLC = 0x0800; // command 3; new PASSWOR is 0x00
382 2
383 2 uwPASSWORD = SCUSLS & 0x00FF;
384 2 uwPASSWORD = (~uwPASSWORD) & 0x00FF;
385 2 SCUSLC = 0x8E00 | uwPASSWORD; // command 4
386 2
387 2 } // end if write protected mode
388 1
389 1 } // End of function MAIN_vUnlockProtecReg
390
391
392 //****************************************************************************
393 // @Function void main(void)
394 //
395 //----------------------------------------------------------------------------
396 // @Description This is the main function.
397 //
398 //----------------------------------------------------------------------------
399 // @Returnvalue None
400 //
401 //----------------------------------------------------------------------------
402 // @Parameters None
403 //
404 //----------------------------------------------------------------------------
405 // @Date 2007-4-3
406 //
407 //****************************************************************************
408
409 // USER CODE BEGIN (Main,1)
410
411 // USER CODE END
412
413 void main(void)
414 {
415 1 // USER CODE BEGIN (Main,2)
416 1
417 1 // USER CODE END
418 1
419 1 MAIN_vInit();
420 1
421 1 // USER CODE BEGIN (Main,4)
422 1 while(1)
423 1 {
424 2 RightMovLed(); // LED点亮后单个右移
425 2 delay(100);
426 2 LeftMovLed(); // LED点亮后单个左移
427 2 delay(100);
C166 COMPILER V6.04, MAIN 03/25/2008 10:21:40 PAGE 8
428 2 LedFlash(); // 实现两个LED从中间跑两边
429 2 delay(100);
430 2 crossFlash(); // 交叉闪烁
431 2 delay(100);
432 2 }
433 1 // USER CODE END
434 1
435 1 } // End of function main
436
437
438
439 // USER CODE BEGIN (MAIN_General,10)
440
441 // USER CODE END
442
MODULE INFORMATION: INITIALIZED UNINITIALIZED
CODE SIZE = 336 --------
NEAR-CONST SIZE = -------- --------
FAR-CONST SIZE = -------- --------
HUGE-CONST SIZE = -------- --------
XHUGE-CONST SIZE = -------- --------
NEAR-DATA SIZE = 5 --------
FAR-DATA SIZE = -------- --------
XHUGE-DATA SIZE = -------- --------
IDATA-DATA SIZE = -------- --------
SDATA-DATA SIZE = -------- --------
BDATA-DATA SIZE = -------- --------
HUGE-DATA SIZE = -------- --------
BIT SIZE = -------- --------
INIT'L SIZE = 10 --------
END OF MODULE INFORMATION.
C166 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -