📄 configtimer23.lst
字号:
C51 COMPILER V7.06 CONFIGTIMER23 04/13/2005 12:55:51 PAGE 1
C51 COMPILER V7.06, COMPILATION OF MODULE CONFIGTIMER23
OBJECT MODULE PLACED IN ConfigTimer23.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE ConfigTimer23.c OMF2 BROWSE INCDIR(..\..\..\..\Include;..\..\..\..\lib) DEF
-INE(FREQ433) DEBUG
stmt level source
1 /*****************************************************************************
2 * *
3 * ********** *
4 * ************ *
5 * *** *** *
6 * *** +++ *** *
7 * *** + + *** *
8 * *** + CHIPCON CC1010 *
9 * *** + + *** HAL - ConfigTimer23 *
10 * *** +++ *** *
11 * *** *** *
12 * *********** *
13 * ********* *
14 * *
15 *****************************************************************************
16 * *
17 *****************************************************************************
18 * Author: ROH *
19 *****************************************************************************
20 * Revision history: *
21 * *
22 * $Log: ConfigTimer23.c,v $
23 * Revision 1.1 2002/10/14 13:04:30 tos
24 * Initial version in CVS.
25 *
26 * *
27 ****************************************************************************/
28
29 #include <chipcon/hal.h>
30
31
32 //----------------------------------------------------------------------------
33 // ulong halConfigTimer23(...);
34 //
35 // Description:
36 // This function configures timer 2 or 3 (depending on the value given in
37 // _option_ as either an interrupt timer (an interrupt is generated at
38 // certain intervals in time, as specified by _period) or a pulse width
39 // modulator (PWM).
40 // If _period_ is specified as 0, then, in timer mode the timeout peiod will
41 // be set to the maximum possible, and in PWM mode the period will be
42 // set as long as possible. Using the PWM mode of timer 2/3 overrides the
43 // normal operation of ports P3.4/P3.5 and can thus not be used in conjunction
44 // with timer 0/1 configured as counters. The duty cycle is set to 50% (128/255)
45 // initially in PWM mode.
46 // The timer/PWM must be started with macro TIMERx_RUN(TRUE).
47 //
48 // Arguments:
49 // byte options
50 // Options indicating which timer to configure and how. Different
51 // constants for _option_ is defined below.
52 // ulong period
53 // The desired period between interrupts in microseconds. In PWM mode
54 // the duty cycle will be set as close to 50% as possible. This duty
C51 COMPILER V7.06 CONFIGTIMER23 04/13/2005 12:55:51 PAGE 2
55 // cycle can be changed (in an ISR or at any other time) by using the
56 // appropriate PWMx_SET_DUTY_CYCLE(...) macro. If _period_
57 // is 0, then the maximum period possible will be set. The period can
58 // also be adjusted dynamically with the PWMx_SET_PERIOD(...) macro.
59 // word clkFreq
60 // The XOSC clock frequency in kHz.
61 //
62 // Return value:
63 // ulong
64 // The actual period in microseconds or zero if the desired period is
65 // too high.
66 //----------------------------------------------------------------------------
67 ulong halConfigTimer23(byte options, ulong period, word clkFreq) {
68 1 byte tx, txpre, mode;
69 1
70 1 period = (period*clkFreq+127500)/255000;
71 1 if (period)
72 1 period--;
73 1 mode=0;
74 1 if (options&TIMER23_PWM) {
75 2 // PWM mode selected
76 2 if (period&0xFFFFFF00) // >255
77 2 return 0;
78 2 txpre=(byte)period;
79 2 tx=128;
80 2 mode=1;
81 2 } else {
82 2 // Timer mode selected
83 2 if (period&0xFFFF0000) // >63535
84 2 return 0;
85 2 txpre=(byte)((word)period>>8);
86 2 tx=(byte)period;
87 2 }
88 1
89 1 if (options&TIMER3) {
90 2 // Timer 3 selected
91 2 if (options&TIMER23_INT_TIMER) {
92 3 EXIF&=~0x80; // Clear interrupt flag
93 3 ET3=1; // Enable timer interrupt
94 3 EA=1; // Enable global interrupt
95 3 }
96 2 T3PRE=txpre;
97 2 T3=tx;
98 2 TCON2=(TCON2&~0x0C)|(mode<<2);
99 2 } else {
100 2 // Timer 2 selected
101 2 if (options&TIMER23_INT_TIMER) {
102 3 EXIF&=~0x20; // Clear interrupt flag
103 3 ET2=1; // Enable timer interrupt
104 3 EA=1; // Enable global interrupt
105 3 }
106 2 T2PRE=txpre;
107 2 T2=tx;
108 2 TCON2=(TCON2&~0x03)|mode;
109 2 }
110 1 period=(period+1)*255000/clkFreq;
111 1 return period;
112 1 }
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 258 ----
C51 COMPILER V7.06 CONFIGTIMER23 04/13/2005 12:55:51 PAGE 3
CONSTANT SIZE = ---- ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = ---- 9
IDATA SIZE = ---- ----
BIT SIZE = ---- ----
EDATA SIZE = ---- ----
HDATA SIZE = ---- ----
XDATA CONST SIZE = ---- ----
FAR CONST SIZE = ---- ----
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -