📄 motor.lst
字号:
C51 COMPILER V7.06 MOTOR 04/23/2005 22:12:30 PAGE 1
C51 COMPILER V7.06, COMPILATION OF MODULE MOTOR
OBJECT MODULE PLACED IN motor.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE motor.c ROM(SMALL) BROWSE DEBUG OBJECTEXTEND
stmt level source
1 //------12M Hz,AT89C51-----
2 #include <at89x51.h>
3 #include <motor.h>
4 void init_ports()
5 {
6 1 P0=0x07;
7 1 P1=0x00;
8 1 P2=0x00;
9 1 P3=0x00;
10 1 }
11 void init_297()
12 {
13 1 DR1=CCW;
14 1 DR2=CCW;
15 1 RST1=1;
16 1 RST2=1;
17 1 RST1=0;
18 1 RST2=0;
19 1 Clk_Delay();
20 1 RST1=1;
21 1 RST2=1;
22 1 EN1=DISABLE;
23 1 EN2=DISABLE;
24 1 HF1=1;
25 1 HF2=1;
26 1 M1_BUSY=0;
27 1 M2_BUSY=0;
28 1 }
29 void init_device()
30 {
31 1 EA=0;
32 1 init_ports();
33 1 init_297();
34 1 TMOD=0x22;//timer,auto-reload mode.
35 1 TL0=0x9B;
36 1 TH0=0x9B;
37 1 TL1=0x9B;
38 1 TH1=0x9B;
39 1 ET0=1;
40 1 ET1=1;
41 1 TR0=1;
42 1 TR1=1;
43 1 EA=1;
44 1 }
45 void int_t0(void) interrupt TF0_VECTOR using 1
46 {
47 1 if(step_count1==0)
48 1 {
49 2 M1_BUSY=0;
50 2 motor1_stop();
51 2 return;
52 2 }
53 1 else
54 1 {
55 2 M1_BUSY=1;
C51 COMPILER V7.06 MOTOR 04/23/2005 22:12:30 PAGE 2
56 2 }
57 1 speed_count1++;
58 1 if(speed_count1>=speed_set1)
59 1 {
60 2 speed_count1=0;
61 2 CLK1_CLR;
62 2 Clk_Delay();
63 2 CLK1_SET;
64 2 if(speed_set1!=FOREVER_RUN)
65 2 {
66 3 step_count1--;
67 3 }
68 2 }
69 1 }
70 void int_t1(void) interrupt TF1_VECTOR using 2
71 {
72 1 if(step_count2==0)
73 1 {
74 2 M2_BUSY=0;
75 2 motor2_stop();
76 2 return;
77 2 }
78 1 else
79 1 {
80 2 M2_BUSY=1;
81 2 }
82 1
83 1 speed_count2++;
84 1 if(speed_count2>=speed_set2)
85 1 {
86 2 speed_count2=0;
87 2 CLK2_CLR;
88 2 Clk_Delay();
89 2 CLK2_SET;
90 2 if(speed_set2!=FOREVER_RUN)
91 2 step_count2--;
92 2 }
93 1 }
94 void motor_run(bit Motor_Select,bit Direction,uint speed,uint step)
95 {
96 1 if(!Motor_Select)
97 1 {
98 2 if(M1_BUSY){return;}
99 2 EN1=ENABLE;
100 2 DR1=Direction;
101 2 speed_set1=speed;
102 2 step_count1=step;
103 2 //return TURE;
104 2 }
105 1 else
106 1 {
107 2 if(M2_BUSY){return;}
108 2 EN2=ENABLE;
109 2 DR2=Direction;
110 2 speed_set2=speed;
111 2 step_count2=step;
112 2 //return TURE;
113 2 }
114 1 }
115 void motor1_stop()
116 {
117 1 M1_BUSY=0;
C51 COMPILER V7.06 MOTOR 04/23/2005 22:12:30 PAGE 3
118 1 EN1=DISABLE;
119 1 step_count1=0;
120 1 }
121 void motor2_stop()
122 {
123 1 M2_BUSY=0;
124 1 EN2=DISABLE;
125 1 step_count2=0;
126 1 }
127 void motor_status()
128 {
129 1 if(M1_BUSY)
130 1 LED_M1=0;
131 1 else
132 1 LED_M1=1;
133 1 if(M2_BUSY)
134 1 LED_M2=0;
135 1 else
136 1 LED_M2=1;
137 1 }
138 main()
139 {
140 1 init_device();
141 1 motor_run(M1,CW,5000,2000);
142 1 motor_run(M2,CCW,500,2000);
143 1 while(1)
144 1 {
145 2 motor_status();
146 2 };
147 1 }
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 376 ----
CONSTANT SIZE = ---- ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = 12 4
IDATA SIZE = ---- ----
BIT SIZE = 2 2
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -