?? pwm842.lst
字號:
C51 COMPILER V5.50, PWM842 17/10/03 18:03:03 PAGE 1
DOS C51 COMPILER V5.50, COMPILATION OF MODULE PWM842
OBJECT MODULE PLACED IN PWM842.OBJ
COMPILER INVOKED BY: C:\ADUC\BIN\C51.EXE PWM842.C DB
stmt level source
1 //pwm842.c
2 /*
3 Author: Eckart Hartmann Date:09/10/2003
4 Description of Software:
5 This program demonstrates the PWM functions
6 <A HREF="/mcc/softw/842/pwm/Pwm842Cfg.html">PwmCfg()</A>,<A HREF="/mcc/softw/842/pwm/Pwm842W16.html">PwmW
-16()</A>, <A HREF="/mcc/softw/842/pwm/Pwm842W8.html">PwmW8()</A>.
7 Development progress: <A HREF="/mcc/softw/834/pwm/Pwm834Df.html">pwm834.df</A>.
8 */
9 #include"..\kei842.h" //;<A HREF="/mcc/softw/842/Kei842Sfr.html">SFR definition file</A>.
10 #include"..\lib842.h" //;<A HREF="/mcc/softw/842/Lib842H.html">Function and variable declaration file</A>.
11 #include<stdio.h> //"stdio.h"
12 #include<ctype.h> //"ctype.h"
13
14 unsigned int uPwm;
15
16 //Use T1 interupt to ramp uPwm at constant rate.
17 void t0int(void) interrupt 1 using 0
18 {
19 1 uPwm += 4;
20 1 P34 = !P34;
21 1 }
22
23 void t1int(void) interrupt 3 using 0
24 {
25 1 uPwm += 4;
26 1 P34 = !P34;
27 1 }
28
29 void main(void)
30 {
31 1 unsigned int u1;
32 1 double dY; //Factor to liniarize PWM in NRZ mode.
33 1
34 1 PwmW8(0,0,0);
35 1 uPwm = 16000;
36 1 TH0 = 10;
37 1 TL0 = 10;
38 1 TMOD |= 0x2; //T0 reload.
39 1 TR0 = 1; //Start T0.
40 1 IE = 0x82; //Enable T0 interupt.
41 1 UrtCfg(0x33,0x832d); //<A HREF="/mcc/softw/842/urt/Urt842Cfg.html">UrtCfg</A> configures UART.
42 1
43 1 printf("\n\nADuC842 PWM Demonstration Program\n");
44 1 printf("=======================================\n");
45 1 printf("Connect 10k resistor from P2.6 (PWM out)\n");
46 1 printf("via 100nF to ground. Connect oscilloscope\n");
47 1 printf("accross capacitor. Repeat for P2.7.\n");
48 1 printf("Oscilloscope will show slow ramps.\n");
49 1
50 1 dY = 0.001; //Typical value.
51 1 PwmCfg(0x067); //Dual RZ sigma delta at fosc/4.
52 1
53 1 while(1)
54 1 {
55 2 u1 = uPwm-(int)((uPwm-0x8000)*dY);
56 2 if(uPwm<0x8000) u1 = uPwm;
57 2 PwmW16(1,u1); //Corrected.
58 2 PwmW16(0,uPwm); //Plain.
C51 COMPILER V5.50, PWM842 17/10/03 18:03:03 PAGE 2
59 2 } }
60
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 229 ----
CONSTANT SIZE = 236 ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = 4 6
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 + -