📄 timer_user.ppl
字号:
/*
78K/0 Series C Compiler V3.60 Preprocess List Date: 9 Oct 2005 Page: 1
Command : -ftimer_user.pcc
In-file : timer_user.c
PPL-file : timer_user.ppl
Para-file : -cF054780
-yC:\NECTools32\DEV\
-p
-kfiln
-zn
timer_user.c
*/
1 : /*
2 : *******************************************************************************
3 : **
4 : ** This device driver was created by Applilet for the 78K0/KB2, 78K0/KC2,
5 : ** 78K0/KD2, 78K0/KE2 and 78K0/KF2 8-Bit Single-Chip Microcontrollers.
6 : **
7 : ** Filename : timer_user.c
8 : ** Abstract : This file implements a device driver for the timer module
9 : ** Device : uPD78F0547
10 : ** Compiler: NEC/CC78K0
11 : **
12 : *******************************************************************************
13 : */
14 : #pragma sfr
15 :
16 :
17 : /*
18 : *******************************************************************************
19 : **
20 : ** This device driver was created by Applilet for the 78K0/KB2, 78K0/KC2,
21 : ** 78K0/KD2, 78K0/KE2 and 78K0/KF2 8-Bit Single-Chip Microcontrollers.
22 : **
23 : ** Filename : timer.h
24 : ** Abstract : This file implements a device driver for the timer module
25 : ** Device : uPD78F0547
26 : ** Compiler: NEC/CC78K0
27 : **
28 : *******************************************************************************
29 : */
30 :
31 :
32 : /*
33 : *******************************************************************************
34 : **
35 : ** This device driver was created by Applilet for the 78K0/KB2, 78K0/KC2,
36 : ** 78K0/KD2, 78K0/KE2 and 78K0/KF2 8-Bit Single-Chip Microcontrollers.
37 : **
38 : ** Filename : timer_config.h
39 : ** Abstract : This file implements a device driver for the timer module
40 : ** Device : uPD78F0547
41 : ** Compiler: NEC/CC78K0
42 : **
43 : *******************************************************************************
44 : */
45 :
46 : /*
/*
78K/0 Series C Compiler V3.60 Preprocess List Date: 9 Oct 2005 Page: 2
*/
47 : *******************************************************************************
48 : ** Case : Square wave output function
49 : **
50 : ** Description : Output squarewave
51 : **
52 : ** Setting : fprs = 8MHz
53 : ** TM00 cycle = 0.003s, duty = 30%
54 : ** TM01 cycle = 0.006s, duty = 60%
55 : ** TM50 cycle = 0.002048s, duty = 40%
56 : ** TM51 cycle = 0.002048s, duty = 80%
57 : ** TMH0 cycle = 0.005s, duty = 25%
58 : ** TMH1 cycle = 0.01s, duty = 50%
59 : **
60 : *******************************************************************************
61 : */
62 :
63 :
64 : /*
65 : *******************************************************************************
66 : **
67 : ** This device driver was created by Applilet for the 78K0/KB2, 78K0/KC2,
68 : ** 78K0/KD2, 78K0/KE2 and 78K0/KF2 8-Bit Single-Chip Microcontrollers.
69 : **
70 : ** Filename : timer.h
71 : ** Abstract : This file implements a device driver for the timer module
72 : ** Device : uPD78F0547
73 : ** Compiler: NEC/CC78K0
74 : **
75 : *******************************************************************************
76 : */
77 :
78 :
79 : #define _TIMERMACRO_
80 :
81 : /*
82 : *******************************************************************************
83 : ** Register bit define
84 : *******************************************************************************
85 : */
86 :
87 : /* TM0n register bit define */
88 :
89 : /* TM0n register TMC0n */
90 : #define TM0n_TMC0n_Operation 0x0c
91 : #define TM0n_TMC0n_Operation_Disable 0x00
92 : #define TM0n_TMC0n_Operation_FreeRunning 0x04
93 : #define TM0n_TMC0n_Operation_ClearByTI00nEdge 0x08
94 : #define TM0n_TMC0n_Operation_ClearByMatchCR00n 0x0c
95 :
96 : #define TM0n_TMC0n_Reverse 0x02
97 : #define TM0n_TMC0n_Reverse_ByMatchCR00n 0x00
98 : #define TM0n_TMC0n_Reverse_ByMatchCR00nAndTI00nInput 0x02
99 :
100 : #define TM0n_TMC0n_OverflowFlag 0x01
101 :
102 : /* TM0n register CRC0n */
/*
78K/0 Series C Compiler V3.60 Preprocess List Date: 9 Oct 2005 Page: 3
*/
103 : #define TM0n_CRC0n_CR01nMode 0x04
104 : #define TM0n_CRC0n_CR01nMode_Compare 0x00
105 : #define TM0n_CRC0n_CR01nMode_Capture 0x04
106 :
107 : #define TM0n_CRC0n_CR00nTrigger 0x02
108 : #define TM0n_CRC0n_CR00nTrigger_TI01nEdge 0x00
109 : #define TM0n_CRC0n_CR00nTrigger_TI00nEdgeReverse 0x02
110 :
111 : #define TM0n_CRC0n_CR00nMode 0x01
112 : #define TM0n_CRC0n_CR00nMode_Compare 0x00
113 : #define TM0n_CRC0n_CR00nMode_Capture 0x01
114 :
115 : /* TM0n register TOC0n */
116 : #define TM0n_TOC0n_OneshotSoftTrigger 0x40 /* write only */
117 :
118 : #define TM0n_TOC0n_OneshotMode 0x20
119 : #define TM0n_TOC0n_OneshotMode_Successive 0x00
120 : #define TM0n_TOC0n_OneshotMode_Oneshot 0x20
121 :
122 : #define TM0n_TOC0n_ReverseTO0nByCR01n 0x10
123 : #define TM0n_TOC0n_ReverseTO0nByCR01n_Disable 0x00
124 : #define TM0n_TOC0n_ReverseTO0nByCR01n_Enable 0x10
125 :
126 : #define TM0n_TOC0n_TO0nOutStatus 0x0C
127 : #define TM0n_TOC0n_TO0nOut_NoChange 0x00
128 : #define TM0n_TOC0n_TO0nOut_Clear0 0x04
129 : #define TM0n_TOC0n_TO0nOut_Set1 0x08
130 : #define TM0n_TOC0n_TO0nOut_Prohibited 0x0C
131 :
132 : #define TM0n_TOC0n_TO0nReverseByCR00n 0x02
133 : #define TM0n_TOC0n_TO0nReverseByCR00n_Disable 0x00
134 : #define TM0n_TOC0n_TO0nReverseByCR00n_Enable 0x02
135 :
136 : #define TM0n_TOC0n_TO0nOutControl 0x01
137 : #define TM0n_TOC0n_TO0nOut_Disable 0x00
138 : #define TM0n_TOC0n_TO0nOut_Enable 0x01
139 :
140 : /* TM0n register PRM0n */
141 : #define TM0n_PRM0n_TI01nEdge 0xc0
142 : #define TM0n_PRM0n_TI01nEdge_Falling 0x00
143 : #define TM0n_PRM0n_TI01nEdge_Rising 0x40
144 : #define TM0n_PRM0n_TI01nEdge_Prohibited 0x80
145 : #define TM0n_PRM0n_TI01nEdge_Both 0xc0
146 :
147 : #define TM0n_PRM0n_TI00nEdge 0x30
148 : #define TM0n_PRM0n_TI00nEdge_Falling 0x00
149 : #define TM0n_PRM0n_TI00nEdge_Rising 0x10
150 : #define TM0n_PRM0n_TI00nEdge_Prohibited 0x20
151 : #define TM0n_PRM0n_TI00nEdge_Both 0x30
152 :
153 : #define TM0n_PRM0n_CountClock 0x03
154 : #define TM0n_PRM0n_CountClock_Internal0 0x00 /* TM00 = fprs, TM00 = fprs */
155 : #define TM0n_PRM0n_CountClock_Internal1 0x01 /* TM00 = fprs/2^2, TM00 = fprs/2^4 */
156 : #define TM0n_PRM0n_CountClock_Internal2 0x02 /* TM00 = fprs/2^8, TM00 = fprs/2^6 */
157 : #define TM0n_PRM0n_CountClock_TI00nEdge 0x03
158 :
/*
78K/0 Series C Compiler V3.60 Preprocess List Date: 9 Oct 2005 Page: 4
*/
159 : /* TM5n register bit define */
160 :
161 : /* TM5n register TCL5n */
162 : #define TM5n_TCL5n_CountCloc 0x07
163 : #define TM5n_TCL5n_CountClock_TI5nFalling 0x00
164 : #define TM5n_TCL5n_CountClock_TI5nRising 0x01
165 : #define TM5n_TCL5n_CountClock_Internal0 0x02 /* TM50 = fprs, TM51 = fprs */
166 : #define TM5n_TCL5n_CountClock_Internal1 0x03 /* TM50 = fprs/2, TM51 = fprs/2 */
167 : #define TM5n_TCL5n_CountClock_Internal2 0x04 /* TM50 = fprs/2^2, TM51 = fprs/2^4 */
168 : #define TM5n_TCL5n_CountClock_Internal3 0x05 /* TM50 = fprs/2^6, TM51 = fprs/2^6 */
169 : #define TM5n_TCL5n_CountClock_Internal4 0x06 /* TM50 = fprs/2^8, TM51 = fprs/2^8 */
170 : #define TM5n_TCL5n_CountClock_Internal5 0x07 /* TM50 = fprs/2^13, TM51 = fprs/2^12 */
171 :
172 : /* TM5n register TMC5n */
173 : #define TM5n_TMC5n_Operation 0x80
174 : #define TM5n_TMC5n_Operation_Disable 0x00
175 : #define TM5n_TMC5n_Operation_Start 0x80
176 :
177 : #define TM5n_TMC5n_Mode 0x40
178 : #define TM5n_TMC5n_Mode_ClearByMatchCR5n 0x00
179 : #define TM5n_TMC5n_Mode_PWMFreeRunning 0x40
180 :
181 : #define TM5n_TMC5n_OutPutStatus 0x0C
182 : #define TM5n_TMC5n_OutPut_NoChange 0x00
183 : #define TM5n_TMC5n_OutPut_Clear0 0x04
184 : #define TM5n_TMC5n_OutPut_Set1 0x08
185 : #define TM5n_TMC5n_OutPut_Prohibited 0x0C
186 :
187 : #define TM5n_TMC5n_OutPutActiveLevel 0x02
188 : #define TM5n_TMC5n_OutPut_NoInversionActiveHigh 0x00
189 : #define TM5n_TMC5n_OutPut_InversionActiveLow 0x02
190 :
191 : #define TM5n_TMC5n_OutPutControl 0x01
192 : #define TM5n_TMC5n_OutPut_Disable 0x00
193 : #define TM5n_TMC5n_OutPut_Enable 0x01
194 :
195 : /* TMHn register bit define */
196 :
197 : /* TMHn register TMHMDn */
198 : #define TMHn_TMHMDn_Operation 0x80
199 : #define TMHn_TMHMDn_Operation_Stop 0x00
200 : #define TMHn_TMHMDn_Operation_Enable 0x80
201 :
202 : #define TMHn_TMHMDn_CountClock 0x70
203 : #define TMHn_TMHMDn_CountClock_Internal0 0x00 /* TMH0 = fprs, TMH1 = fprs */
204 : #define TMHn_TMHMDn_CountClock_Internal1 0x10 /* TMH0 = fprs/2, TMH1 = fprs/2 */
205 : #define TMHn_TMHMDn_CountClock_Internal2 0x20 /* TMH0 = fprs/2^2, TMH1 = fprs/2^4 */
206 : #define TMHn_TMHMDn_CountClock_Internal3 0x30 /* TMH0 = fprs/2^6, TMH1 = fprs/2^6 */
207 : #define TMHn_TMHMDn_CountClock_Internal4 0x40 /* TMH0 = fprs/2^8, TMH1 = fprs/2^8 */
208 : #define TMHn_TMHMDn_CountClock_Internal5 0x50 /* TMH0 = fprs/2^13, TMH1 = frl/2^7 */
209 : #define TMHn_TMHMDn_CountClock_Internal6 0x60 /* TMH0 = fprs/2^13, TMH1 = frl/2^9 */
210 : #define TMHn_TMHMDn_CountClock_Internal7 0x70 /* TMH0 = fprs/2^13, TMH1 = frl */
211 :
212 : #define TMHn_TMHMDn_Mode 0x0c
213 : #define TMHn_TMHMDn_Mode_Interval 0x00
214 : #define TMHn_TMHMDn_Mode_Carrier 0x04
/*
78K/0 Series C Compiler V3.60 Preprocess List Date: 9 Oct 2005 Page: 5
*/
215 : #define TMHn_TMHMDn_Mode_PWM 0x08
216 :
217 : #define TMHn_TMHMDn_Level_Low 0x00
218 : #define TMHn_TMHMDn_Level_High 0x02
219 :
220 : #define TMHn_TMHMDn_OutPut_Disable 0x00
221 : #define TMHn_TMHMDn_Output_Enable 0x01
222 :
223 : /* TMHn register TMCYC1(TMH1 only) */
224 : #define TMHn_TMCYC1_Remote 0x06
225 : #define TMHn_TMCYC1_Remote_Low 0x00
226 : #define TMHn_TMCYC1_Remote_High 0x02
227 : #define TMHn_TMCYC1_Remote_Low2 0x04
228 : #define TMHn_TMCYC1_Remote_Carrier 0x06
229 :
230 : #define TMHn_TMCYC1_CarrierStatus 0x01
231 : #define TMHn_TMCYC1_Carrier_Disable 0x00
232 : #define TMHn_TMCYC1_Carrier_Enable 0x01
233 :
234 :
235 :
236 :
237 : #define _TIMERCFG_
238 :
239 : /*
240 : *******************************************************************************
241 : ** User control macro define
242 : *******************************************************************************
243 : */
244 :
245 : /*
246 : ***************************************
247 : ** TM00 configure
248 : **
249 : ** Please set operation mode here
250 : ***************************************
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -