📄 pwm.lst
字号:
C51 COMPILER V7.50 PWM 08/19/2006 09:45:24 PAGE 1
C51 COMPILER V7.50, 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 <REG1210.H>
2 #include <intrins.h>
3 #include <stdio.h>
4 #include "ISD51.H"
5 #include "ROM.H"
6 #define XTAL 11059200
7 #define BAUDRATE 9600
8 #define T2RELOAD (65536-(XTAL/32/BAUDRATE))
9 sbit GreenLed = P2^4;
10 void delay(void){
11 1 unsigned long s;
12 1
13 1 s =0x0f000;
14 1 while(s--);
15 1 }
16
17 void main(void) {
18 1 //Config ISD
19 1 T2CON = 0x34; // Use Timer 2 as baudrate generator
20 1 RCAP2H = 0xFF;
21 1 RCAP2H = (T2RELOAD >> 8); // baudrate reload factor
22 1 RCAP2L = T2RELOAD;
23 1
24 1 SCON0 = 0x50; // enable serial uart & receiver
25 1 PCON |= 0x80; // double baudrate for UART0
26 1 P3DDRL &= 0xF0; // P3DDRL set port pins of UART0 to input/strong drive output
27 1 P3DDRL |= 0x07; // P3DDRL set port pins of UART0 to input/strong drive output
28 1
29 1
30 1 USEC = ((XTAL+500000)/1000000)-1; // USEC timer factor
31 1 ONEMS = (XTAL/1000)-1; // (MSECH+MSCL) MS Timer counting at 1.0ms
32 1
33 1 HMSEC = 100-1; // Hundred MS Timer to 100.0ms
34 1 SECINT = (10-1) | 0x80; // SECINT= 10 * HMS Timer Rate = 1 sec
35 1 // '0x80' will set the MSB for write immediate
36 1 MSINT = (10-1) | 0x80; // MSINT = 10ms for Tone period time base
37 1 PDCON = 0x1D; // Powerup SysTimer
38 1
39 1 FTCON = 0xA5; // setup flash programming times
40 1
41 1 EICON = 0x40; //DIS enable all auxiliary interrupts
42 1
43 1 EA = 1; //DIS Enable global interrupt flag
44 1
45 1 ISDwait (); // wait for connection to uVision2 Debugger
46 1 //Config PWM
47 1 P3 = 0xFF ; //Config P3's PWM
48 1 P3DDRL = 0x40;
49 1 PDCON &= 0xED; //Turn on PWM power
50 1 PWMCON =0 ; //Config period time
51 1 PWM = 200;
52 1 PWMCON = 0x10; //Config pwmduty
53 1 PWM = 20;
54 1 PWMCON = 0x01; //Select time speed using USEC,permit pwm function
55 1 while (1) {
C51 COMPILER V7.50 PWM 08/19/2006 09:45:24 PAGE 2
56 2 printf("PWM is normal\n");
57 2 PWMCON = 0x10;
58 2 PWM = 150 ;
59 2 PWMCON = 0x01; //Select time speed using USEC,permit pwm function
60 2 delay();
61 2 PWMCON = 0x10;
62 2 GreenLed = 0; //调试指示灯
63 2 PWM = 10;
64 2 PWMCON = 0x01; //Select time speed using USEC,permit pwm function
65 2 delay();
66 2 GreenLed = 1;
67 2 }
68 1 }
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 166 ----
CONSTANT SIZE = 15 ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = ---- 4
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 + -