モノリシックマシンテスト
6371 ワード
1 #include "reg52.h"
2 #include "intrins.h"
3 #define uchar unsigned char
4 #define uint unsigned int
5
6 void delay( uchar x)
7 {
8 uint y;
9 for (; x > 0 ; x-- )
10 for( y=500 ;y>0;y--);
11
12
13 }
14
15 uchar a;//
16
17 void main()
18 {
19 uchar b=0x7f;
20 uchar bb = 0xcf;
21 uchar bbb = 0xef;
22 TMOD=0x20;// 1 2,8
23 TH1=0xFd; //11.0592M ,9600
24 TL1=0xFd;
25 SCON=0x50;// 1 SM0 SM1 01
26 PCON=0x00;//SMOD=0 16
27 TR1=1;// 1
28 ES=1;//
29 EA=1;//
30 while(1)
31 {
32 if(a== 'A')
33 {
34 delay(1000);
35 P1=b;
36 }
37 else if(a== 'B')
38 {
39 delay(1000);
40 P1 = bb;
41 }
42 else
43 P1 = bbb;
44 }
45
46 }
47
48 void serial() interrupt 4 //
49 {
50 RI=0;
51 a = SBUF;
52 }