MSP430 DriverLib for MSP430FR2xx_4xx Devices  2.91.13.01
timer_b.h
1 //*****************************************************************************
2 //
3 // timer_b.h - Driver for the TIMER_B Module.
4 //
5 //*****************************************************************************
6 
7 #ifndef __MSP430WARE_TIMER_B_H__
8 #define __MSP430WARE_TIMER_B_H__
9 
10 #include "inc/hw_memmap.h"
11 
12 #ifdef __MSP430_HAS_TxB7__
13 
14 //*****************************************************************************
15 //
16 // If building with a C++ compiler, make all of the definitions in this header
17 // have a C binding.
18 //
19 //*****************************************************************************
20 #ifdef __cplusplus
21 extern "C"
22 {
23 #endif
24 
25 #include "inc/hw_memmap.h"
26 //*****************************************************************************
27 //
28 // The following is a parameter used for Timer_B_getCounterValue that
29 // determines the maximum difference in counts of the TAxR register for a
30 // majority vote.
31 //
32 //*****************************************************************************
33 #define TIMER_B_THRESHOLD 50
34 
35 //*****************************************************************************
36 //
37 //! \brief Used in the Timer_B_outputPWM() function as the param parameter.
38 //
39 //*****************************************************************************
40 typedef struct Timer_B_outputPWMParam {
41  //! Selects the clock source
42  //! \n Valid values are:
43  //! - \b TIMER_B_CLOCKSOURCE_EXTERNAL_TXCLK [Default]
44  //! - \b TIMER_B_CLOCKSOURCE_ACLK
45  //! - \b TIMER_B_CLOCKSOURCE_SMCLK
46  //! - \b TIMER_B_CLOCKSOURCE_INVERTED_EXTERNAL_TXCLK
47  uint16_t clockSource;
48  //! Is the divider for Clock source.
49  //! \n Valid values are:
50  //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_1 [Default]
51  //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_2
52  //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_3
53  //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_4
54  //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_5
55  //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_6
56  //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_7
57  //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_8
58  //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_10
59  //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_12
60  //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_14
61  //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_16
62  //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_20
63  //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_24
64  //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_28
65  //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_32
66  //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_40
67  //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_48
68  //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_56
69  //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_64
71  //! Selects the desired Timer_B period
72  uint16_t timerPeriod;
73  //! Selects the compare register being used. Refer to datasheet to ensure
74  //! the device has the compare register being used.
75  //! \n Valid values are:
76  //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_0
77  //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_1
78  //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_2
79  //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_3
80  //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_4
81  //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_5
82  //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_6
83  uint16_t compareRegister;
84  //! Specifies the output mode.
85  //! \n Valid values are:
86  //! - \b TIMER_B_OUTPUTMODE_OUTBITVALUE [Default]
87  //! - \b TIMER_B_OUTPUTMODE_SET
88  //! - \b TIMER_B_OUTPUTMODE_TOGGLE_RESET
89  //! - \b TIMER_B_OUTPUTMODE_SET_RESET
90  //! - \b TIMER_B_OUTPUTMODE_TOGGLE
91  //! - \b TIMER_B_OUTPUTMODE_RESET
92  //! - \b TIMER_B_OUTPUTMODE_TOGGLE_SET
93  //! - \b TIMER_B_OUTPUTMODE_RESET_SET
95  //! Specifies the dutycycle for the generated waveform
96  uint16_t dutyCycle;
98 
99 //*****************************************************************************
100 //
101 //! \brief Used in the Timer_B_initUpMode() function as the param parameter.
102 //
103 //*****************************************************************************
104 typedef struct Timer_B_initUpModeParam {
105  //! Selects the clock source
106  //! \n Valid values are:
107  //! - \b TIMER_B_CLOCKSOURCE_EXTERNAL_TXCLK [Default]
108  //! - \b TIMER_B_CLOCKSOURCE_ACLK
109  //! - \b TIMER_B_CLOCKSOURCE_SMCLK
110  //! - \b TIMER_B_CLOCKSOURCE_INVERTED_EXTERNAL_TXCLK
111  uint16_t clockSource;
112  //! Is the divider for Clock source.
113  //! \n Valid values are:
114  //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_1 [Default]
115  //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_2
116  //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_3
117  //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_4
118  //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_5
119  //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_6
120  //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_7
121  //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_8
122  //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_10
123  //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_12
124  //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_14
125  //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_16
126  //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_20
127  //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_24
128  //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_28
129  //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_32
130  //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_40
131  //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_48
132  //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_56
133  //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_64
135  //! Is the specified Timer_B period. This is the value that gets written
136  //! into the CCR0. Limited to 16 bits[uint16_t]
137  uint16_t timerPeriod;
138  //! Is to enable or disable Timer_B interrupt
139  //! \n Valid values are:
140  //! - \b TIMER_B_TBIE_INTERRUPT_ENABLE
141  //! - \b TIMER_B_TBIE_INTERRUPT_DISABLE [Default]
143  //! Is to enable or disable Timer_B CCR0 capture compare interrupt.
144  //! \n Valid values are:
145  //! - \b TIMER_B_CCIE_CCR0_INTERRUPT_ENABLE
146  //! - \b TIMER_B_CCIE_CCR0_INTERRUPT_DISABLE [Default]
148  //! Decides if Timer_B clock divider, count direction, count need to be
149  //! reset.
150  //! \n Valid values are:
151  //! - \b TIMER_B_DO_CLEAR
152  //! - \b TIMER_B_SKIP_CLEAR [Default]
153  uint16_t timerClear;
154  //! Whether to start the timer immediately
157 
158 //*****************************************************************************
159 //
160 //! \brief Used in the Timer_B_initCaptureMode() function as the param
161 //! parameter.
162 //
163 //*****************************************************************************
165  //! Selects the capture register being used. Refer to datasheet to ensure
166  //! the device has the capture register being used.
167  //! \n Valid values are:
168  //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_0
169  //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_1
170  //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_2
171  //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_3
172  //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_4
173  //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_5
174  //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_6
175  uint16_t captureRegister;
176  //! Is the capture mode selected.
177  //! \n Valid values are:
178  //! - \b TIMER_B_CAPTUREMODE_NO_CAPTURE [Default]
179  //! - \b TIMER_B_CAPTUREMODE_RISING_EDGE
180  //! - \b TIMER_B_CAPTUREMODE_FALLING_EDGE
181  //! - \b TIMER_B_CAPTUREMODE_RISING_AND_FALLING_EDGE
182  uint16_t captureMode;
183  //! Decides the Input Select
184  //! \n Valid values are:
185  //! - \b TIMER_B_CAPTURE_INPUTSELECT_CCIxA [Default]
186  //! - \b TIMER_B_CAPTURE_INPUTSELECT_CCIxB
187  //! - \b TIMER_B_CAPTURE_INPUTSELECT_GND
188  //! - \b TIMER_B_CAPTURE_INPUTSELECT_Vcc
190  //! Decides if capture source should be synchronized with Timer_B clock
191  //! \n Valid values are:
192  //! - \b TIMER_B_CAPTURE_ASYNCHRONOUS [Default]
193  //! - \b TIMER_B_CAPTURE_SYNCHRONOUS
195  //! Is to enable or disable Timer_B capture compare interrupt.
196  //! \n Valid values are:
197  //! - \b TIMER_B_CAPTURECOMPARE_INTERRUPT_DISABLE [Default]
198  //! - \b TIMER_B_CAPTURECOMPARE_INTERRUPT_ENABLE
200  //! Specifies the output mode.
201  //! \n Valid values are:
202  //! - \b TIMER_B_OUTPUTMODE_OUTBITVALUE [Default]
203  //! - \b TIMER_B_OUTPUTMODE_SET
204  //! - \b TIMER_B_OUTPUTMODE_TOGGLE_RESET
205  //! - \b TIMER_B_OUTPUTMODE_SET_RESET
206  //! - \b TIMER_B_OUTPUTMODE_TOGGLE
207  //! - \b TIMER_B_OUTPUTMODE_RESET
208  //! - \b TIMER_B_OUTPUTMODE_TOGGLE_SET
209  //! - \b TIMER_B_OUTPUTMODE_RESET_SET
212 
213 //*****************************************************************************
214 //
215 //! \brief Used in the Timer_B_initContinuousMode() function as the param
216 //! parameter.
217 //
218 //*****************************************************************************
220  //! Selects the clock source
221  //! \n Valid values are:
222  //! - \b TIMER_B_CLOCKSOURCE_EXTERNAL_TXCLK [Default]
223  //! - \b TIMER_B_CLOCKSOURCE_ACLK
224  //! - \b TIMER_B_CLOCKSOURCE_SMCLK
225  //! - \b TIMER_B_CLOCKSOURCE_INVERTED_EXTERNAL_TXCLK
226  uint16_t clockSource;
227  //! Is the divider for Clock source.
228  //! \n Valid values are:
229  //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_1 [Default]
230  //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_2
231  //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_3
232  //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_4
233  //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_5
234  //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_6
235  //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_7
236  //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_8
237  //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_10
238  //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_12
239  //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_14
240  //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_16
241  //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_20
242  //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_24
243  //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_28
244  //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_32
245  //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_40
246  //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_48
247  //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_56
248  //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_64
250  //! Is to enable or disable Timer_B interrupt
251  //! \n Valid values are:
252  //! - \b TIMER_B_TBIE_INTERRUPT_ENABLE
253  //! - \b TIMER_B_TBIE_INTERRUPT_DISABLE [Default]
255  //! Decides if Timer_B clock divider, count direction, count need to be
256  //! reset.
257  //! \n Valid values are:
258  //! - \b TIMER_B_DO_CLEAR
259  //! - \b TIMER_B_SKIP_CLEAR [Default]
260  uint16_t timerClear;
261  //! Whether to start the timer immediately
264 
265 //*****************************************************************************
266 //
267 //! \brief Used in the Timer_B_initUpDownMode() function as the param
268 //! parameter.
269 //
270 //*****************************************************************************
272  //! Selects the clock source
273  //! \n Valid values are:
274  //! - \b TIMER_B_CLOCKSOURCE_EXTERNAL_TXCLK [Default]
275  //! - \b TIMER_B_CLOCKSOURCE_ACLK
276  //! - \b TIMER_B_CLOCKSOURCE_SMCLK
277  //! - \b TIMER_B_CLOCKSOURCE_INVERTED_EXTERNAL_TXCLK
278  uint16_t clockSource;
279  //! Is the divider for Clock source.
280  //! \n Valid values are:
281  //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_1 [Default]
282  //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_2
283  //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_3
284  //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_4
285  //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_5
286  //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_6
287  //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_7
288  //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_8
289  //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_10
290  //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_12
291  //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_14
292  //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_16
293  //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_20
294  //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_24
295  //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_28
296  //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_32
297  //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_40
298  //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_48
299  //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_56
300  //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_64
302  //! Is the specified Timer_B period
303  uint16_t timerPeriod;
304  //! Is to enable or disable Timer_B interrupt
305  //! \n Valid values are:
306  //! - \b TIMER_B_TBIE_INTERRUPT_ENABLE
307  //! - \b TIMER_B_TBIE_INTERRUPT_DISABLE [Default]
309  //! Is to enable or disable Timer_B CCR0 capture compare interrupt.
310  //! \n Valid values are:
311  //! - \b TIMER_B_CCIE_CCR0_INTERRUPT_ENABLE
312  //! - \b TIMER_B_CCIE_CCR0_INTERRUPT_DISABLE [Default]
314  //! Decides if Timer_B clock divider, count direction, count need to be
315  //! reset.
316  //! \n Valid values are:
317  //! - \b TIMER_B_DO_CLEAR
318  //! - \b TIMER_B_SKIP_CLEAR [Default]
319  uint16_t timerClear;
320  //! Whether to start the timer immediately
323 
324 //*****************************************************************************
325 //
326 //! \brief Used in the Timer_B_initCompareMode() function as the param
327 //! parameter.
328 //
329 //*****************************************************************************
331  //! Selects the compare register being used. Refer to datasheet to ensure
332  //! the device has the compare register being used.
333  //! \n Valid values are:
334  //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_0
335  //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_1
336  //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_2
337  //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_3
338  //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_4
339  //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_5
340  //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_6
341  uint16_t compareRegister;
342  //! Is to enable or disable Timer_B capture compare interrupt.
343  //! \n Valid values are:
344  //! - \b TIMER_B_CAPTURECOMPARE_INTERRUPT_DISABLE [Default]
345  //! - \b TIMER_B_CAPTURECOMPARE_INTERRUPT_ENABLE
347  //! Specifies the output mode.
348  //! \n Valid values are:
349  //! - \b TIMER_B_OUTPUTMODE_OUTBITVALUE [Default]
350  //! - \b TIMER_B_OUTPUTMODE_SET
351  //! - \b TIMER_B_OUTPUTMODE_TOGGLE_RESET
352  //! - \b TIMER_B_OUTPUTMODE_SET_RESET
353  //! - \b TIMER_B_OUTPUTMODE_TOGGLE
354  //! - \b TIMER_B_OUTPUTMODE_RESET
355  //! - \b TIMER_B_OUTPUTMODE_TOGGLE_SET
356  //! - \b TIMER_B_OUTPUTMODE_RESET_SET
358  //! Is the count to be compared with in compare mode
359  uint16_t compareValue;
361 
362 
363 //*****************************************************************************
364 //
365 // The following are values that can be passed to the param parameter for
366 // functions: Timer_B_initContinuousMode(), Timer_B_initUpMode(),
367 // Timer_B_initUpDownMode(), and Timer_B_outputPWM().
368 //
369 //*****************************************************************************
370 #define TIMER_B_CLOCKSOURCE_DIVIDER_1 0x00
371 #define TIMER_B_CLOCKSOURCE_DIVIDER_2 0x08
372 #define TIMER_B_CLOCKSOURCE_DIVIDER_3 0x02
373 #define TIMER_B_CLOCKSOURCE_DIVIDER_4 0x10
374 #define TIMER_B_CLOCKSOURCE_DIVIDER_5 0x04
375 #define TIMER_B_CLOCKSOURCE_DIVIDER_6 0x05
376 #define TIMER_B_CLOCKSOURCE_DIVIDER_7 0x06
377 #define TIMER_B_CLOCKSOURCE_DIVIDER_8 0x18
378 #define TIMER_B_CLOCKSOURCE_DIVIDER_10 0x0C
379 #define TIMER_B_CLOCKSOURCE_DIVIDER_12 0x0D
380 #define TIMER_B_CLOCKSOURCE_DIVIDER_14 0x0E
381 #define TIMER_B_CLOCKSOURCE_DIVIDER_16 0x0F
382 #define TIMER_B_CLOCKSOURCE_DIVIDER_20 0x14
383 #define TIMER_B_CLOCKSOURCE_DIVIDER_24 0x15
384 #define TIMER_B_CLOCKSOURCE_DIVIDER_28 0x16
385 #define TIMER_B_CLOCKSOURCE_DIVIDER_32 0x17
386 #define TIMER_B_CLOCKSOURCE_DIVIDER_40 0x1C
387 #define TIMER_B_CLOCKSOURCE_DIVIDER_48 0x1D
388 #define TIMER_B_CLOCKSOURCE_DIVIDER_56 0x1E
389 #define TIMER_B_CLOCKSOURCE_DIVIDER_64 0x1F
390 
391 //*****************************************************************************
392 //
393 // The following are values that can be passed to the timerMode parameter for
394 // functions: Timer_B_startCounter().
395 //
396 //*****************************************************************************
397 #define TIMER_B_STOP_MODE MC_0
398 #define TIMER_B_UP_MODE MC_1
399 #define TIMER_B_CONTINUOUS_MODE MC_2
400 #define TIMER_B_UPDOWN_MODE MC_3
401 
402 //*****************************************************************************
403 //
404 // The following are values that can be passed to the param parameter for
405 // functions: Timer_B_initContinuousMode(), Timer_B_initUpMode(), and
406 // Timer_B_initUpDownMode().
407 //
408 //*****************************************************************************
409 #define TIMER_B_DO_CLEAR TBCLR
410 #define TIMER_B_SKIP_CLEAR 0x00
411 
412 //*****************************************************************************
413 //
414 // The following are values that can be passed to the param parameter for
415 // functions: Timer_B_initContinuousMode(), Timer_B_initUpMode(),
416 // Timer_B_initUpDownMode(), and Timer_B_outputPWM().
417 //
418 //*****************************************************************************
419 #define TIMER_B_CLOCKSOURCE_EXTERNAL_TXCLK TBSSEL__TACLK
420 #define TIMER_B_CLOCKSOURCE_ACLK TBSSEL__ACLK
421 #define TIMER_B_CLOCKSOURCE_SMCLK TBSSEL__SMCLK
422 #define TIMER_B_CLOCKSOURCE_INVERTED_EXTERNAL_TXCLK TBSSEL__INCLK
423 
424 //*****************************************************************************
425 //
426 // The following are values that can be passed to the param parameter for
427 // functions: Timer_B_initContinuousMode(), Timer_B_initUpMode(), and
428 // Timer_B_initUpDownMode().
429 //
430 //*****************************************************************************
431 #define TIMER_B_TBIE_INTERRUPT_ENABLE TBIE
432 #define TIMER_B_TBIE_INTERRUPT_DISABLE 0x00
433 
434 //*****************************************************************************
435 //
436 // The following are values that can be passed to the param parameter for
437 // functions: Timer_B_initUpMode(), and Timer_B_initUpDownMode().
438 //
439 //*****************************************************************************
440 #define TIMER_B_CCIE_CCR0_INTERRUPT_ENABLE CCIE
441 #define TIMER_B_CCIE_CCR0_INTERRUPT_DISABLE 0x00
442 
443 //*****************************************************************************
444 //
445 // The following are values that can be passed to the param parameter for
446 // functions: Timer_B_initCaptureMode(), and Timer_B_initCompareMode().
447 //
448 //*****************************************************************************
449 #define TIMER_B_CAPTURECOMPARE_INTERRUPT_DISABLE 0x00
450 #define TIMER_B_CAPTURECOMPARE_INTERRUPT_ENABLE CCIE
451 
452 //*****************************************************************************
453 //
454 // The following are values that can be passed to the param parameter for
455 // functions: Timer_B_initCaptureMode().
456 //
457 //*****************************************************************************
458 #define TIMER_B_CAPTURE_INPUTSELECT_CCIxA CCIS_0
459 #define TIMER_B_CAPTURE_INPUTSELECT_CCIxB CCIS_1
460 #define TIMER_B_CAPTURE_INPUTSELECT_GND CCIS_2
461 #define TIMER_B_CAPTURE_INPUTSELECT_Vcc CCIS_3
462 
463 //*****************************************************************************
464 //
465 // The following are values that can be passed to the compareOutputMode
466 // parameter for functions: Timer_B_setOutputMode(); the param parameter for
467 // functions: Timer_B_initCaptureMode(), Timer_B_initCompareMode(), and
468 // Timer_B_outputPWM().
469 //
470 //*****************************************************************************
471 #define TIMER_B_OUTPUTMODE_OUTBITVALUE OUTMOD_0
472 #define TIMER_B_OUTPUTMODE_SET OUTMOD_1
473 #define TIMER_B_OUTPUTMODE_TOGGLE_RESET OUTMOD_2
474 #define TIMER_B_OUTPUTMODE_SET_RESET OUTMOD_3
475 #define TIMER_B_OUTPUTMODE_TOGGLE OUTMOD_4
476 #define TIMER_B_OUTPUTMODE_RESET OUTMOD_5
477 #define TIMER_B_OUTPUTMODE_TOGGLE_SET OUTMOD_6
478 #define TIMER_B_OUTPUTMODE_RESET_SET OUTMOD_7
479 
480 //*****************************************************************************
481 //
482 // The following are values that can be passed to the compareRegister parameter
483 // for functions: Timer_B_setCompareValue(),
484 // Timer_B_initCompareLatchLoadEvent(), and Timer_B_setOutputMode(); the
485 // captureCompareRegister parameter for functions:
486 // Timer_B_enableCaptureCompareInterrupt(),
487 // Timer_B_disableCaptureCompareInterrupt(),
488 // Timer_B_getCaptureCompareInterruptStatus(),
489 // Timer_B_getSynchronizedCaptureCompareInput(),
490 // Timer_B_getOutputForOutputModeOutBitValue(),
491 // Timer_B_getCaptureCompareCount(),
492 // Timer_B_setOutputForOutputModeOutBitValue(), and
493 // Timer_B_clearCaptureCompareInterrupt(); the param parameter for functions:
494 // Timer_B_initCaptureMode(), Timer_B_initCompareMode(), and
495 // Timer_B_outputPWM().
496 //
497 //*****************************************************************************
498 #define TIMER_B_CAPTURECOMPARE_REGISTER_0 0x02
499 #define TIMER_B_CAPTURECOMPARE_REGISTER_1 0x04
500 #define TIMER_B_CAPTURECOMPARE_REGISTER_2 0x06
501 #define TIMER_B_CAPTURECOMPARE_REGISTER_3 0x08
502 #define TIMER_B_CAPTURECOMPARE_REGISTER_4 0x0A
503 #define TIMER_B_CAPTURECOMPARE_REGISTER_5 0x0C
504 #define TIMER_B_CAPTURECOMPARE_REGISTER_6 0x0E
505 
506 //*****************************************************************************
507 //
508 // The following are values that can be passed to the param parameter for
509 // functions: Timer_B_initCaptureMode().
510 //
511 //*****************************************************************************
512 #define TIMER_B_CAPTUREMODE_NO_CAPTURE CM_0
513 #define TIMER_B_CAPTUREMODE_RISING_EDGE CM_1
514 #define TIMER_B_CAPTUREMODE_FALLING_EDGE CM_2
515 #define TIMER_B_CAPTUREMODE_RISING_AND_FALLING_EDGE CM_3
516 
517 //*****************************************************************************
518 //
519 // The following are values that can be passed to the param parameter for
520 // functions: Timer_B_initCaptureMode().
521 //
522 //*****************************************************************************
523 #define TIMER_B_CAPTURE_ASYNCHRONOUS 0x00
524 #define TIMER_B_CAPTURE_SYNCHRONOUS SCS
525 
526 //*****************************************************************************
527 //
528 // The following are values that can be passed to the mask parameter for
529 // functions: Timer_B_getCaptureCompareInterruptStatus() as well as returned by
530 // the Timer_B_getCaptureCompareInterruptStatus() function.
531 //
532 //*****************************************************************************
533 #define TIMER_B_CAPTURE_OVERFLOW COV
534 #define TIMER_B_CAPTURECOMPARE_INTERRUPT_FLAG CCIFG
535 
536 //*****************************************************************************
537 //
538 // The following are values that can be passed to the synchronized parameter
539 // for functions: Timer_B_getSynchronizedCaptureCompareInput().
540 //
541 //*****************************************************************************
542 #define TIMER_B_READ_SYNCHRONIZED_CAPTURECOMPAREINPUT SCCI
543 #define TIMER_B_READ_CAPTURE_COMPARE_INPUT CCI
544 
545 //*****************************************************************************
546 //
547 // The following are values that can be passed toThe following are values that
548 // can be returned by the Timer_B_getSynchronizedCaptureCompareInput()
549 // function.
550 //
551 //*****************************************************************************
552 #define TIMER_B_CAPTURECOMPARE_INPUT_HIGH 0x01
553 #define TIMER_B_CAPTURECOMPARE_INPUT_LOW 0x00
554 
555 //*****************************************************************************
556 //
557 // The following are values that can be passed to the outputModeOutBitValue
558 // parameter for functions: Timer_B_setOutputForOutputModeOutBitValue() as well
559 // as returned by the Timer_B_getOutputForOutputModeOutBitValue() function.
560 //
561 //*****************************************************************************
562 #define TIMER_B_OUTPUTMODE_OUTBITVALUE_HIGH OUT
563 #define TIMER_B_OUTPUTMODE_OUTBITVALUE_LOW 0x0000
564 
565 //*****************************************************************************
566 //
567 // The following are values that can be passed to the counterLength parameter
568 // for functions: Timer_B_selectCounterLength().
569 //
570 //*****************************************************************************
571 #define TIMER_B_COUNTER_16BIT CNTL_0
572 #define TIMER_B_COUNTER_12BIT CNTL_1
573 #define TIMER_B_COUNTER_10BIT CNTL_2
574 #define TIMER_B_COUNTER_8BIT CNTL_3
575 
576 //*****************************************************************************
577 //
578 // The following are values that can be passed to the groupLatch parameter for
579 // functions: Timer_B_selectLatchingGroup().
580 //
581 //*****************************************************************************
582 #define TIMER_B_GROUP_NONE TBCLGRP_0
583 #define TIMER_B_GROUP_CL12_CL23_CL56 TBCLGRP_1
584 #define TIMER_B_GROUP_CL123_CL456 TBCLGRP_2
585 #define TIMER_B_GROUP_ALL TBCLGRP_3
586 
587 //*****************************************************************************
588 //
589 // The following are values that can be passed to the compareLatchLoadEvent
590 // parameter for functions: Timer_B_initCompareLatchLoadEvent().
591 //
592 //*****************************************************************************
593 #define TIMER_B_LATCH_ON_WRITE_TO_TBxCCRn_COMPARE_REGISTER CLLD_0
594 #define TIMER_B_LATCH_WHEN_COUNTER_COUNTS_TO_0_IN_UP_OR_CONT_MODE CLLD_1
595 #define TIMER_B_LATCH_WHEN_COUNTER_COUNTS_TO_0_IN_UPDOWN_MODE CLLD_2
596 #define TIMER_B_LATCH_WHEN_COUNTER_COUNTS_TO_CURRENT_COMPARE_LATCH_VALUE CLLD_3
597 
598 //*****************************************************************************
599 //
600 // The following are values that can be passed toThe following are values that
601 // can be returned by the Timer_B_getInterruptStatus() function.
602 //
603 //*****************************************************************************
604 #define TIMER_B_INTERRUPT_NOT_PENDING 0x00
605 #define TIMER_B_INTERRUPT_PENDING 0x01
606 
607 //*****************************************************************************
608 //
609 // The following are values that can be passed to the triggerSelect parameter
610 // for functions: Timer_B_selectOutputHighImpedanceTrigger().
611 //
612 //*****************************************************************************
613 #define TIMER_B_OUTPUTHIGH_TRIGGER_INTERNALSOURCE 0x00
614 #define TIMER_B_OUTPUTHIGH_TRIGGER_EXTERNALSOURCE 0x01
615 
616 //*****************************************************************************
617 //
618 // The following are values that can be passed to the pinsSelect parameter for
619 // functions: Timer_B_remapPins().
620 //
621 //*****************************************************************************
622 #define TIMER_B_REMAP_PINS_1 0x00
623 #define TIMER_B_REMAP_PINS_2 0x01
624 
625 //*****************************************************************************
626 //
627 // Prototypes for the APIs.
628 //
629 //*****************************************************************************
630 
631 //*****************************************************************************
632 //
633 //! \brief Starts Timer_B counter
634 //!
635 //! This function assumes that the timer has been previously configured using
636 //! Timer_B_initContinuousMode, Timer_B_initUpMode or Timer_B_initUpDownMode.
637 //!
638 //! \param baseAddress is the base address of the TIMER_B module.
639 //! \param timerMode selects the mode of the timer
640 //! Valid values are:
641 //! - \b TIMER_B_STOP_MODE
642 //! - \b TIMER_B_UP_MODE
643 //! - \b TIMER_B_CONTINUOUS_MODE [Default]
644 //! - \b TIMER_B_UPDOWN_MODE
645 //!
646 //! Modified bits of \b TBxCTL register.
647 //!
648 //! \return None
649 //
650 //*****************************************************************************
651 extern void Timer_B_startCounter(uint16_t baseAddress,
652  uint16_t timerMode);
653 
654 //*****************************************************************************
655 //
656 //! \brief Configures Timer_B in continuous mode.
657 //!
658 //! This API does not start the timer. Timer needs to be started when required
659 //! using the Timer_B_startCounter API.
660 //!
661 //! \param baseAddress is the base address of the TIMER_B module.
662 //! \param param is the pointer to struct for continuous mode initialization.
663 //!
664 //! Modified bits of \b TBxCTL register.
665 //!
666 //! \return None
667 //
668 //*****************************************************************************
669 extern void Timer_B_initContinuousMode(uint16_t baseAddress,
671 
672 //*****************************************************************************
673 //
674 //! \brief Configures Timer_B in up mode.
675 //!
676 //! This API does not start the timer. Timer needs to be started when required
677 //! using the Timer_B_startCounter API.
678 //!
679 //! \param baseAddress is the base address of the TIMER_B module.
680 //! \param param is the pointer to struct for up mode initialization.
681 //!
682 //! Modified bits of \b TBxCTL register, bits of \b TBxCCTL0 register and bits
683 //! of \b TBxCCR0 register.
684 //!
685 //! \return None
686 //
687 //*****************************************************************************
688 extern void Timer_B_initUpMode(uint16_t baseAddress,
689  Timer_B_initUpModeParam *param);
690 
691 //*****************************************************************************
692 //
693 //! \brief Configures Timer_B in up down mode.
694 //!
695 //! This API does not start the timer. Timer needs to be started when required
696 //! using the Timer_B_startCounter API.
697 //!
698 //! \param baseAddress is the base address of the TIMER_B module.
699 //! \param param is the pointer to struct for up-down mode initialization.
700 //!
701 //! Modified bits of \b TBxCTL register, bits of \b TBxCCTL0 register and bits
702 //! of \b TBxCCR0 register.
703 //!
704 //! \return None
705 //
706 //*****************************************************************************
707 extern void Timer_B_initUpDownMode(uint16_t baseAddress,
709 
710 //*****************************************************************************
711 //
712 //! \brief Initializes Capture Mode
713 //!
714 //! \param baseAddress is the base address of the TIMER_B module.
715 //! \param param is the pointer to struct for capture mode initialization.
716 //!
717 //! Modified bits of \b TBxCCTLn register.
718 //!
719 //! \return None
720 //
721 //*****************************************************************************
722 extern void Timer_B_initCaptureMode(uint16_t baseAddress,
724 
725 //*****************************************************************************
726 //
727 //! \brief Initializes Compare Mode
728 //!
729 //! \param baseAddress is the base address of the TIMER_B module.
730 //! \param param is the pointer to struct for compare mode initialization.
731 //!
732 //! Modified bits of \b TBxCCTLn register and bits of \b TBxCCRn register.
733 //!
734 //! \return None
735 //
736 //*****************************************************************************
737 extern void Timer_B_initCompareMode(uint16_t baseAddress,
739 
740 //*****************************************************************************
741 //
742 //! \brief Enable Timer_B interrupt
743 //!
744 //! Enables Timer_B interrupt. Does not clear interrupt flags.
745 //!
746 //! \param baseAddress is the base address of the TIMER_B module.
747 //!
748 //! Modified bits of \b TBxCTL register.
749 //!
750 //! \return None
751 //
752 //*****************************************************************************
753 extern void Timer_B_enableInterrupt(uint16_t baseAddress);
754 
755 //*****************************************************************************
756 //
757 //! \brief Disable Timer_B interrupt
758 //!
759 //! \param baseAddress is the base address of the TIMER_B module.
760 //!
761 //! Modified bits of \b TBxCTL register.
762 //!
763 //! \return None
764 //
765 //*****************************************************************************
766 extern void Timer_B_disableInterrupt(uint16_t baseAddress);
767 
768 //*****************************************************************************
769 //
770 //! \brief Get Timer_B interrupt status
771 //!
772 //! \param baseAddress is the base address of the TIMER_B module.
773 //!
774 //! \return One of the following:
775 //! - \b TIMER_B_INTERRUPT_NOT_PENDING
776 //! - \b TIMER_B_INTERRUPT_PENDING
777 //! \n indicating the status of the Timer_B interrupt
778 //
779 //*****************************************************************************
780 extern uint32_t Timer_B_getInterruptStatus(uint16_t baseAddress);
781 
782 //*****************************************************************************
783 //
784 //! \brief Enable capture compare interrupt
785 //!
786 //! \param baseAddress is the base address of the TIMER_B module.
787 //! \param captureCompareRegister selects the capture compare register being
788 //! used. Refer to datasheet to ensure the device has the capture
789 //! compare register being used.
790 //! Valid values are:
791 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_0
792 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_1
793 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_2
794 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_3
795 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_4
796 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_5
797 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_6
798 //!
799 //! Modified bits of \b TBxCCTLn register.
800 //!
801 //! \return None
802 //
803 //*****************************************************************************
804 extern void Timer_B_enableCaptureCompareInterrupt(uint16_t baseAddress,
805  uint16_t captureCompareRegister);
806 
807 //*****************************************************************************
808 //
809 //! \brief Disable capture compare interrupt
810 //!
811 //! \param baseAddress is the base address of the TIMER_B module.
812 //! \param captureCompareRegister selects the capture compare register being
813 //! used. Refer to datasheet to ensure the device has the capture
814 //! compare register being used.
815 //! Valid values are:
816 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_0
817 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_1
818 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_2
819 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_3
820 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_4
821 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_5
822 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_6
823 //!
824 //! Modified bits of \b TBxCCTLn register.
825 //!
826 //! \return None
827 //
828 //*****************************************************************************
829 extern void Timer_B_disableCaptureCompareInterrupt(uint16_t baseAddress,
830  uint16_t captureCompareRegister);
831 
832 //*****************************************************************************
833 //
834 //! \brief Return capture compare interrupt status
835 //!
836 //! \param baseAddress is the base address of the TIMER_B module.
837 //! \param captureCompareRegister selects the capture compare register being
838 //! used. Refer to datasheet to ensure the device has the capture
839 //! compare register being used.
840 //! Valid values are:
841 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_0
842 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_1
843 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_2
844 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_3
845 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_4
846 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_5
847 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_6
848 //! \param mask is the mask for the interrupt status
849 //! Mask value is the logical OR of any of the following:
850 //! - \b TIMER_B_CAPTURE_OVERFLOW
851 //! - \b TIMER_B_CAPTURECOMPARE_INTERRUPT_FLAG
852 //!
853 //! \return Logical OR of any of the following:
854 //! - \b TIMER_B_CAPTURE_OVERFLOW
855 //! - \b TIMER_B_CAPTURECOMPARE_INTERRUPT_FLAG
856 //! \n indicating the status of the masked interrupts
857 //
858 //*****************************************************************************
859 extern uint32_t Timer_B_getCaptureCompareInterruptStatus(uint16_t baseAddress,
860  uint16_t captureCompareRegister,
861  uint16_t mask);
862 
863 //*****************************************************************************
864 //
865 //! \brief Reset/Clear the Timer_B clock divider, count direction, count
866 //!
867 //! \param baseAddress is the base address of the TIMER_B module.
868 //!
869 //! Modified bits of \b TBxCTL register.
870 //!
871 //! \return None
872 //
873 //*****************************************************************************
874 extern void Timer_B_clear(uint16_t baseAddress);
875 
876 //*****************************************************************************
877 //
878 //! \brief Get synchronized capturecompare input
879 //!
880 //! \param baseAddress is the base address of the TIMER_B module.
881 //! \param captureCompareRegister selects the capture compare register being
882 //! used. Refer to datasheet to ensure the device has the capture
883 //! compare register being used.
884 //! Valid values are:
885 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_0
886 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_1
887 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_2
888 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_3
889 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_4
890 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_5
891 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_6
892 //! \param synchronized selects the type of capture compare input
893 //! Valid values are:
894 //! - \b TIMER_B_READ_SYNCHRONIZED_CAPTURECOMPAREINPUT
895 //! - \b TIMER_B_READ_CAPTURE_COMPARE_INPUT
896 //!
897 //! \return One of the following:
898 //! - \b TIMER_B_CAPTURECOMPARE_INPUT_HIGH
899 //! - \b TIMER_B_CAPTURECOMPARE_INPUT_LOW
900 //
901 //*****************************************************************************
902 extern uint8_t Timer_B_getSynchronizedCaptureCompareInput(uint16_t baseAddress,
903  uint16_t captureCompareRegister,
904  uint16_t synchronized);
905 
906 //*****************************************************************************
907 //
908 //! \brief Get output bit for output mode
909 //!
910 //! \param baseAddress is the base address of the TIMER_B module.
911 //! \param captureCompareRegister selects the capture compare register being
912 //! used. Refer to datasheet to ensure the device has the capture
913 //! compare register being used.
914 //! Valid values are:
915 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_0
916 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_1
917 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_2
918 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_3
919 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_4
920 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_5
921 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_6
922 //!
923 //! \return One of the following:
924 //! - \b TIMER_B_OUTPUTMODE_OUTBITVALUE_HIGH
925 //! - \b TIMER_B_OUTPUTMODE_OUTBITVALUE_LOW
926 //
927 //*****************************************************************************
928 extern uint8_t Timer_B_getOutputForOutputModeOutBitValue(uint16_t baseAddress,
929  uint16_t captureCompareRegister);
930 
931 //*****************************************************************************
932 //
933 //! \brief Get current capturecompare count
934 //!
935 //! \param baseAddress is the base address of the TIMER_B module.
936 //! \param captureCompareRegister selects the capture compare register being
937 //! used. Refer to datasheet to ensure the device has the capture
938 //! compare register being used.
939 //! Valid values are:
940 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_0
941 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_1
942 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_2
943 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_3
944 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_4
945 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_5
946 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_6
947 //!
948 //! \return Current count as uint16_t
949 //
950 //*****************************************************************************
951 extern uint16_t Timer_B_getCaptureCompareCount(uint16_t baseAddress,
952  uint16_t captureCompareRegister);
953 
954 //*****************************************************************************
955 //
956 //! \brief Set output bit for output mode
957 //!
958 //! \param baseAddress is the base address of the TIMER_B module.
959 //! \param captureCompareRegister selects the capture compare register being
960 //! used. Refer to datasheet to ensure the device has the capture
961 //! compare register being used.
962 //! Valid values are:
963 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_0
964 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_1
965 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_2
966 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_3
967 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_4
968 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_5
969 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_6
970 //! \param outputModeOutBitValue the value to be set for out bit
971 //! Valid values are:
972 //! - \b TIMER_B_OUTPUTMODE_OUTBITVALUE_HIGH
973 //! - \b TIMER_B_OUTPUTMODE_OUTBITVALUE_LOW
974 //!
975 //! Modified bits of \b TBxCCTLn register.
976 //!
977 //! \return None
978 //
979 //*****************************************************************************
980 extern void Timer_B_setOutputForOutputModeOutBitValue(uint16_t baseAddress,
981  uint16_t captureCompareRegister,
982  uint16_t outputModeOutBitValue);
983 
984 //*****************************************************************************
985 //
986 //! \brief Generate a PWM with Timer_B running in up mode
987 //!
988 //! \param baseAddress is the base address of the TIMER_B module.
989 //! \param param is the pointer to struct for PWM configuration.
990 //!
991 //! Modified bits of \b TBxCCTLn register, bits of \b TBxCTL register, bits of
992 //! \b TBxCCTL0 register and bits of \b TBxCCR0 register.
993 //!
994 //! \return None
995 //
996 //*****************************************************************************
997 extern void Timer_B_outputPWM(uint16_t baseAddress,
998  Timer_B_outputPWMParam *param);
999 
1000 //*****************************************************************************
1001 //
1002 //! \brief Stops the Timer_B
1003 //!
1004 //! \param baseAddress is the base address of the TIMER_B module.
1005 //!
1006 //! Modified bits of \b TBxCTL register.
1007 //!
1008 //! \return None
1009 //
1010 //*****************************************************************************
1011 extern void Timer_B_stop(uint16_t baseAddress);
1012 
1013 //*****************************************************************************
1014 //
1015 //! \brief Sets the value of the capture-compare register
1016 //!
1017 //! \param baseAddress is the base address of the TIMER_B module.
1018 //! \param compareRegister selects the compare register being used. Refer to
1019 //! datasheet to ensure the device has the compare register being used.
1020 //! Valid values are:
1021 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_0
1022 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_1
1023 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_2
1024 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_3
1025 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_4
1026 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_5
1027 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_6
1028 //! \param compareValue is the count to be compared with in compare mode
1029 //!
1030 //! Modified bits of \b TBxCCRn register.
1031 //!
1032 //! \return None
1033 //
1034 //*****************************************************************************
1035 extern void Timer_B_setCompareValue(uint16_t baseAddress,
1036  uint16_t compareRegister,
1037  uint16_t compareValue);
1038 
1039 //*****************************************************************************
1040 //
1041 //! \brief Clears the Timer_B TBIFG interrupt flag
1042 //!
1043 //! \param baseAddress is the base address of the TIMER_B module.
1044 //!
1045 //! Modified bits are \b TBIFG of \b TBxCTL register.
1046 //!
1047 //! \return None
1048 //
1049 //*****************************************************************************
1050 extern void Timer_B_clearTimerInterrupt(uint16_t baseAddress);
1051 
1052 //*****************************************************************************
1053 //
1054 //! \brief Clears the capture-compare interrupt flag
1055 //!
1056 //! \param baseAddress is the base address of the TIMER_B module.
1057 //! \param captureCompareRegister selects the capture compare register being
1058 //! used. Refer to datasheet to ensure the device has the capture
1059 //! compare register being used.
1060 //! Valid values are:
1061 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_0
1062 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_1
1063 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_2
1064 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_3
1065 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_4
1066 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_5
1067 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_6
1068 //!
1069 //! Modified bits are \b CCIFG of \b TBxCCTLn register.
1070 //!
1071 //! \return None
1072 //
1073 //*****************************************************************************
1074 extern void Timer_B_clearCaptureCompareInterrupt(uint16_t baseAddress,
1075  uint16_t captureCompareRegister);
1076 
1077 //*****************************************************************************
1078 //
1079 //! \brief Selects Timer_B counter length
1080 //!
1081 //! \param baseAddress is the base address of the TIMER_B module.
1082 //! \param counterLength selects the value of counter length.
1083 //! Valid values are:
1084 //! - \b TIMER_B_COUNTER_16BIT [Default]
1085 //! - \b TIMER_B_COUNTER_12BIT
1086 //! - \b TIMER_B_COUNTER_10BIT
1087 //! - \b TIMER_B_COUNTER_8BIT
1088 //!
1089 //! Modified bits are \b CNTL of \b TBxCTL register.
1090 //!
1091 //! \return None
1092 //
1093 //*****************************************************************************
1094 extern void Timer_B_selectCounterLength(uint16_t baseAddress,
1095  uint16_t counterLength);
1096 
1097 //*****************************************************************************
1098 //
1099 //! \brief Selects Timer_B Latching Group
1100 //!
1101 //! \param baseAddress is the base address of the TIMER_B module.
1102 //! \param groupLatch selects the latching group.
1103 //! Valid values are:
1104 //! - \b TIMER_B_GROUP_NONE [Default]
1105 //! - \b TIMER_B_GROUP_CL12_CL23_CL56
1106 //! - \b TIMER_B_GROUP_CL123_CL456
1107 //! - \b TIMER_B_GROUP_ALL
1108 //!
1109 //! Modified bits are \b TBCLGRP of \b TBxCTL register.
1110 //!
1111 //! \return None
1112 //
1113 //*****************************************************************************
1114 extern void Timer_B_selectLatchingGroup(uint16_t baseAddress,
1115  uint16_t groupLatch);
1116 
1117 //*****************************************************************************
1118 //
1119 //! \brief Selects Compare Latch Load Event
1120 //!
1121 //! \param baseAddress is the base address of the TIMER_B module.
1122 //! \param compareRegister selects the compare register being used. Refer to
1123 //! datasheet to ensure the device has the compare register being used.
1124 //! Valid values are:
1125 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_0
1126 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_1
1127 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_2
1128 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_3
1129 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_4
1130 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_5
1131 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_6
1132 //! \param compareLatchLoadEvent selects the latch load event
1133 //! Valid values are:
1134 //! - \b TIMER_B_LATCH_ON_WRITE_TO_TBxCCRn_COMPARE_REGISTER [Default]
1135 //! - \b TIMER_B_LATCH_WHEN_COUNTER_COUNTS_TO_0_IN_UP_OR_CONT_MODE
1136 //! - \b TIMER_B_LATCH_WHEN_COUNTER_COUNTS_TO_0_IN_UPDOWN_MODE
1137 //! - \b
1138 //! TIMER_B_LATCH_WHEN_COUNTER_COUNTS_TO_CURRENT_COMPARE_LATCH_VALUE
1139 //!
1140 //! Modified bits are \b CLLD of \b TBxCCTLn register.
1141 //!
1142 //! \return None
1143 //
1144 //*****************************************************************************
1145 extern void Timer_B_initCompareLatchLoadEvent(uint16_t baseAddress,
1146  uint16_t compareRegister,
1147  uint16_t compareLatchLoadEvent);
1148 
1149 //*****************************************************************************
1150 //
1151 //! \brief Reads the current timer count value
1152 //!
1153 //! Reads the current count value of the timer. There is a majority vote system
1154 //! in place to confirm an accurate value is returned. The Timer_B_THRESHOLD
1155 //! #define in the associated header file can be modified so that the votes
1156 //! must be closer together for a consensus to occur.
1157 //!
1158 //! \param baseAddress is the base address of the Timer module.
1159 //!
1160 //! \return Majority vote of timer count value
1161 //
1162 //*****************************************************************************
1163 extern uint16_t Timer_B_getCounterValue(uint16_t baseAddress);
1164 
1165 //*****************************************************************************
1166 //
1167 //! \brief Sets the output mode
1168 //!
1169 //! Sets the output mode for the timer even the timer is already running.
1170 //!
1171 //! \param baseAddress is the base address of the TIMER_B module.
1172 //! \param compareRegister selects the compare register being used.
1173 //! Valid values are:
1174 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_0
1175 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_1
1176 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_2
1177 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_3
1178 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_4
1179 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_5
1180 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_6
1181 //! \param compareOutputMode specifies the output mode.
1182 //! Valid values are:
1183 //! - \b TIMER_B_OUTPUTMODE_OUTBITVALUE [Default]
1184 //! - \b TIMER_B_OUTPUTMODE_SET
1185 //! - \b TIMER_B_OUTPUTMODE_TOGGLE_RESET
1186 //! - \b TIMER_B_OUTPUTMODE_SET_RESET
1187 //! - \b TIMER_B_OUTPUTMODE_TOGGLE
1188 //! - \b TIMER_B_OUTPUTMODE_RESET
1189 //! - \b TIMER_B_OUTPUTMODE_TOGGLE_SET
1190 //! - \b TIMER_B_OUTPUTMODE_RESET_SET
1191 //!
1192 //! Modified bits are \b OUTMOD of \b TBxCCTLn register.
1193 //!
1194 //! \return None
1195 //
1196 //*****************************************************************************
1197 extern void Timer_B_setOutputMode(uint16_t baseAddress,
1198  uint16_t compareRegister,
1199  uint16_t compareOutputMode);
1200 
1201 //*****************************************************************************
1202 //
1203 //! \brief Selects the trigger source to output high impedance
1204 //!
1205 //! Timer_B output can be triggered to output high impedance. The trigger
1206 //! source can be selected either internal or external.
1207 //!
1208 //! \param baseAddress is the base address of the TIMER_B module.
1209 //! \param triggerSelect trigger to output high impedance
1210 //! Valid values are:
1211 //! - \b TIMER_B_OUTPUTHIGH_TRIGGER_INTERNALSOURCE [Default]
1212 //! - \b TIMER_B_OUTPUTHIGH_TRIGGER_EXTERNALSOURCE
1213 //!
1214 //! \return None
1215 //
1216 //*****************************************************************************
1217 extern void Timer_B_selectOutputHighImpedanceTrigger(uint16_t baseAddress,
1218  uint8_t triggerSelect);
1219 
1220 //*****************************************************************************
1221 //
1222 //! \brief Remaps Timer_B GPIO pins.
1223 //!
1224 //! Remaps Timer_B GPIO pins. After calling this function,
1225 //! GPIO_setAsPeripheralModuleFunctionInputPin() or
1226 //! GPIO_setAsPeripheralModuleFunctionInputPin() still needs to be invoked to
1227 //! set peripheral functions.
1228 //!
1229 //! \param baseAddress is the base address of the TIMER_B module.
1230 //! \param pinsSelect remapping pins to select. Please refer to device specific
1231 //! datasheet for remapping pins details.
1232 //! Valid values are:
1233 //! - \b TIMER_B_REMAP_PINS_1 [Default]
1234 //! - \b TIMER_B_REMAP_PINS_2
1235 //!
1236 //! \return None
1237 //
1238 //*****************************************************************************
1239 extern void Timer_B_remapPins(uint16_t baseAddress,
1240  uint8_t pinsSelect);
1241 
1242 //*****************************************************************************
1243 //
1244 // Mark the end of the C bindings section for C++ compilers.
1245 //
1246 //*****************************************************************************
1247 #ifdef __cplusplus
1248 }
1249 #endif
1250 
1251 #endif
1252 #endif // __MSP430WARE_TIMER_B_H__
bool startTimer
Whether to start the timer immediately.
Definition: timer_b.h:155
void Timer_B_selectCounterLength(uint16_t baseAddress, uint16_t counterLength)
Selects Timer_B counter length.
Definition: timer_b.c:304
Used in the Timer_B_initContinuousMode() function as the param parameter.
Definition: timer_b.h:219
uint16_t clockSourceDivider
Definition: timer_b.h:134
void Timer_B_initContinuousMode(uint16_t baseAddress, Timer_B_initContinuousModeParam *param)
Configures Timer_B in continuous mode.
Definition: timer_b.c:28
void Timer_B_initUpDownMode(uint16_t baseAddress, Timer_B_initUpDownModeParam *param)
Configures Timer_B in up down mode.
Definition: timer_b.c:88
uint16_t timerInterruptEnable_TBIE
Definition: timer_b.h:142
uint16_t clockSource
Definition: timer_b.h:111
void Timer_B_initCompareLatchLoadEvent(uint16_t baseAddress, uint16_t compareRegister, uint16_t compareLatchLoadEvent)
Selects Compare Latch Load Event.
Definition: timer_b.c:319
uint8_t Timer_B_getOutputForOutputModeOutBitValue(uint16_t baseAddress, uint16_t captureCompareRegister)
Get output bit for output mode.
Definition: timer_b.c:219
uint16_t Timer_B_getCaptureCompareCount(uint16_t baseAddress, uint16_t captureCompareRegister)
Get current capturecompare count.
Definition: timer_b.c:232
void Timer_B_initCaptureMode(uint16_t baseAddress, Timer_B_initCaptureModeParam *param)
Initializes Capture Mode.
Definition: timer_b.c:122
void Timer_B_initCompareMode(uint16_t baseAddress, Timer_B_initCompareModeParam *param)
Initializes Compare Mode.
Definition: timer_b.c:145
uint16_t timerInterruptEnable_TBIE
Definition: timer_b.h:254
uint32_t Timer_B_getCaptureCompareInterruptStatus(uint16_t baseAddress, uint16_t captureCompareRegister, uint16_t mask)
Return capture compare interrupt status.
Definition: timer_b.c:192
Used in the Timer_B_initCaptureMode() function as the param parameter.
Definition: timer_b.h:164
uint16_t clockSource
Definition: timer_b.h:226
uint16_t timerPeriod
Selects the desired Timer_B period.
Definition: timer_b.h:72
void Timer_B_clearCaptureCompareInterrupt(uint16_t baseAddress, uint16_t captureCompareRegister)
Clears the capture-compare interrupt flag.
Definition: timer_b.c:297
Used in the Timer_B_initUpDownMode() function as the param parameter.
Definition: timer_b.h:271
uint16_t compareOutputMode
Definition: timer_b.h:357
void Timer_B_remapPins(uint16_t baseAddress, uint8_t pinsSelect)
Remaps Timer_B GPIO pins.
Definition: timer_b.c:377
uint16_t captureMode
Definition: timer_b.h:182
uint16_t timerClear
Definition: timer_b.h:319
uint16_t timerPeriod
Is the specified Timer_B period.
Definition: timer_b.h:303
void Timer_B_setOutputMode(uint16_t baseAddress, uint16_t compareRegister, uint16_t compareOutputMode)
Sets the output mode.
Definition: timer_b.c:352
void Timer_B_stop(uint16_t baseAddress)
Stops the Timer_B.
Definition: timer_b.c:278
void Timer_B_enableCaptureCompareInterrupt(uint16_t baseAddress, uint16_t captureCompareRegister)
Enable capture compare interrupt.
Definition: timer_b.c:178
uint16_t compareRegister
Definition: timer_b.h:83
uint16_t synchronizeCaptureSource
Definition: timer_b.h:194
uint16_t dutyCycle
Specifies the dutycycle for the generated waveform.
Definition: timer_b.h:96
void Timer_B_outputPWM(uint16_t baseAddress, Timer_B_outputPWMParam *param)
Generate a PWM with Timer_B running in up mode.
Definition: timer_b.c:249
uint16_t clockSourceDivider
Definition: timer_b.h:249
void Timer_B_setCompareValue(uint16_t baseAddress, uint16_t compareRegister, uint16_t compareValue)
Sets the value of the capture-compare register.
Definition: timer_b.c:284
uint16_t captureInterruptEnable
Definition: timer_b.h:199
uint16_t captureCompareInterruptEnable_CCR0_CCIE
Definition: timer_b.h:313
uint16_t captureCompareInterruptEnable_CCR0_CCIE
Definition: timer_b.h:147
bool startTimer
Whether to start the timer immediately.
Definition: timer_b.h:321
uint16_t compareValue
Is the count to be compared with in compare mode.
Definition: timer_b.h:359
void Timer_B_clear(uint16_t baseAddress)
Reset/Clear the Timer_B clock divider, count direction, count.
Definition: timer_b.c:200
uint16_t captureRegister
Definition: timer_b.h:175
uint16_t compareInterruptEnable
Definition: timer_b.h:346
Used in the Timer_B_initUpMode() function as the param parameter.
Definition: timer_b.h:104
uint32_t Timer_B_getInterruptStatus(uint16_t baseAddress)
Get Timer_B interrupt status.
Definition: timer_b.c:173
uint16_t timerPeriod
Definition: timer_b.h:137
uint16_t clockSource
Definition: timer_b.h:278
void Timer_B_selectLatchingGroup(uint16_t baseAddress, uint16_t groupLatch)
Selects Timer_B Latching Group.
Definition: timer_b.c:312
uint16_t Timer_B_getCounterValue(uint16_t baseAddress)
Reads the current timer count value.
Definition: timer_b.c:328
void Timer_B_disableCaptureCompareInterrupt(uint16_t baseAddress, uint16_t captureCompareRegister)
Disable capture compare interrupt.
Definition: timer_b.c:185
uint16_t compareOutputMode
Definition: timer_b.h:94
void Timer_B_startCounter(uint16_t baseAddress, uint16_t timerMode)
Starts Timer_B counter.
Definition: timer_b.c:21
void Timer_B_setOutputForOutputModeOutBitValue(uint16_t baseAddress, uint16_t captureCompareRegister, uint16_t outputModeOutBitValue)
Set output bit for output mode.
Definition: timer_b.c:240
Used in the Timer_B_outputPWM() function as the param parameter.
Definition: timer_b.h:40
uint16_t clockSource
Definition: timer_b.h:47
uint16_t captureInputSelect
Definition: timer_b.h:189
void Timer_B_selectOutputHighImpedanceTrigger(uint16_t baseAddress, uint8_t triggerSelect)
Selects the trigger source to output high impedance.
Definition: timer_b.c:360
uint16_t compareRegister
Definition: timer_b.h:341
uint16_t timerClear
Definition: timer_b.h:153
void Timer_B_initUpMode(uint16_t baseAddress, Timer_B_initUpModeParam *param)
Configures Timer_B in up mode.
Definition: timer_b.c:54
uint16_t captureOutputMode
Definition: timer_b.h:210
uint16_t timerClear
Definition: timer_b.h:260
bool startTimer
Whether to start the timer immediately.
Definition: timer_b.h:262
void Timer_B_disableInterrupt(uint16_t baseAddress)
Disable Timer_B interrupt.
Definition: timer_b.c:168
Used in the Timer_B_initCompareMode() function as the param parameter.
Definition: timer_b.h:330
uint16_t clockSourceDivider
Definition: timer_b.h:301
uint16_t clockSourceDivider
Definition: timer_b.h:70
uint16_t timerInterruptEnable_TBIE
Definition: timer_b.h:308
void Timer_B_clearTimerInterrupt(uint16_t baseAddress)
Clears the Timer_B TBIFG interrupt flag.
Definition: timer_b.c:292
uint8_t Timer_B_getSynchronizedCaptureCompareInput(uint16_t baseAddress, uint16_t captureCompareRegister, uint16_t synchronized)
Get synchronized capturecompare input.
Definition: timer_b.c:206
void Timer_B_enableInterrupt(uint16_t baseAddress)
Enable Timer_B interrupt.
Definition: timer_b.c:163

Copyright 2020, Texas Instruments Incorporated