📄 test7279.lst
字号:
C51 COMPILER V7.06 TEST7279 09/09/2006 14:17:59 PAGE 1
C51 COMPILER V7.06, COMPILATION OF MODULE TEST7279
OBJECT MODULE PLACED IN Test7279.OBJ
COMPILER INVOKED BY: c:\KEIL\C51\BIN\C51.exe Test7279.c DB OE
stmt level source
1 #include "c8051f020.h"
2 #include <intrins.h>
3
4 sbit HD7279_DAT=P1^7;
5 sbit HD7279_CLK=P1^6;
6
7 #define NOSELECT7279 P5 |= 0x80 //SPICS4(P57)=1
8 #define SELECT7279 P5 &= ~(0x80) //SPICS4(P57)=0;
9 #define Set7279DAT HD7279_DAT=1
10 #define Clr7279DAT HD7279_DAT=0
11 #define Set7279CLK HD7279_CLK=1
12 #define Clr7279CLK HD7279_CLK=0
13
14 // HD7279测试/演示程序
15
16 // I/O口初始化
17
18 void Delay1ms(unsigned char T);
19 void Delay1s(unsigned char T);
20 void Delay1us(unsigned char T);
21
22 void Send7279Byte(unsigned char ch)
23 {
24 1 char i;
25 1 SELECT7279; //置CS低电平
26 1 Delay1us(50); //延时50μ
27 1
28 1 for (i=0;i<8;i++)
29 1 {
30 2 if (ch&0x80) //输出7位到HD7279A的DATA端
31 2 {
32 3 Set7279DAT;
33 3 }
34 2 else
35 2 {
36 3 Clr7279DAT;
37 3 }
38 2 Set7279CLK; //置CLK高电平
39 2 ch=ch<<1; //待发数据左移
40 2 Delay1us(8); //延时8μ
41 2 Clr7279CLK; //置CLK低电平
42 2 Delay1us(8); //延时50μ
43 2 }
44 1 Clr7279DAT; //发送完毕,DATA端置低,返回
45 1 }
46 unsigned char Receive7279Byte(void)
47 {
48 1 unsigned char i,ch;
49 1 ch=0;
50 1 Set7279DAT; //DATA端置为高电平,输入状态
51 1 Delay1us(50); //延时50μ
52 1 for (i=0;i<8;i++)
53 1 {
54 2 Set7279CLK; //置CLK高电平
55 2 Delay1us(8); //延时8μ
C51 COMPILER V7.06 TEST7279 09/09/2006 14:17:59 PAGE 2
56 2 ch=ch<<1; //接收数据左移1位
57 2 if (HD7279_DAT)
58 2 ch+=1; //接收1位数据
59 2 Clr7279CLK; //置CLK低电平
60 2 Delay1us(8); //延时8μ
61 2 }
62 1 Clr7279DAT; //接收完毕,DATA端重新置成低电平(输出状态)
63 1 return ch;
64 1 }
65
66 void FlashLED(unsigned char No)
67 {
68 1 char i;
69 1 Send7279Byte(0x88); //发闪烁指令
70 1 i=0x1;
71 1 while (No)
72 1 {
73 2 i=i<<1;
74 2 No--;
75 2 }
76 1 Send7279Byte(~i); //1闪烁
77 1 NOSELECT7279; //置CS高电平
78 1 }
79
80 /*
81 void BlankLED(unsigned char ch)
82 {
83 Send7279Byte(0x98); //发消隐指令
84 Send7279Byte(ch); //1-显示 0-消隐
85 NOSELECT7279; //置CS高电平
86 }
87 */
88
89 void MoveLeft(void)
90 {
91 1 Send7279Byte(0xA1); //发左移指令
92 1 NOSELECT7279; //置CS高电平
93 1 }
94
95 void MoveRight(void)
96 {
97 1 Send7279Byte(0xA0); //发右移指令
98 1 NOSELECT7279; //置CS高电平
99 1 }
100
101 unsigned char code BdSeg[]={
102 0x7e,0x30,0x6d,0x79, // 0 1 2 3
103 0x33,0x5b,0x5f,0x70, // 4 5 6 7
104 0x7f,0x7b,0x77,0x1f, // 8 9 a b
105 0x4e,0x3d,0x4f,0x47, // c d e f
106 0x00,0x01};
107
108 void DispLED(char *DispBuf,char ShowDot)//ShowDot 显示小数点位
109 {
110 1 char i,ch;
111 1 ShowDot--;
112 1 for (i=0;i<6;i++)
113 1 {
114 2 ch=DispBuf[i];
115 2 if ((ch>='a') && (ch<='f'))
116 2 {
117 3 ch-='a';ch+=0xa;
C51 COMPILER V7.06 TEST7279 09/09/2006 14:17:59 PAGE 3
118 3 }
119 2 if ((ch>='A') && (ch<='F'))
120 2 {
121 3 ch-='A';ch+=0xa;
122 3 }
123 2 Send7279Byte(0x90+5-i); //不译码
124 2 if (ch==' ')
125 2 Send7279Byte(0x00);
126 2 else
127 2 if (ch=='-')
128 2 Send7279Byte(0x01);
129 2 else
130 2 {
131 3 if (ShowDot==i)
132 3 Send7279Byte(0x80|BdSeg[ch&0x0f]);
133 3 else
134 3 Send7279Byte(BdSeg[ch&0x0f]);
135 3 }
136 2 }
137 1 NOSELECT7279; //置CS高电平
138 1 }
139
140 char GetKeyValue(void)
141 {
142 1 char KeyValue;
143 1 if (CPT1CN&0x40) return -1; //无键按下
144 1 Send7279Byte(0x15); //发读键盘指令
145 1 KeyValue=Receive7279Byte();
146 1 NOSELECT7279; //置CS高电平
147 1 return KeyValue;
148 1 }
149
150 void WaitKeyOff(void)
151 {
152 1 while (!(CPT1CN&0x40));
153 1 }
154
155 void Test7279(bit LoopFlag)
156 {
157 1 char i,KeyValue;
158 1 Delay1ms(25); //等待25ms复位时间
159 1 Send7279Byte(0xA4); //发复位指令
160 1 NOSELECT7279; //置CS高电平
161 1 if (LoopFlag==0) return;
162 1 DispLED("123456",0); //显示123456
163 1 for (i=0;i<8;i++)
164 1 {
165 2 Delay1s(1);
166 2 MoveLeft();
167 2 }
168 1
169 1 DispLED("123456",0); //显示123456
170 1 DispLED("7890AB",2); //显示123456
171 1 DispLED("CDEF -",3); //显示123456
172 1
173 1 for (i=0;i<6;i++)
174 1 {
175 2 Delay1s(1);
176 2 MoveRight();
177 2 }
178 1
179 1 DispLED("F 1",1); //显示123456
C51 COMPILER V7.06 TEST7279 09/09/2006 14:17:59 PAGE 4
180 1
181 1 FlashLED(0); //第一位闪烁
182 1 Delay1s(1);
183 1 FlashLED(1); //第二位闪烁
184 1 Delay1s(1);
185 1 FlashLED(8); //关闪烁
186 1
187 1 //BlankLED(0x23); //注意:执行消隐后,键盘输入中断口不能恢复.
188 1
189 1 for (;;)
190 1 {
191 2 KeyValue=GetKeyValue();
192 2 if(KeyValue!=-1)
193 2 {
194 3 Send7279Byte(0xC8); //发送键码值,按方式1译码下载显示
195 3 Send7279Byte(KeyValue%16);
196 3 NOSELECT7279; //置CS高电平
197 3 WaitKeyOff();
198 3 }
199 2 }
200 1 }
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 544 ----
CONSTANT SIZE = 46 ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = ---- 13
IDATA SIZE = ---- ----
BIT SIZE = ---- 1
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -