wd.lst
来自「该程序可以实现用595与154结合51单片机的16*32LED点阵左右滚动。」· LST 代码 · 共 108 行
LST
108 行
C51 COMPILER V8.05a WD 03/26/2009 12:12:54 PAGE 1
C51 COMPILER V8.05a, COMPILATION OF MODULE WD
OBJECT MODULE PLACED IN wd.OBJ
COMPILER INVOKED BY: E:\KeilC51安装地\C51\BIN\C51.EXE wd.c BROWSE DEBUG OBJECTEXTEND
line level source
1 #include <at89x51.h>
2 #include "led.h"
3 unsigned char init=0;
4 unsigned int temp=0;
5 unsigned int x=0,y=0;
6
7 void delay(unsigned char t)
8 {
9 1 while(--t);
10 1 }
11 void delay_50us(unsigned int t)
12 {
13 1 unsigned char j;
14 1 for(;t>0;t--)
15 1 for(j=19;j>0;j--);
16 1 }
17
18 void init_device(void)
19 {
20 1 P2_4=1;
21 1 delay_50us(1); //88us
22 1 P2_4=0;
23 1 delay_50us(12); //736
24 1 P2_4=1;
25 1 delay(30); //142us
26 1 if (P2_4==0) init=1;
27 1 delay_50us(5);
28 1 }
29 void write_8bit(unsigned char write_dat)
30 {
31 1 unsigned char i=0;
32 1 for (i=0;i<8;i++)
33 1 {
34 2 P2_4=0;
35 2 P2_4=write_dat&0x01;
36 2 delay_50us(2); //61
37 2 P2_4=1;
38 2 write_dat=write_dat>>1;
39 2 }
40 1 }
41 unsigned char read_8bit(void)
42 {
43 1 unsigned char read_dat=0,i=0;
44 1 for (i=0;i<8;i++)
45 1 {
46 2
47 2 P2_4=0;
48 2 read_dat>>=1;
49 2 P2_4=1;
50 2 delay(1);
51 2 if (P2_4) read_dat|=0x80;
52 2 delay_50us(2); //52
53 2 }
54 1 return (read_dat);
55 1 }
C51 COMPILER V8.05a WD 03/26/2009 12:12:54 PAGE 2
56 unsigned char temperature(void)
57 {
58 1 unsigned char wd_l8=0,wd_h8=0,wd=0;
59 1
60 1 init_device();
61 1 write_8bit(0xCC);
62 1 write_8bit(0x44);
63 1 delay_50us(16);
64 1 init_device();
65 1 write_8bit(0xCC);
66 1 write_8bit(0xBE);
67 1 wd_l8=read_8bit();
68 1 wd_h8=read_8bit();
69 1 wd_l8=wd_l8>>4;
70 1 wd_h8=wd_h8<<4;
71 1 wd=wd_l8|wd_h8;
72 1 return (wd);
73 1 }
74
75 void wd_t(void)
76 {
77 1 P2_4=1;
78 1 temp=temperature();
79 1 x=temp/10;
80 1 y=temp-10*x;
81 1
82 1 }
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 225 ----
CONSTANT SIZE = ---- ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = 7 ----
IDATA SIZE = ---- ----
BIT SIZE = ---- ----
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?