?? p87lpc761_控制交流電機.lst
字號:
C51 COMPILER V7.09 P87LPC761_控制交羅電籣 03/20/2007 10:41:30 PAGE 1
C51 COMPILER V7.09, COMPILATION OF MODULE P87LPC761_控制交羅電籣
OBJECT MODULE PLACED IN P87LPC761_控制交流電機.OBJ
COMPILER INVOKED BY: D:\Program Files\Keil\C51\BIN\C51.EXE P87LPC761_控制交流電機.c BROWSE DEBUG OBJECTEXTEND
line level source
1 //飛利浦51LPC系列單片機用于控制交流電機
2 /*
3 Philips 51LPC是采用兩倍速80C51內核的低成本,低功耗,低功耗,低EMI,高抗干擾性及
4 內建電源Brownout,模擬功能,UART,I2C和片內RC振蕩器的新一代單片機.該系列目前已
5 包括P87LPC760/1/2/4/7/8/9共六個型號.51LPC提供高速和低速的晶振和RC振蕩方式,
6 可編程選擇具有較寬的操作電壓范圍2.7-6.0V,可編程I/O口線輸出模式選擇,可選擇
7 施密特觸發輸入,LED驅動輸出有內部看門狗定時器及提供掉電檢測模擬功能.最大限
8 度地減少了外部元件的使用.這些特性和改進的C51結構結合在一起使得在設計高集成度
9 低成本和低功耗控制電路時具有更多的選擇.該系列主要用于對系統成本有嚴格要求的低
10 功耗應用領域.
11 */
12
13 #include<REG764.H>
14 #define uchar unsigned char
15 #define uint unsigned int
16 uchar keyflag=0;
17 uchar s,x,y=0;
18 void timer0(void) interrupt 1 using 1 { //T0 interrupt
19 1 x=x+1;
20 1 if (x/10>s) {
21 2 if (y==0){
22 3 P1=P1&0xfb; /* LED ON---P12 */
23 3 x=0;y=1;}
24 2 else {
25 3 P1=P1|0x04; /*LED OFF*/
26 3
27 3 y=0;x=0;}
28 2 }
29 1 TF0=0;
30 1 TH0=-(28/256);
31 1 TL0=-(28%256);
32 1 }
33 void speed(s) {
34 1 uchar pulsecount ,pulseduration=0;
35 1 uint i=0;
36 1 uint j=0;
37 1 if (((CMP1&0x02))&&!(CMP2&0x02)) //poll comparator value
38 1 {
39 2 for (i=0;i<s;i++)
40 2 {for (j=0;j<210; j++) ;} //delay trigger
41 2 CMP1=CMP1&0xfc;
42 2 CMP2=CMP2&0xfc;
43 2 pulsecount=1;
44 2 while(pulsecount)
45 2 {
46 3 P1=P1&0xfe;
47 3 pulseduration=12; //trigger pulse
48 3 while(pulseduration) {pulseduration--;}
49 3 P1=P1|0x01;
50 3 pulsecount --;
51 3 } //pulse width
52 2 } //enter windows comparator
53 1 }
54 void Initcomparator(void)
55 {
C51 COMPILER V7.09 P87LPC761_控制交羅電籣 03/20/2007 10:41:30 PAGE 2
56 1 PT0AD=0x6f; /*disable P0 port digtial I/O function */
57 1 P0=0xff;
58 1 P0M1=0x2a; /* p01,p03,p05 input only */
59 1 P0M2=0xd5; /* p00,p04,p06 push pull */
60 1 P1=0xff;
61 1 P1M1=0x82; /* p17 input only for VZC */
62 1 P1M2=0x05; /*p10,p12 push pull, p11 input only */
63 1 CMP1=0x34; /* Cin1B+CMPREF+OE*/
64 1 CMP2=0x34; /* Cin2B+CMPREF+OE*/
65 1 }
66 void main (void)
67 {
68 1 uchar pulseduration=0x08;
69 1 uint i=0;
70 1 uint j=0;
71 1 uint keyflag=0;
72 1 SP=0x5f;
73 1
74 1 EA=0;
75 1 TH0=-(28/256);
76 1 TL0=-(28%256);
77 1 TF0=0;
78 1 EA=0;
79 1 TR0=0;
80 1 ET0=1;
81 1 CMP1=0;
82 1 CMP2=0;
83 1 Initcomparator();
84 1 CMP1=CMP1&0xfc;
85 1 CMP2=CMP2&0xfc;
86 1 s=0;
87 1 while (P1^1) {; } //wait press
88 1 while (!P1^1) {; } //wait release
89 1 while(P1&0x80) {};
90 1 while(!(P1&0x80)) {};
91 1 while(P1&0x80) {};
92 1 while(!(P1&0x80)) {};
93 1 while(P1&0x80) {};
94 1 P1=P1&0xfe; // P1_0=0 start up motor
95 1 while(1)
96 1 {
97 2 if (P1^1==0) {x=0;
98 3 while (!x) {;}
99 3 if(P1^1==0)
100 3 { P1=0xff; s=s+1;} //stop motor
101 3 if (s==8) {s=0;}
102 3 while (!P1^1) {; } //wait release
103 3 while(P1&0x80) {};
104 3 while(!(P1&0x80)) {};
105 3 while(P1&0x80) {};
106 3 while(!(P1&0x80)) {};
107 3 while(P1&0x80) {};
108 3 P1=P1&0xfe; } //start up motor
109 2 EA=1;TR0=1;
110 2 speed(s);
111 2 }
112 1 }
113
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 334 ----
C51 COMPILER V7.09 P87LPC761_控制交羅電籣 03/20/2007 10:41:30 PAGE 3
CONSTANT SIZE = ---- ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = 4 7
IDATA SIZE = ---- ----
BIT SIZE = ---- ----
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -