📄 main.lst
字号:
C51 COMPILER V7.20 MAIN 11/15/2008 17:31:50 PAGE 1
C51 COMPILER V7.20, COMPILATION OF MODULE MAIN
OBJECT MODULE PLACED IN main.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE main.c BROWSE DEBUG OBJECTEXTEND
line level source
1 #include <main.h>
2 #include <REG54.H>
3
4 #define TRUE 0x1
5 #define FALSE 0x0
6 typedef unsigned int uint;
7 typedef unsigned char uchar;
8
9 sbit keyOne=P1^0; //--setkey
10 sbit keyTwo=P1^1; //--number is select to fist Led
11 sbit keyThree=P1^2; //--number is select to second Led
12 sbit keyFour=P1^3; //--save
13 sbit keyFive=P0^7; //--positoin
14 sbit keySix=P2^7; //--otherS key
15 //--
16 sbit RelayOne=P1^4; //--
17 sbit RelayTwo=P1^6; //--
18 sbit RelayThree=P1^7; //--
19 sbit RelayFour=P1^5; //--
20 sbit RelayFive=P3^0; //--
21 sbit RelaySix=P3^1; //--
22 sbit RelaySeven=P3^2; //--
23 sbit RelayEight=P3^3; //--
24 sbit RelayNine=P3^4; //--
25 sbit RelayTen=P3^5; //--
26 //--
27 #define firstL 0x34
28 #define secondL 0x24
29 #define thirdL 0x13
30 #define fourth 0x1f
31 #define huaChe
32 #define ZhengXin
33 #define modeA 0x12
34 #define ModeB 0x13
35
36 unsigned char const CharCodeForBcd[] = {0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x77,0x7c,0x39,
-0x7e,0x97,0x79};
37
38 const unsigned char p2code[]={0x7e,0x30,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x77,0x7c,0x39,0x7e,0x97,0
-x79};
39
40 unsigned char keyOneValue = 0;//--S1的按键for select workMode
41 unsigned char keyTwoValue = 0;//--S2的按键次数 for select motoin
42 unsigned char keyThreeValue = 0;//--S3的按键次数
43 unsigned char keyFourV = 0;
44
45 void delayMs(uint n);//--延时函数
46 void display(unsigned char keyA,unsigned char keyB);//--数码管运算显示
47 void keyboardScan(void);//--按键扫描
48 void RelayControl(unsigned VP1,unsigned char VP3);//--
49 void main(void)
50 {
51 1 P1 = 0xff; //---初始化系统
52 1 P3 = 0xff;
53 1 P0 = 0xff;
C51 COMPILER V7.20 MAIN 11/15/2008 17:31:50 PAGE 2
54 1 P2 = 0xff;
55 1 delayMs(1);
56 1 while(1)
57 1 {
58 2 keyboardScan();
59 2 display(keyOneValue,keyTwoValue);
60 2
61 2 }
62 1 }
63 void delayMs(uint n)//--延时函数
64 {
65 1
66 1 while(n)
67 1 {
68 2 n--;
69 2 }
70 1 }//--
71 void display(unsigned char keyA,unsigned char keyB)//--数码管运算显示
72 {
73 1
74 1 unsigned char Value = 0;
75 1 Value = (keyA <<4) +keyB;
76 1
77 1 P0=CharCodeForBcd[Value & 0x0f];
78 1 P2=p2code[(Value & 0xf0)>>4];
79 1
80 1 }
81 //--
82 void keyboardScan(void)//--按键扫描
83 {
84 1 static bit a = 0;
85 1 static bit b = 0;
86 1 static bit c= 0;
87 1 static bit d= 0;
88 1
89 1 if(keyOne == FALSE) //--按S1
90 1 {
91 2 if(~a)
92 2 {
93 3 delayMs(10);
94 3 if(keyOne == FALSE)
95 3 {
96 4 a =1;
97 4 keyOneValue++;//--process keyValue
98 4 if(keyOneValue>5)
99 4 keyOneValue=0;
100 4 }
101 3 }
102 2 }
103 1 else a =0;
104 1 if(keyTwo == FALSE)//--按S2
105 1 {
106 2 if(~b)
107 2 {
108 3 delayMs(10);
109 3 if(keyTwo == FALSE)
110 3 {
111 4 b = 1;
112 4 keyTwoValue++;
113 4 if(keyTwoValue>5)
114 4 keyTwoValue=0;//--process keyValue
115 4 }
C51 COMPILER V7.20 MAIN 11/15/2008 17:31:50 PAGE 3
116 3 }
117 2 }
118 1 else b =0;
119 1
120 1 if(keyThree == FALSE)//--按S3
121 1 {
122 2 if(~c)
123 2 {
124 3 delayMs(10);
125 3 if(keyThree == FALSE)
126 3 {
127 4 c = 1;
128 4 keyThreeValue++;
129 4 if(keyThreeValue>2)
130 4 keyThreeValue=0; //--process keyValue
131 4 }
132 3 }
133 2 }
134 1 else c = FALSE;
135 1
136 1 if(keyFour == FALSE)//--按S3
137 1 {
138 2 if (~d)
139 2 {
140 3 delayMs(10);
141 3 if(keyFour == FALSE)
142 3 {
143 4 d = 1;
144 4 keyFourV++;
145 4 if(keyFourV>2)
146 4 keyFourV=0; //--process keyValue
147 4 }
148 3 }
149 2 }
150 1 else d = FALSE;
151 1 }
152
153 void RelayControl(unsigned VP1,unsigned char VP3)//--
154 {
155 1 ;
156 1
157 1
158 1
159 1
160 1
161 1 }
*** WARNING C280 IN LINE 153 OF MAIN.C: 'VP1': unreferenced local variable
*** WARNING C280 IN LINE 153 OF MAIN.C: 'VP3': unreferenced local variable
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 205 ----
CONSTANT SIZE = ---- ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = 36 3
IDATA SIZE = ---- ----
BIT SIZE = 4 ----
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 2 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -