VFD荧光显示驱动程序
源代码在线查看: 复件 radio72131.lst
C51 COMPILER V7.50 复件_RADIO72131 10/22/2008 11:35:24 PAGE 1
C51 COMPILER V7.50, COMPILATION OF MODULE 复件_RADIO72131
OBJECT MODULE PLACED IN 复件 RADIO72131.OBJ
COMPILER INVOKED BY: D:\Program Files\keil\C51\BIN\C51.EXE 复件 RADIO72131.C BROWSE DEBUG OBJECTEXTEND
line level source
1 #include
2 #include
3 #define uchar unsigned char
4 #define uint unsigned int
5 #define ulong unsigned long
6 #define doo P3_4
7 #define cl P3_5
8 #define di P3_6
9 #define ce P3_7
10 #define lamp P3_3
11 #define lamp2 P2_2
12 //////led///////////
13 #define led1 P1_3
14 #define led2 P1_2
15 #define led3 P1_1
16 #define led4 P1_0
17 unsigned char code led[]={192,249,164,176,153,146,130,248,128,144,255};//
18 /////////////////////
19 #define k1 P2_0
20 #define k2 P2_3
21 #define k3 P2_7
22 ////////iic////////
23 #define sda P3_2
24 #define scl P3_0
25 ///////////////
26 uchar gw,sw,bw,qw;
27 uint freq_fm,freq_am;
28 bit bandb;
29 delay(uint i)
30 { uchar k;
31 1 while(--i)
32 1 {
33 2 for(k=0;k 34 2 }
35 1 }
36 /////////I2C///////////////////
37 //////////I2C开始///////////
38 start()
39 {
40 1
41 1 sda=1;
42 1 scl=1;
43 1 _nop_();
44 1 sda=0;
45 1 _nop_();
46 1 scl=0;
47 1
48 1 }
49 //////////I2C停止///////// /
50 stop()
51 {
52 1 sda=0;
53 1 _nop_();
54 1 scl=1;
55 1 _nop_();
C51 COMPILER V7.50 复件_RADIO72131 10/22/2008 11:35:24 PAGE 2
56 1 sda=1;
57 1 }
58 /////////I2C读一个字节//////////////
59 unsigned char rd(void)
60 {
61 1 uchar out=0;
62 1 uchar i; //有8位数据
63 1
64 1 for(i=0;i 65 1 { sda=1;
66 2 scl=1;
67 2 out|=sda;
68 2 scl=0;
69 2 if(i 70 2 }
71 1 sda=1;
72 1 scl=0;
73 1 return out;
74 1 }
75
76 /////////////////////I2C写一个字节/////////////////////////
77 void wd(unsigned char dd) //
78 {
79 1 uchar in,i=8;
80 1 in=dd;
81 1 while(i--)
82 1 {
83 2 sda=(in&0x80);
84 2 scl=1;
85 2 delay(1);
86 2 scl=0;
87 2 in 88 2 }
89 1 sda=1;
90 1 scl=1;
91 1 }
92
93 //////////////////I2C不应答//////////
94 noack()
95 {
96 1 sda=1;
97 1 scl=1;
98 1 delay(2);
99 1 scl=0;
100 1 delay(2);
101 1 sda=0;
102 1
103 1 }
104 //////////I2C等待器件应答///////////////
105 ack(){
106 1 uchar i=255;
107 1 while (--i) //等待ASK
108 1 { delay(1);
109 2 sda=1; //释放总线
110 2 if (sda==0) break; //跳出
111 2 scl=0;
112 2 }
113 1 scl=0;
114 1 }
115 ///////////////I2C读24C16///////////
116 uchar r_2402(uint add)
117 { uchar dd;
C51 COMPILER V7.50 复件_RADIO72131 10/22/2008 11:35:24 PAGE 3
118 1 start(); //开始
119 1 wd(0xa0);ack(); //写地址
120 1 wd(add);ack();//写读的地址
121 1 start();// 重新启动
122 1 wd(0xa1);ack(); //写 器件地址
123 1 dd=rd(); //读出数据
124 1 noack(); //不应答
125 1 stop(); //停止
126 1 return dd;
127 1 }
128 ///////////////////I2C写24C16////////////////////////////
129 void w_2402(uchar add,uchar dat) //(地址,数据 )
130 {
131 1 start(); //开始
132 1 wd(0xa0);ack(); //写写的数据
133 1 wd(add);ack();//
134 1 wd(dat); ack();
135 1 stop(); //停止
136 1 }
137
138
139 /////////主程序//////////////
140 main()
141 {
142 1
143 1 while(1)
144 1 {
145 2
146 2 bcd();//
*** WARNING C206 IN LINE 146 OF 复件 RADIO72131.C: 'bcd': missing function-prototype
147 2 display();//调显示
*** WARNING C206 IN LINE 147 OF 复件 RADIO72131.C: 'display': missing function-prototype
148 2
149 2
150 2 }
151 1 }
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 239 ----
CONSTANT SIZE = 11 ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = 8 1
IDATA SIZE = ---- ----
BIT SIZE = 1 ----
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 2 WARNING(S), 0 ERROR(S)