📄 upsd3300_pca-pwm.lst
字号:
C51 COMPILER V7.50 UPSD3300_PCA_PWM 07/11/2005 15:30:33 PAGE 1
C51 COMPILER V7.50, COMPILATION OF MODULE UPSD3300_PCA_PWM
OBJECT MODULE PLACED IN upsd3300_pca-pwm.OBJ
COMPILER INVOKED BY: C:\keil\C51\BIN\C51.EXE upsd3300_pca-pwm.c OPTIMIZE(9,SIZE) BROWSE DEBUG OBJECTEXTEND
line level source
1 /*------------------------------------------------------------------------------
2 upsd3300_pca-pwm.c
3
4 Version:
5 August 2004 Version 2.0 - Updated include file names, modified comments.
6
7 Dependencies: None.
8
9 Description:
10 The uPSD3300 PCA-PWM device driver is intended to provide a set of standard
11 functions for using the PCA-PWM features. The various modes of the PCA-PWM are:
12 Mode0 - Stop
13 Mode1 - 8-bit fixed frequency PWM
14 Mode2 - 8-bit variable frequency PWM
15 Mode3 - 16-bit fixed frequency PWM
16
17
18 Copyright (c) 2004 STMicroelectronics Inc.
19
20 This example demo code is provided as is and has no warranty,
21 implied or otherwise. You are free to use/modify any of the provided
22 code at your own risk in your applications with the expressed limitation
23 of liability (see below) so long as your product using the code contains
24 at least one uPSD product (device).
25
26 LIMITATION OF LIABILITY: NEITHER STMicroelectronics NOR ITS VENDORS OR
27 AGENTS SHALL BE LIABLE FOR ANY LOSS OF PROFITS, LOSS OF USE, LOSS OF DATA,
28 INTERRUPTION OF BUSINESS, NOR FOR INDIRECT, SPECIAL, INCIDENTAL OR
29 CONSEQUENTIAL DAMAGES OF ANY KIND WHETHER UNDER THIS AGREEMENT OR
30 OTHERWISE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
31 ------------------------------------------------------------------------------*/
32
33 #include "upsd3300.h"
34 #include "upsd3300_pca-pwm.h"
35
36
37 /*------------------------------------------------------------------------------
38 PWM_Mode1_Init(channel, duty_cycle)
39
40 This function initializes the PCA to function in PWM Mode 1 with the specified
41 duty cycle.
42
43 channel - unsigned char
44 - Channel to initialize (only 0 is supported at this time).
45 duty_cycle - unsigned char
46 - sets the duty cycle for the pulse
47 ------------------------------------------------------------------------------*/
48 void PWM_Mode1_Init(unsigned char channel, unsigned char duty_cycle)
49 {
50 1 switch(channel)
51 1 {
52 2 case 0:
53 2 P4SFS0 |= 0x01;
54 2 P4SFS1 &= 0xFE;
55 2 PCACL0 = PCACH0 = 0x00;
C51 COMPILER V7.50 UPSD3300_PCA_PWM 07/11/2005 15:30:33 PAGE 2
56 2 CCON2 = 0x10;
57 2 PCACON0 = 0x00;
58 2 TCMMODE0 = 0x41; //CAPCOML0=CAPCOMH0=duty_cycle;
59 2 CAPCOMH0 = duty_cycle;
60 2 PCACON0 |= 0x40;
61 2 break;
62 2
63 2 case 1:
64 2 break;
65 2 }
66 1 }
67
68
69 /*------------------------------------------------------------------------------
70 PwmInit_Mode1(PwmDuty_Mode1)
71
72 This function initializes the PCA to function in PWM Mode 1 with the specified
73 duty cycle.
74
75 PwmDuty_Mode1 - unsigned char
76 - sets the duty cycle for the pulse.
77 ------------------------------------------------------------------------------*/
78 /*
79 void PwmInit_Mode1(unsigned char PwmDuty_Mode1)
80 {
81 {
82 //0.1 Configure pins as PCA function
83 P4SFS0=0xff;
84 P4SFS1=0;
85 //0.2 initialize PCA0 counter
86 PCACL0=PCACH0=0;
87
88 //1.1 set PCA0CLK frequency
89 CCON0=0x10;
90 //1.2 select PCA0CLK as PCA0 clock source
91 //2. Configure PCA0 Counter operating mode
92 PCACON0=0x00;
93 //3. Set TCM0 operationg mode
94 TCMMODE0=0x41;
95 //4. Set duty for TCM0
96 CAPCOML0=CAPCOMH0=PwmDuty_Mode1;
97 //5. Start PCA0 counter
98 PCACON0|=0x40;
99 }
100 }
101 */
102
103 /*------------------------------------------------------------------------------
104 PwmSetDuty_Mode1(PwmDuty_Mode1)
105
106 This function initializes the PCA to function in PWM Mode 1 with the specified
107 duty cycle.
108
109 PwmDuty_Mode1 - unsigned char
110 - sets the duty cycle for the pulse.
111 ------------------------------------------------------------------------------*/
112 /*
113 void PwmSetDuty_Mode1(unsigned char PwmDuty_Mode1)
114 {
115 CAPCOMH0=PwmDuty_Mode1;
116 }
117
C51 COMPILER V7.50 UPSD3300_PCA_PWM 07/11/2005 15:30:33 PAGE 3
118 */
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 28 ----
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)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -