📄 max531.lst
字号:
C51 COMPILER V8.02 MAX531 12/01/2008 21:36:30 PAGE 1
C51 COMPILER V8.02, COMPILATION OF MODULE MAX531
OBJECT MODULE PLACED IN MAX531.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE MAX531.c BROWSE DEBUG OBJECTEXTEND
line level source
1 #include<reg52.h>
2 #define uint unsigned int
3 #define uchar unsigned char
4
5 void delay1ms(uint);
6 //uchar keyscan(void);
7 //void getscan();
8 /****max531引脚定义***/
9 sbit din531=P1^0;
10 sbit clk531=P1^1;
11 sbit cs531=P1^2;
12 /***4乘4引脚定义***/
13 uchar keyascan[2];
14 uchar wordbuf[6]; // 字型码缓冲区
15 uchar count,key; // 位计数
16
17 /*****1602引脚定义***/
18 sbit RS=P3^7;
19 sbit RW=P3^6;
20 sbit EN=P3^5;
21 //uchar JS[5]={0X30,0X30,':',0X30,0X30};
22 unsigned char code str1[]={"setdy:"};
23 unsigned char code str2[]={"nowgl:"};
24 //unsigned char code str3[]={"OK"};
25 //unsigned char code str4[]={"HOT"};
26 //unsigned char code str5[]={"COOL"};
27 //uchar data disdata[5];
28
29
30
31 /************MAX531D/A转换************/
32 void da_out531(uint out_value)
33 {
34 1 uchar da_h8,da_l4,i;
35 1 uint a;
36 1 a=out_value;
37 1 da_h8=(uchar)(a>>4)&0x00ff;
38 1 a=out_value;
39 1 da_l4=(char)(a<<4)&0x00ff;
40 1 cs531=0;
41 1 for(i=0;i<8;i++)
42 1 {
43 2 clk531=0;
44 2 delay1ms(1);
45 2 if(da_h8&0x80)din531=1;
46 2 else din531=0;
47 2 clk531=1;
48 2 da_h8<<=1;
49 2 }
50 1 for(i=0;i<4;i++)
51 1 {
52 2 clk531=0;
53 2 delay1ms(1);
54 2 if(da_l4&0x80)
55 2 din531=1;
C51 COMPILER V8.02 MAX531 12/01/2008 21:36:30 PAGE 2
56 2 else
57 2 din531=0;
58 2 clk531=1;
59 2 da_l4<<=1;
60 2 }
61 1 cs531=1;
62 1 }
63
64 /******************延时**********************/
65 void delay1ms(uint t) //延时1MS
66 {
67 1 uchar j;
68 1 while(t--)
69 1 {
70 2 for(j=0;j<125;j++)
71 2 {;}
72 2 }
73 1 }
74
75 /*****************4乘4键盘**************/
76 /* 键扫描函数 */
77 uchar keyscan(void)
78 {
79 1 uchar scancode,tmpcode;
80 1 P2 = 0xf0; // 发全0行扫描码
81 1 if ((P2&0xf0)!=0xf0) // 若有键按下
82 1 {
83 2 delay1ms(2); // 延时去抖动
84 2 if ((P2&0xf0)!=0xf0) // 延时后再判断一次,去除抖动影响
85 2 {
86 3 scancode = 0xfe;
87 3 while((scancode&0x10)!=0) // 逐行扫描
88 3 {
89 4 P2 = scancode; // 输出行扫描码
90 4 if ((P2&0xf0)!=0xf0) // 本行有键按下
91 4 {
92 5 tmpcode = (P2&0xf0)|0x0f;
93 5
94 5 /* 返回特征字节码,为1的位即对应于行和列 */
95 5 return((~scancode)+(~tmpcode));
96 5 }
97 4 else scancode = (scancode<<1)|0x01; // 行扫描码左移一位
98 4 }
99 3 }
100 2 }
101 1 return(0); // 无键按下,返回值为0
102 1 }
103 /* 键盘取值函数*/
104 void getscan()
105 { uchar j,enterflag=0; // 确认键按下与否标志
106 1
107 1 key = keyscan(); // 调用键盘扫描函数
108 1 switch(key)
109 1 {
110 2 case 0x11: // 1行1列,数字0
111 2 if (count<2)
112 2 {
113 3 wordbuf[count] = '0';
114 3 count++;
115 3
116 3 }
117 2 break;
C51 COMPILER V8.02 MAX531 12/01/2008 21:36:30 PAGE 3
118 2 case 0x21: // 1行2列,数字1
119 2 if (count<2)
120 2 {
121 3 wordbuf[count] = '1';
122 3 count++;
123 3 }
124 2 break;
125 2 case 0x41: // 1行3列,数字2
126 2 if (count<2)
127 2 {
128 3 wordbuf[count] = '2';
129 3 count++;
130 3 }
131 2 break;
132 2 case 0x81: // 1行4列,数字3
133 2 if (count<2)
134 2 {
135 3 wordbuf[count]= '3';
136 3 count++;
137 3 }
138 2 break;
139 2 case 0x12: // 2行1列,数字4
140 2 if (count<2)
141 2 {
142 3 wordbuf[count] = '4';
143 3 count++;
144 3 }
145 2 break;
146 2 case 0x22: // 2行2列,数字5
147 2 if (count<2)
148 2 {
149 3 wordbuf[count]= '5';
150 3 count++;
151 3 }
152 2 break;
153 2 case 0x42: // 2行3列,数字6
154 2 if (count<2)
155 2 {
156 3 wordbuf[count]= '6';
157 3 count++;
158 3 }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -