📄 7279.lst
字号:
C51 COMPILER V7.07 7279 05/17/2007 20:27:53 PAGE 1
C51 COMPILER V7.07, COMPILATION OF MODULE 7279
OBJECT MODULE PLACED IN 7279.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE 7279.c BROWSE DEBUG OBJECTEXTEND
stmt level source
1 /* */
2 /* S A G E T E C H . P R O P R I E T A R Y */
3 /* */
4 /* COPYRIGHT (c) 2005 BY SAGE TECH. CHINA. */
5 /* -- ALL RIGHTS RESERVED -- */
6 /* */
7 /* File Name: HD7279Atest.c */
8 /* Author: sagestar */
9 /* Created: 2005 */
10 /* Modified: no */
11 /* Revision: V1.0 */
12 /************************************************************************************/
13 /*程序作用:测试Sage Tech.开发板(MCP300)中hd7279键盘显示芯片是否能正常工作 */
14 /*程序功能:按下1号键显示0、1、2、3,按下2号键显示c、d、e、f,按下3号键显示4、5、6、7 */
15 /* 按下4号键显示8、9、a、b,按下0号键点亮4个LED灯 */
16 /************************************************************************************/
17 #include "my_include.h"
18 /************************************************************************************/
19 typedef unsigned char BYTE; /*自定义字节类型*/
20 /************************************************************************************/
21 #define Set_Bit(BIT) (BIT = 1) /*定义置1函数*/
22 #define Clear_Bit(BIT) (BIT = 0) /*定义清0函数*/
23 /************************************************************************************/
24 void Led_On(BYTE); /*定义点亮LED灯函数*/
25 void Led_Off(BYTE); /*定义熄灭LED灯函数*/
26 void Write_Hd7279(BYTE,BYTE); /*定义HD7279写函数*/
27 BYTE Read_Hd7279(BYTE); /*定义HD7279读函数*/
28 void Send_Byte(BYTE); /*定义HD7279发送字节函数*/
29 BYTE Receive_Byte(void); /*定义HD7279接收字节函数*/
30 void Short_Delay(void); /*定义短延时函数*/
31 void Long_Delay(void); /*定义长延时函数*/
32 void Mcu_Init(void); /*定义MCU初始化函数*/
33 void Delay_200_mS(void); /*定义200ms延时函数*/
34 /************************************************************************************/
35 BYTE Keyboard_Out; /*定义键值变量*/
36 bit Keyboard_Flag; /*定义按键标志*/
37 /************************************************************************************/
38 #define Hd7279_Key P3_2
39 #define Hd7279_Clk P1_4
40 #define Hd7279_Data P1_5
41 /************************************************************************************/
42 unsigned int cumulate=0x00;
43 unsigned int cumulate1=0x00;
44
45 unsigned char disp=0x09;
46 void time(void) interrupt 3 using 2
47 {
48 1 cumulate++;
49 1 if(cumulate>0xefff)
50 1 {
51 2 cumulate=0x00;
52 2 cumulate1+=1;
53 2 }
54 1 if(cumulate1>0x8ca0)
55 1 {disp+=1;
C51 COMPILER V7.07 7279 05/17/2007 20:27:53 PAGE 2
56 2 cumulate=0x00;
57 2 cumulate1=0x00;
58 2 }
59 1 _nop_();
60 1 _nop_();
61 1 _nop_();
62 1 _nop_();
63 1 _nop_();
64 1 _nop_();
65 1 _nop_();
66 1 _nop_();
67 1 _nop_();
68 1 _nop_();
69 1 _nop_();
70 1 TL1=0xff;
71 1 TH1=0xff;
72 1
73 1 }
74 void main(void) /*主函数*/
75 {
76 1
77 1 Mcu_Init(); /*MCU初始化*/
78 1 mai();
79 1 while(1)
80 1 {
81 2 Write_Hd7279(0xcf,disp);
82 2 if(Keyboard_Flag)
83 2 {
84 3 Clear_Bit(Keyboard_Flag);
85 3 if(Keyboard_Out==0) /*0号键处理*/
86 3 {
87 4 Send_Byte(0xa3);
88 4 }
89 3 else if(Keyboard_Out==1) /*1号键处理*/
90 3 { /*显示0、1、2、3*/
91 4
92 4 Led_On(0x07);
93 4
94 4 }
95 3 else if(Keyboard_Out==2) /*2号键处理*/
96 3 { /*显示c、d、e、f*/
97 4 Led_On(0x07);
98 4 }
99 3 else if(Keyboard_Out==3) /*3号键处理*/
100 3 { /*显示4、5、6、7*/
101 4 Write_Hd7279(0xc9,0x07);
102 4 Write_Hd7279(0xca,0x06);
103 4 Write_Hd7279(0xcb,0x05);
104 4 Write_Hd7279(0xcc,0x04); Led_Off(0x02);
105 4 }
106 3 else /*4号键处理*/
107 3 { /*显示8、9、a、b*/
108 4 Write_Hd7279(0xc9,0x0b);
109 4 Write_Hd7279(0xca,0x0a);
110 4 Write_Hd7279(0xcb,0x09);
111 4 Write_Hd7279(0xcc,0x08); Led_Off(0x02);
112 4 }
113 3 Delay_200_mS();
114 3 }
115 2 }
116 1 }
117 /***********************************************************************************/
C51 COMPILER V7.07 7279 05/17/2007 20:27:53 PAGE 3
118 void Delay_200_mS(void) /*500ms延时函数*/
119 {
120 1 BYTE i,j;
121 1 i=200;
122 1 while (i--)
123 1 {
124 2 j=228;
125 2 while(j--);
126 2 }
127 1 }
128 /************************************************************************************/
129 void Mcu_Init(void) /*MCU初始化函数*/
130 {
131 1 P1_3=0;
132 1 Delay_200_mS();
133 1
134 1 Set_Bit(EX0); /*外部中断0使能*/
135 1 Set_Bit(IT0); /*外部中断0下降沿触发*/
136 1 Set_Bit(EA); /*中断使能*/
137 1 TL1=0xff;
138 1 TH1=0xff;
139 1 IE1=1;
140 1 TR1=1;
141 1 ET1=1;
142 1 Send_Byte(0xa4); /*HD7279复位*/
143 1 Write_Hd7279(0x98,0x00); /*HD7279启动消隐功能,能提高灯的亮度*/
144 1 Write_Hd7279(0xc8,0x00);
145 1 Write_Hd7279(0xc9,0x02);
146 1 //Write_Hd7279(0xca,0x45); /*上电显示1、2、3、4、5、6、7、8*/
147 1 Write_Hd7279(0xcb,0x00);
148 1 Write_Hd7279(0xcc,0x05);
149 1 //Write_Hd7279(0xcd,0x26);
150 1 Write_Hd7279(0xce,0x01);
151 1 Write_Hd7279(0xcf,0x09);
152 1 }
153 /************************************************************************************/
154 void int1_Hd7279key(void) interrupt 0 /*外部中断0函数*/
155 {
156 1 Keyboard_Out=Read_Hd7279(0x15); /*读取键值*/
157 1 if(Keyboard_Out<=0x04)
158 1 {
159 2 Set_Bit(Keyboard_Flag); /*设置键标志*/
160 2 }
161 1 }
162 /************************************************************************************/
163 void Short_Delay(void) /*短延时函数*/
164 {
165 1 BYTE i;
166 1 for(i=0;i<0x08;i++);
167 1 }
168 /************************************************************************************/
169 void Long_Delay(void) /*长延时函数*/
170 {
171 1 BYTE i;
172 1 for(i=0;i<0x30;i++);
173 1 }
174 /************************************************************************************/
175 void Led_On(BYTE Led_Num) /*点亮LED灯函数*/
176 {
177 1 Write_Hd7279(0xe0,Led_Num);
178 1 }
179 /************************************************************************************/
C51 COMPILER V7.07 7279 05/17/2007 20:27:53 PAGE 4
180 void Led_Off(BYTE Led_Num) /*熄灭LED灯函数*/
181 {
182 1 Write_Hd7279(0xc0,Led_Num);
183 1 }
184 /************************************************************************************/
185 void Write_Hd7279(BYTE Command,BYTE Data) /*HD7279写函数*/
186 {
187 1 Send_Byte(Command);
188 1 Send_Byte(Data);
189 1 }
190 /************************************************************************************/
191 BYTE Read_Hd7279(BYTE Command) /*HD7279读函数*/
192 {
193 1 Send_Byte(Command);
194 1 return(Receive_Byte());
195 1 }
196 /************************************************************************************/
197 void Send_Byte(BYTE Data_Out) /*HD7279发送字节函数*/
198 {
199 1 BYTE i;
200 1 Long_Delay();
201 1 for(i=0;i<8;i++)
202 1 {
203 2 if(Data_Out&0x80) Set_Bit(Hd7279_Data);
204 2 else Clear_Bit(Hd7279_Data);
205 2 Set_Bit(Hd7279_Clk);
206 2 Short_Delay();
207 2 Clear_Bit(Hd7279_Clk);
208 2 Short_Delay();
209 2 Data_Out=Data_Out<<1;
210 2 }
211 1 Clear_Bit(Hd7279_Data);
212 1 }
213 /************************************************************************************/
214 BYTE Receive_Byte(void) /*HD7279接收字节函数*/
215 {
216 1 BYTE i,Data_In;
217 1 Set_Bit(Hd7279_Data);
218 1 Long_Delay();
219 1 for(i=0;i<8;i++)
220 1 {
221 2 Set_Bit(Hd7279_Clk);
222 2 Short_Delay();
223 2 Data_In=Data_In<<1;
224 2 if(Hd7279_Data) Data_In=Data_In|0x01;
225 2 Clear_Bit(Hd7279_Clk);
226 2 Short_Delay();
227 2 }
228 1 Clear_Bit(Hd7279_Data);
229 1 return(Data_In);
230 1 }
231 /************************************************************************************/
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 486 ----
CONSTANT SIZE = ---- ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = 6 1
IDATA SIZE = ---- ----
BIT SIZE = 1 ----
C51 COMPILER V7.07 7279 05/17/2007 20:27:53 PAGE 5
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -