?? example1.lst
字號:
C51 COMPILER V7.06 EXAMPLE1 02/05/2004 21:39:53 PAGE 1
C51 COMPILER V7.06, COMPILATION OF MODULE EXAMPLE1
OBJECT MODULE PLACED IN Example1.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE Example1.c LARGE BROWSE DEBUG OBJECTEXTEND
stmt level source
1 /*
2 *********************************************************************************************************
3 * EXAMPLE1
4
5 * Using the Keil uVision2 compiler
6 * File : EXAMPLE1.C
7 *********************************************************************************************************
8 */
9 #include "uPLC.h"
10 #include "EXAMPLE1.h"
11 #include "REG52.h" //應與所用的CPU相配
12 #include "Program.h"
13
14 //////////////////////////////////////////////////////////////////////////////////
15 #define OSC_FREQ (12000000UL)
16 #define OSC_PER_INST (12)
17
18 //Preload value for 20 ms delay
19 #define PERIOD (20) //100 msec
20 #define PRELOAD020 (65536 - (unsigned int)(OSC_FREQ * PERIOD / (OSC_PER_INST * 1000)))
21 #define PRELOAD020H (PRELOAD020 / 256)
22 #define PRELOAD020L (PRELOAD020 % 256)
23
24 #define INTR_TIMER_0 1
25
26 unsigned int xdata counter;
27
28 ///////////////////////////////////////////////////////////////////////////////
29 void Timer0ISR(void) interrupt INTR_TIMER_0
30 {
31 1 //Reload timer0 value
32 1 TL0 = PRELOAD020L;
33 1 TH0 = PRELOAD020H;
34 1 if(counter%5==0) ReflashTIM();
35 1 counter++;
36 1 }
37 ///////////////////////////////////////////////////////////////////////////////
38 void main (void)
39 {
40 1 #if CODE_DEBUGGING
SCON = 0x50; /* SCON: mode 1, 8-bit UART, enable rcvr */
TMOD |= 0x20; /* TMOD: timer 1, mode 2, 8-bit reload */
TH1 = 221; /* TH1: reload value for 1200 baud @ 16MHz */
TR1 = 1; /* TR1: timer 1 run */
TI = 1; /* TI: set TI to send first char of UART */
#endif
47 1 Init();
48 1
49 1 #if CODE_DEBUGGING
CheckLadder(Program);
#endif
52 1 while (1)
53 1 {
54 2 ExecuteLadder(Program);
55 2 MappingIO();
C51 COMPILER V7.06 EXAMPLE1 02/05/2004 21:39:53 PAGE 2
56 2 }
57 1 }
58 ////////////////////////////////////////////////////////////////////////////////////////////////////
59 void Init(void)
60 {
61 1 P0=P1=P2=P3=0xff;
62 1
63 1 TMOD &= 0xf0; // clear all T0 bits
64 1 TMOD |= 0x01; // set T0 as 16-bit timer
65 1
66 1 //Set timer0 value as (65536 - 20 * 1000) equivalent to 20 ms
67 1 TL0 = PRELOAD020L;
68 1 TH0 = PRELOAD020H;
69 1
70 1 ET0 = 1; // enable timer 0 interrupt
71 1 TR0 = 1; // start timer 0
72 1 EA = 1; // enable interrupt
73 1 // AUXR=0; //選擇片內XRAM
74 1 uPLCInit();
75 1 counter=0;
76 1 }
77 ////////////////////////////////////////////////////////////////////////////////
78 void MappingIO(void)
79 {
80 1 unsigned char In;
81 1 unsigned int xdata mt;
82 1 int *pIR;
83 1 pIR=GetIR();
84 1 mt=0;
85 1 In=~P3;
86 1 mt|=In;
87 1 *pIR=mt;
88 1 mt=*(pIR+9);
89 1 P1=~mt;
90 1 }
91 //////////////////////////////////////////////////////////////////////////////////
92
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 207 ----
CONSTANT SIZE = 504 ----
XDATA SIZE = 2 2
PDATA SIZE = ---- ----
DATA SIZE = ---- ----
IDATA SIZE = ---- ----
BIT SIZE = ---- ----
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -