📄 7289.lst
字号:
C51 COMPILER V8.17 7289 03/19/2009 11:18:00 PAGE 1
C51 COMPILER V8.17, COMPILATION OF MODULE 7289
OBJECT MODULE PLACED IN 7289.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE 7289.c BROWSE DEBUG OBJECTEXTEND
line level source
1 #include "reg52.h"
2
3 sbit KEY = P3^3;
4 sbit CS = P3^1;
5 sbit CLK = P3^0;
6 sbit DIO= P3^2;
7
8 void DisPlay(KeyValue, char all);
9
10 void Delay(int time)
11 {
12 1 do
13 1 {
14 2 int j;
15 2 for(j=0; j<5; j++)
16 2 ;
17 2 } while (--time);
18 1 }
19
20 /*发送指令或数据到7289*/
21 void SendCmd(unsigned char cmd)
22 {
23 1 unsigned char BitCnt = 8;
24 1 CS = 0;
25 1 Delay(50);
26 1
27 1 while(BitCnt--)
28 1 {
29 2 DIO = cmd >> 7;
30 2 cmd<<=1;
31 2 CLK = 1;
32 2 Delay(10);
33 2 CLK = 0;
34 2 Delay(10);
35 2 }
36 1 DIO = 0;
37 1
38 1 }
39
40 /*接受Key值从7289*/
41 unsigned char Receive()
42 {
43 1 unsigned char BitCnt = 8;
44 1 unsigned char rec = 0;
45 1 DIO = 1;
46 1 CS = 0;
47 1 Delay(50);
48 1 while(BitCnt--)
49 1 {
50 2 CLK = 1;
51 2 Delay(10);
52 2 rec= (rec<<1)|DIO;
53 2 CLK=0;
54 2 Delay(10);
55 2 }
C51 COMPILER V8.17 7289 03/19/2009 11:18:00 PAGE 2
56 1 DIO = 0;
57 1 return rec;
58 1
59 1 }
60
61 /*等待Key按下,如果按下,接受Key值*/
62 unsigned char FindKey(NewKey)
63 {
64 1 unsigned char KeyValue;
65 1 KEY = 1;
66 1 Delay(50);
67 1 while(KEY)
68 1 {
69 2 ;
70 2 }
71 1 SendCmd(0x15);
72 1 KeyValue = Receive();
73 1 CS=1;
74 1 return KeyValue ;
75 1 }
76
77 /*如果all=1, 8个数码 管一起显示KeyValue,否则根据位数显示*/
78 void DisPlay(KeyValue, char all)
79 {
80 1 unsigned char LedValue;
81 1
82 1 unsigned char ledsel = 0x87;
83 1 int i;
84 1 if(!all)
85 1 SendCmd(0xA4);
86 1 for(i=0; i<8;i++)
87 1 {
88 2 LedValue = KeyValue%10;
89 2 SendCmd(ledsel-i);
90 2 SendCmd(LedValue);
91 2 CS = 1;
92 2 KeyValue/=10;
93 2 if((!all) && (KeyValue ==0))
94 2 break;
95 2 }
96 1
97 1 }
98
99 /*on=1 Led 闪,否则on=0,不闪*/
100 void LedShine(int on)
101 {
102 1 SendCmd(0x88);
103 1 if(on)
104 1 SendCmd(0x0);
105 1 else
106 1 SendCmd(0xff);
107 1 CS = 1;
108 1 }
109
110 /*Led左移一位*/
111 void LedLsl()
112 {
113 1 SendCmd(0xA0);
114 1 CS = 1;
115 1 }
116
117
C51 COMPILER V8.17 7289 03/19/2009 11:18:00 PAGE 3
118
119 void main(void)
120 { unsigned char KeyValue,NewKey;
121 1 int i;
122 1 CS = 1;
123 1 KEY = 1;
124 1 DIO = 1;
125 1 Delay(10);
126 1 SendCmd(0xA4);
127 1 Delay(10);
128 1 DisPlay(0, 1);
129 1 Delay(5000);
130 1 DisPlay(8, 0);
131 1
132 1 for(i=0; i<8; i++)
133 1 {
134 2 Delay(3000);
135 2 LedLsl();
136 2 }
137 1 while(1)
138 1 {
139 2 KeyValue = FindKey(NewKey);
140 2 DisPlay(KeyValue,0);
141 2 }
142 1
143 1
144 1
145 1 }
146
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 368 ----
CONSTANT SIZE = ---- ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = ---- 10
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 + -