📄 dd.lst
字号:
C51 COMPILER V8.02 DD 09/15/2007 14:54:57 PAGE 1
C51 COMPILER V8.02, COMPILATION OF MODULE DD
OBJECT MODULE PLACED IN dd.OBJ
COMPILER INVOKED BY: d:\program files\Keil\C51\BIN\C51.EXE dd.c BROWSE DEBUG OBJECTEXTEND
line level source
1 #include <reg52.h>
2 #include <intrins.h>
3 #include <math.h>
4 #include <string.h>
5 #include"AT24c02.h"
6 #include"MAX7219.h"
7
8 #define uchar unsigned char
9 #define uint unsigned int
10 #define num_circle 10 //圈数
11 #define second 2 //秒
12
13 sbit motor1=P1^5;
14 sbit motor2=P1^6;
15 sbit bee=P1^7;
16 sbit start_key=P1^3;
17 sbit stop_zero_key=P1^4;
18
19 uint c;
20 uchar twice=0,num50ms=0;
21 bit start_flag=1,circle_flag=0,cry_flag=1;
22
23 void circle_read(void)
24 {
25 1 c=read_random(0x01)*256+read_random(0x00);
26 1 }
27
28 void circle_write(uint cir)
29 {
30 1 write_byte(0x00,cir%256); write_byte(0x01,cir/256);
31 1 }
32
33 void Delay1ms(uint count)
34 {
35 1 uint i,j;
36 1 for(i=0;i<count;i++)
37 1 for(j=0;j<120;j++);
38 1 }
39
40 void buzzer(uchar b)
41 {
42 1 uchar k;
43 1 for(k=0;k<b;k++)
44 1 {
45 2 bee=0;
46 2 Delay1ms(50);
47 2 bee=1;
48 2 Delay1ms(50);
49 2 }
50 1 }
51 void McuInitial(void)
52 {
53 1 InitialMax7219();
54 1 TMOD=0x01;
55 1 TH0=0X4C;
C51 COMPILER V8.02 DD 09/15/2007 14:54:57 PAGE 2
56 1 TL0=0;
57 1 EA=1;
58 1 ET0=1;
59 1 start_flag=1;
60 1 circle_read();
61 1 display(c);
62 1
63 1 buzzer(1);
64 1 }
65
66 main()
67 {
68 1 McuInitial();
69 1 while(1)
70 1 {
71 2 ///////////////////////////键1继续///////////////////////////////////////////////////////
72 2 if(start_key==0&&start_flag==1)
73 2 {
74 3 Delay1ms(10);
75 3 if(!start_key)
76 3 {
77 4 start_flag=0;
78 4 cry_flag=1;
79 4 buzzer(1);
80 4 circle_read();
81 4 if(c>=num_circle)
82 4 {buzzer(3);motor1=1;motor2=1;}
83 4 else
84 4 {TR0=1;motor1=1;motor2=0;}
85 4 }
86 3 }
87 2 ////////////////////////////键2暂停并清零///////////////////////////////////////////////////////
88 2 if(!stop_zero_key)
89 2 {
90 3 Delay1ms(10);
91 3 if(!stop_zero_key)
92 3 {
93 4 TR0=0;
94 4 motor1=1;motor2=1;
95 4 start_flag=1;
96 4 cry_flag=1;
97 4 buzzer(1);
98 4 Delay1ms(2000);
99 4 if(!stop_zero_key)
100 4 {
101 5 fill_byte(0);
102 5
103 5 circle_read();
104 5 display(c);
105 5
106 5 buzzer(1);
107 5 while(!stop_zero_key);
108 5 }
109 4 }
110 3 }
111 2 ///////////////////////////每圈显示,保存数据//////////////////////////////////////////////////////
112 2 if(circle_flag)
113 2 {
114 3 circle_read();
115 3 c++;
116 3 circle_write(c);
117 3 circle_read();
C51 COMPILER V8.02 DD 09/15/2007 14:54:57 PAGE 3
118 3 display(c);
119 3 circle_flag=0;
120 3 }
121 2 ////////////////////////////判断是否计数到////////////////////////////////////////////////////////
122 2 circle_read();
123 2 if(c>=num_circle)
124 2 {
125 3 if(cry_flag)
126 3 {
127 4 TR0=0;
128 4 motor1=1;motor2=1;
129 4 start_flag=1;
130 4 buzzer(50);
131 4 cry_flag=0;
132 4 }
133 3
134 3 }
135 2 //////////////////////////////////////////////////////////////////////////////////////////////////
136 2 }
137 1 }
138
139 void time0(void)interrupt 1 using 1
140 {
141 1 num50ms++;
142 1 TH0=0X4C;
143 1 TL0=0;
144 1 if(num50ms==20*second)
145 1 {
146 2 motor1=~motor1;
147 2 motor2=~motor2;
148 2 twice++;
149 2 num50ms=0;
150 2 }
151 1 if(twice==2)
152 1 {
153 2 circle_flag=1;
154 2 twice=0;
155 2 }
156 1 }
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 1148 ----
CONSTANT SIZE = ---- ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = 12 7
IDATA SIZE = ---- ----
BIT SIZE = 3 1
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -