c8051f020模块.rar
源代码在线查看: pwm.lst
C51 COMPILER V8.02 PWM 09/05/2009 02:20:47 PAGE 1
C51 COMPILER V8.02, COMPILATION OF MODULE PWM
OBJECT MODULE PLACED IN PWM.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE PWM.C BROWSE DEBUG OBJECTEXTEND
line level source
1 #include
2
3 #define uint8 unsigned char
4 #define uint16 unsigned int
5
6
7
8 void Init_SYSCLK(void)
9 {
10 1 uint8 i;
11 1 OSCXCN = 0X67;//开始外部22.1184M晶振
12 1 for(i = 0;i < 128;i++); //等待外部起振
13 1 while(!(OSCXCN & 0X80)); //查询标志位
14 1 OSCICN = 0X88;//用外部晶振,并使能始终丢
15 1 }
16
17
18 void Init_PCA(void)
19 {
20 1 PCA0MD=0X00; //09
21 1
22 1 PCA0L=0X00;
23 1 PCA0H=0X00;
24 1 PCA0CPM0=0X46;//CB
25 1 //PCA0CPL0=0;
26 1 //PCA0CPH1=0X80;
27 1 PCA0CPH0=0Xc8;//4.6k
28 1
29 1 PCA0CPM1=0X46; //4c高速输出模式,46频率输出模式
30 1 //CCAP3L=0XFF;
31 1 PCA0CPH1=0Xb8; //5k
32 1 PCA0CPM2=0X46; //4c高速输出模式,46频率输出模式
33 1 PCA0CPH2=0Xc0; //4.8k
34 1 PCA0CPM3=0X46;
35 1 PCA0CPH3=0Xb1;//5.2k
36 1 PCA0CPM4=0X46;
37 1 PCA0CPH4=0Xaa;//5.4K
38 1
39 1 PCA0CN=0X40;
40 1 //EIE1=0X08;
41 1 }
42
43
44 void Init_PORT(void)
45 {
46 1 //XBR0=0X20;
47 1 XBR0=0X2c;
48 1 XBR2=0X40;
49 1 P0MDOUT=0XFF;
50 1 }
51
52 /*
53 void PCA_ISR(void) interrupt 9
54 {
55 CF=0;
C51 COMPILER V8.02 PWM 09/05/2009 02:20:47 PAGE 2
56 CCF1=1;
57
58
59 } */
60
61
62 void main(void)
63 {
64 1 WDTCN = 0xde;
65 1 WDTCN = 0xad;//关闭看门狗
66 1
67 1 Init_SYSCLK();
68 1 Init_PORT();
69 1 Init_PCA();
70 1 // EA=1;
71 1
72 1 while(1);
73 1
74 1 }
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 86 ----
CONSTANT SIZE = ---- ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = ---- ----
IDATA SIZE = ---- ----
BIT SIZE = ---- ----
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)