📄 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\
-iD:\visteon\Test\Interval
-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 :
15 :
16 : /*
17 : *******************************************************************************
18 : **
19 : ** This device driver was created by Applilet for the 78K0/KB2, 78K0/KC2,
20 : ** 78K0/KD2, 78K0/KE2 and 78K0/KF2 8-Bit Single-Chip Microcontrollers.
21 : **
22 : ** Filename : timer_config.h
23 : ** Abstract : This file implements a device driver for the timer module
24 : ** Device : uPD78F0547
25 : ** Compiler: NEC/CC78K0
26 : **
27 : *******************************************************************************
28 : */
29 :
30 : /*
31 : *******************************************************************************
32 : ** Case : Square wave output function
33 : **
34 : ** Description : Output squarewave
35 : **
36 : ** Setting : fprs = 8MHz
37 : ** TM00 interval time = 0.5s
38 : ** TM01 interval time = 0.5s
39 : ** TM50 interval time = 0.25s
40 : ** TM51 interval time = 0.125s
41 : ** TMH0 interval time = 0.03125s%
42 : ** TMH1 interval time = 0.125s
43 : **
44 : *******************************************************************************
45 : */
/*
78K/0 Series C Compiler V3.60 Preprocess List Date: 9 Oct 2005 Page: 2
*/
46 :
47 :
48 : /*
49 : *******************************************************************************
50 : **
51 : ** This device driver was created by Applilet for the 78K0/KB2, 78K0/KC2,
52 : ** 78K0/KD2, 78K0/KE2 and 78K0/KF2 8-Bit Single-Chip Microcontrollers.
53 : **
54 : ** Filename : timer.h
55 : ** Abstract : This file implements a device driver for the timer module
56 : ** Device : uPD78F0547
57 : ** Compiler: NEC/CC78K0
58 : **
59 : *******************************************************************************
60 : */
61 :
62 :
63 : #define _TIMERMACRO_
64 :
65 : /*
66 : *******************************************************************************
67 : ** Register bit define
68 : *******************************************************************************
69 : */
70 :
71 : /* TM0n register bit define */
72 :
73 : /* TM0n register TMC0n */
74 : #define TM0n_TMC0n_Operation 0x0c
75 : #define TM0n_TMC0n_Operation_Disable 0x00
76 : #define TM0n_TMC0n_Operation_FreeRunning 0x04
77 : #define TM0n_TMC0n_Operation_ClearByTI00nEdge 0x08
78 : #define TM0n_TMC0n_Operation_ClearByMatchCR00n 0x0c
79 :
80 : #define TM0n_TMC0n_Reverse 0x02
81 : #define TM0n_TMC0n_Reverse_ByMatchCR00n 0x00
82 : #define TM0n_TMC0n_Reverse_ByMatchCR00nAndTI00nInput 0x02
83 :
84 : #define TM0n_TMC0n_OverflowFlag 0x01
85 :
86 : /* TM0n register CRC0n */
87 : #define TM0n_CRC0n_CR01nMode 0x04
88 : #define TM0n_CRC0n_CR01nMode_Compare 0x00
89 : #define TM0n_CRC0n_CR01nMode_Capture 0x04
90 :
91 : #define TM0n_CRC0n_CR00nTrigger 0x02
92 : #define TM0n_CRC0n_CR00nTrigger_TI01nEdge 0x00
93 : #define TM0n_CRC0n_CR00nTrigger_TI00nEdgeReverse 0x02
94 :
95 : #define TM0n_CRC0n_CR00nMode 0x01
96 : #define TM0n_CRC0n_CR00nMode_Compare 0x00
97 : #define TM0n_CRC0n_CR00nMode_Capture 0x01
98 :
99 : /* TM0n register TOC0n */
100 : #define TM0n_TOC0n_OneshotSoftTrigger 0x40 /* write only */
101 :
/*
78K/0 Series C Compiler V3.60 Preprocess List Date: 9 Oct 2005 Page: 3
*/
102 : #define TM0n_TOC0n_OneshotMode 0x20
103 : #define TM0n_TOC0n_OneshotMode_Successive 0x00
104 : #define TM0n_TOC0n_OneshotMode_Oneshot 0x20
105 :
106 : #define TM0n_TOC0n_ReverseTO0nByCR01n 0x10
107 : #define TM0n_TOC0n_ReverseTO0nByCR01n_Disable 0x00
108 : #define TM0n_TOC0n_ReverseTO0nByCR01n_Enable 0x10
109 :
110 : #define TM0n_TOC0n_TO0nOutStatus 0x0C
111 : #define TM0n_TOC0n_TO0nOut_NoChange 0x00
112 : #define TM0n_TOC0n_TO0nOut_Clear0 0x04
113 : #define TM0n_TOC0n_TO0nOut_Set1 0x08
114 : #define TM0n_TOC0n_TO0nOut_Prohibited 0x0C
115 :
116 : #define TM0n_TOC0n_TO0nReverseByCR00n 0x02
117 : #define TM0n_TOC0n_TO0nReverseByCR00n_Disable 0x00
118 : #define TM0n_TOC0n_TO0nReverseByCR00n_Enable 0x02
119 :
120 : #define TM0n_TOC0n_TO0nOutControl 0x01
121 : #define TM0n_TOC0n_TO0nOut_Disable 0x00
122 : #define TM0n_TOC0n_TO0nOut_Enable 0x01
123 :
124 : /* TM0n register PRM0n */
125 : #define TM0n_PRM0n_TI01nEdge 0xc0
126 : #define TM0n_PRM0n_TI01nEdge_Falling 0x00
127 : #define TM0n_PRM0n_TI01nEdge_Rising 0x40
128 : #define TM0n_PRM0n_TI01nEdge_Prohibited 0x80
129 : #define TM0n_PRM0n_TI01nEdge_Both 0xc0
130 :
131 : #define TM0n_PRM0n_TI00nEdge 0x30
132 : #define TM0n_PRM0n_TI00nEdge_Falling 0x00
133 : #define TM0n_PRM0n_TI00nEdge_Rising 0x10
134 : #define TM0n_PRM0n_TI00nEdge_Prohibited 0x20
135 : #define TM0n_PRM0n_TI00nEdge_Both 0x30
136 :
137 : #define TM0n_PRM0n_CountClock 0x03
138 : #define TM0n_PRM0n_CountClock_Internal0 0x00 /* TM00 = fprs, TM00 = fprs */
139 : #define TM0n_PRM0n_CountClock_Internal1 0x01 /* TM00 = fprs/2^2, TM00 = fprs/2^4 */
140 : #define TM0n_PRM0n_CountClock_Internal2 0x02 /* TM00 = fprs/2^8, TM00 = fprs/2^6 */
141 : #define TM0n_PRM0n_CountClock_TI00nEdge 0x03
142 :
143 : /* TM5n register bit define */
144 :
145 : /* TM5n register TCL5n */
146 : #define TM5n_TCL5n_CountCloc 0x07
147 : #define TM5n_TCL5n_CountClock_TI5nFalling 0x00
148 : #define TM5n_TCL5n_CountClock_TI5nRising 0x01
149 : #define TM5n_TCL5n_CountClock_Internal0 0x02 /* TM50 = fprs, TM51 = fprs */
150 : #define TM5n_TCL5n_CountClock_Internal1 0x03 /* TM50 = fprs/2, TM51 = fprs/2 */
151 : #define TM5n_TCL5n_CountClock_Internal2 0x04 /* TM50 = fprs/2^2, TM51 = fprs/2^4 */
152 : #define TM5n_TCL5n_CountClock_Internal3 0x05 /* TM50 = fprs/2^6, TM51 = fprs/2^6 */
153 : #define TM5n_TCL5n_CountClock_Internal4 0x06 /* TM50 = fprs/2^8, TM51 = fprs/2^8 */
154 : #define TM5n_TCL5n_CountClock_Internal5 0x07 /* TM50 = fprs/2^13, TM51 = fprs/2^12 */
155 :
156 : /* TM5n register TMC5n */
157 : #define TM5n_TMC5n_Operation 0x80
/*
78K/0 Series C Compiler V3.60 Preprocess List Date: 9 Oct 2005 Page: 4
*/
158 : #define TM5n_TMC5n_Operation_Disable 0x00
159 : #define TM5n_TMC5n_Operation_Start 0x80
160 :
161 : #define TM5n_TMC5n_Mode 0x40
162 : #define TM5n_TMC5n_Mode_ClearByMatchCR5n 0x00
163 : #define TM5n_TMC5n_Mode_PWMFreeRunning 0x40
164 :
165 : #define TM5n_TMC5n_OutPutStatus 0x0C
166 : #define TM5n_TMC5n_OutPut_NoChange 0x00
167 : #define TM5n_TMC5n_OutPut_Clear0 0x04
168 : #define TM5n_TMC5n_OutPut_Set1 0x08
169 : #define TM5n_TMC5n_OutPut_Prohibited 0x0C
170 :
171 : #define TM5n_TMC5n_OutPutActiveLevel 0x02
172 : #define TM5n_TMC5n_OutPut_NoInversionActiveHigh 0x00
173 : #define TM5n_TMC5n_OutPut_InversionActiveLow 0x02
174 :
175 : #define TM5n_TMC5n_OutPutControl 0x01
176 : #define TM5n_TMC5n_OutPut_Disable 0x00
177 : #define TM5n_TMC5n_OutPut_Enable 0x01
178 :
179 : /* TMHn register bit define */
180 :
181 : /* TMHn register TMHMDn */
182 : #define TMHn_TMHMDn_Operation 0x80
183 : #define TMHn_TMHMDn_Operation_Stop 0x00
184 : #define TMHn_TMHMDn_Operation_Enable 0x80
185 :
186 : #define TMHn_TMHMDn_CountClock 0x70
187 : #define TMHn_TMHMDn_CountClock_Internal0 0x00 /* TMH0 = fprs, TMH1 = fprs */
188 : #define TMHn_TMHMDn_CountClock_Internal1 0x10 /* TMH0 = fprs/2, TMH1 = fprs/2 */
189 : #define TMHn_TMHMDn_CountClock_Internal2 0x20 /* TMH0 = fprs/2^2, TMH1 = fprs/2^4 */
190 : #define TMHn_TMHMDn_CountClock_Internal3 0x30 /* TMH0 = fprs/2^6, TMH1 = fprs/2^6 */
191 : #define TMHn_TMHMDn_CountClock_Internal4 0x40 /* TMH0 = fprs/2^8, TMH1 = fprs/2^8 */
192 : #define TMHn_TMHMDn_CountClock_Internal5 0x50 /* TMH0 = fprs/2^13, TMH1 = frl/2^7 */
193 : #define TMHn_TMHMDn_CountClock_Internal6 0x60 /* TMH0 = fprs/2^13, TMH1 = frl/2^9 */
194 : #define TMHn_TMHMDn_CountClock_Internal7 0x70 /* TMH0 = fprs/2^13, TMH1 = frl */
195 :
196 : #define TMHn_TMHMDn_Mode 0x0c
197 : #define TMHn_TMHMDn_Mode_Interval 0x00
198 : #define TMHn_TMHMDn_Mode_Carrier 0x04
199 : #define TMHn_TMHMDn_Mode_PWM 0x08
200 :
201 : #define TMHn_TMHMDn_Level_Low 0x00
202 : #define TMHn_TMHMDn_Level_High 0x02
203 :
204 : #define TMHn_TMHMDn_OutPut_Disable 0x00
205 : #define TMHn_TMHMDn_Output_Enable 0x01
206 :
207 : /* TMHn register TMCYC1(TMH1 only) */
208 : #define TMHn_TMCYC1_Remote 0x06
209 : #define TMHn_TMCYC1_Remote_Low 0x00
210 : #define TMHn_TMCYC1_Remote_High 0x02
211 : #define TMHn_TMCYC1_Remote_Low2 0x04
212 : #define TMHn_TMCYC1_Remote_Carrier 0x06
213 :
/*
78K/0 Series C Compiler V3.60 Preprocess List Date: 9 Oct 2005 Page: 5
*/
214 : #define TMHn_TMCYC1_CarrierStatus 0x01
215 : #define TMHn_TMCYC1_Carrier_Disable 0x00
216 : #define TMHn_TMCYC1_Carrier_Enable 0x01
217 :
218 :
219 :
220 :
221 : #define _TIMERCFG_
222 :
223 : /*
224 : *******************************************************************************
225 : ** User control macro define
226 : *******************************************************************************
227 : */
228 :
229 : /*
230 : ***************************************
231 : ** TM00 configure
232 : **
233 : ** Please set operation mode here
234 : ***************************************
235 : */
236 : /* if no use set nouse = 1, if use some function set function = 1 */
237 : #define TM00_NotUse 0
238 : #define TM00_Interval 1
239 : #define TM00_ExternalEvent 0
240 : #define TM00_SquareOut 0
241 : #define TM00_PPGOut 0
242 : #define TM00_OneshotOut 0
243 : #define TM00_PulseMeasurement 0
244 : /* if no use some method of pulse measurement set method = 1 */
245 : #define TM00_Pulse_TI00nAndTI01nFreeRunning 1
246 : #define TM00_Pulse_TI00nFreeRunning 0
247 : #define TM00_Pulse_TI00nRestart 0
248 :
249 : /* macro for setting of different functions */
250 :
251 : /*
252 : ***************************************
253 : ** TM00 interval
254 : **
255 : ** user set interval time = 0.5s
256 : ***************************************
257 : */
258 :
259 : /* Count clock and compare value */
260 : /* Use register bit macro
261 : TM0n_PRM0n_CountClock_Internal0 : fprs or
262 : TM0n_PRM0n_CountClock_Internal1 : fprs/2^2 or
263 : TM0n_PRM0n_CountClock_Internal2 : fprs/2^8 or
264 : TM0n_PRM0n_CountClock_TI00nEdge
265 : TM0n_PRM0n_TI00nEdge_Falling or
266 : TM0n_PRM0n_TI01nEdge_Rising or
267 : TM0n_PRM0n_TI01nEdge_Both
268 : Note : Please select the higher frequency you can,
269 : so the precision will be higher.
/*
78K/0 Series C Compiler V3.60 Preprocess List Date: 9 Oct 2005 Page: 6
*/
270 : */
271 : #define TM00_Clock TM0n_PRM0n_CountClock_Internal2
272 : /*
273 : Value range : 0x0001 - 0xffff
274 : Interval time = (CR00n_value + 1) * count_clock
275 : */
276 : #define TM00_CR00nValue 0x3d08
277 : #define TM00_CR01nValue 0xffff
278 :
279 : /* Register settings */
280 : #define TM00_TMC0nValue TM0n_TMC0n_Operation_ClearByMatchCR00n
281 : #define TM00_PRM0nValue TM00_Clock
282 : #define TM00_CRC0nValue TM0n_CRC0n_CR00nMode_Compare
283 :
284 : /* Interrupt settings */
285 : #define TM00_INTTM000 1
286 : #define TM00_INTTM010 0
287 :
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -