MSP430 DriverLib for MSP430i2xx Devices  2.91.13.01
timer_a.h
1 //*****************************************************************************
2 //
3 // timer_a.h - Driver for the TIMER_A Module.
4 //
5 //*****************************************************************************
6 
7 #ifndef __MSP430WARE_TIMER_A_H__
8 #define __MSP430WARE_TIMER_A_H__
9 
10 #include "inc/hw_memmap.h"
11 
12 #ifdef __MSP430_HAS_TxA3__
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_A_getCounterValue that
29 // determines the maximum difference in counts of the TAxR register for a
30 // majority vote.
31 //
32 //*****************************************************************************
33 #define TIMER_A_THRESHOLD 50
34 
35 //*****************************************************************************
36 //
37 //! \brief Used in the Timer_A_initContinuousMode() function as the param
38 //! parameter.
39 //
40 //*****************************************************************************
42  //! Selects Clock source.
43  //! \n Valid values are:
44  //! - \b TIMER_A_CLOCKSOURCE_EXTERNAL_TXCLK [Default]
45  //! - \b TIMER_A_CLOCKSOURCE_ACLK
46  //! - \b TIMER_A_CLOCKSOURCE_SMCLK
47  //! - \b TIMER_A_CLOCKSOURCE_INVERTED_EXTERNAL_TXCLK
48  uint16_t clockSource;
49  //! Is the desired divider for the clock source
50  //! \n Valid values are:
51  //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_1 [Default]
52  //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_2
53  //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_4
54  //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_8
56  //! Is to enable or disable Timer_A interrupt
57  //! \n Valid values are:
58  //! - \b TIMER_A_TAIE_INTERRUPT_ENABLE
59  //! - \b TIMER_A_TAIE_INTERRUPT_DISABLE [Default]
61  //! Decides if Timer_A clock divider, count direction, count need to be
62  //! reset.
63  //! \n Valid values are:
64  //! - \b TIMER_A_DO_CLEAR
65  //! - \b TIMER_A_SKIP_CLEAR [Default]
66  uint16_t timerClear;
67  //! Whether to start the timer immediately
68  bool startTimer;
70 
71 //*****************************************************************************
72 //
73 //! \brief Used in the Timer_A_initCaptureMode() function as the param
74 //! parameter.
75 //
76 //*****************************************************************************
78  //! Selects the Capture register being used. Refer to datasheet to ensure
79  //! the device has the capture compare register being used.
80  //! \n Valid values are:
81  //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_0
82  //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_1
83  //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_2
84  uint16_t captureRegister;
85  //! Is the capture mode selected.
86  //! \n Valid values are:
87  //! - \b TIMER_A_CAPTUREMODE_NO_CAPTURE [Default]
88  //! - \b TIMER_A_CAPTUREMODE_RISING_EDGE
89  //! - \b TIMER_A_CAPTUREMODE_FALLING_EDGE
90  //! - \b TIMER_A_CAPTUREMODE_RISING_AND_FALLING_EDGE
91  uint16_t captureMode;
92  //! Decides the Input Select
93  //! \n Valid values are:
94  //! - \b TIMER_A_CAPTURE_INPUTSELECT_CCIxA
95  //! - \b TIMER_A_CAPTURE_INPUTSELECT_CCIxB
96  //! - \b TIMER_A_CAPTURE_INPUTSELECT_GND
97  //! - \b TIMER_A_CAPTURE_INPUTSELECT_Vcc
99  //! Decides if capture source should be synchronized with timer clock
100  //! \n Valid values are:
101  //! - \b TIMER_A_CAPTURE_ASYNCHRONOUS [Default]
102  //! - \b TIMER_A_CAPTURE_SYNCHRONOUS
104  //! Is to enable or disable timer captureComapre interrupt.
105  //! \n Valid values are:
106  //! - \b TIMER_A_CAPTURECOMPARE_INTERRUPT_DISABLE [Default]
107  //! - \b TIMER_A_CAPTURECOMPARE_INTERRUPT_ENABLE
109  //! Specifies the output mode.
110  //! \n Valid values are:
111  //! - \b TIMER_A_OUTPUTMODE_OUTBITVALUE [Default]
112  //! - \b TIMER_A_OUTPUTMODE_SET
113  //! - \b TIMER_A_OUTPUTMODE_TOGGLE_RESET
114  //! - \b TIMER_A_OUTPUTMODE_SET_RESET
115  //! - \b TIMER_A_OUTPUTMODE_TOGGLE
116  //! - \b TIMER_A_OUTPUTMODE_RESET
117  //! - \b TIMER_A_OUTPUTMODE_TOGGLE_SET
118  //! - \b TIMER_A_OUTPUTMODE_RESET_SET
121 
122 //*****************************************************************************
123 //
124 //! \brief Used in the Timer_A_initUpDownMode() function as the param
125 //! parameter.
126 //
127 //*****************************************************************************
129  //! Selects Clock source.
130  //! \n Valid values are:
131  //! - \b TIMER_A_CLOCKSOURCE_EXTERNAL_TXCLK [Default]
132  //! - \b TIMER_A_CLOCKSOURCE_ACLK
133  //! - \b TIMER_A_CLOCKSOURCE_SMCLK
134  //! - \b TIMER_A_CLOCKSOURCE_INVERTED_EXTERNAL_TXCLK
135  uint16_t clockSource;
136  //! Is the desired divider for the clock source
137  //! \n Valid values are:
138  //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_1 [Default]
139  //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_2
140  //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_4
141  //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_8
143  //! Is the specified Timer_A period
144  uint16_t timerPeriod;
145  //! Is to enable or disable Timer_A interrupt
146  //! \n Valid values are:
147  //! - \b TIMER_A_TAIE_INTERRUPT_ENABLE
148  //! - \b TIMER_A_TAIE_INTERRUPT_DISABLE [Default]
150  //! Is to enable or disable Timer_A CCR0 captureComapre interrupt.
151  //! \n Valid values are:
152  //! - \b TIMER_A_CCIE_CCR0_INTERRUPT_ENABLE
153  //! - \b TIMER_A_CCIE_CCR0_INTERRUPT_DISABLE [Default]
155  //! Decides if Timer_A clock divider, count direction, count need to be
156  //! reset.
157  //! \n Valid values are:
158  //! - \b TIMER_A_DO_CLEAR
159  //! - \b TIMER_A_SKIP_CLEAR [Default]
160  uint16_t timerClear;
161  //! Whether to start the timer immediately
164 
165 //*****************************************************************************
166 //
167 //! \brief Used in the Timer_A_outputPWM() function as the param parameter.
168 //
169 //*****************************************************************************
170 typedef struct Timer_A_outputPWMParam {
171  //! Selects Clock source.
172  //! \n Valid values are:
173  //! - \b TIMER_A_CLOCKSOURCE_EXTERNAL_TXCLK [Default]
174  //! - \b TIMER_A_CLOCKSOURCE_ACLK
175  //! - \b TIMER_A_CLOCKSOURCE_SMCLK
176  //! - \b TIMER_A_CLOCKSOURCE_INVERTED_EXTERNAL_TXCLK
177  uint16_t clockSource;
178  //! Is the desired divider for the clock source
179  //! \n Valid values are:
180  //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_1 [Default]
181  //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_2
182  //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_4
183  //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_8
185  //! Selects the desired timer period
186  uint16_t timerPeriod;
187  //! Selects the compare register being used. Refer to datasheet to ensure
188  //! the device has the capture compare register being used.
189  //! \n Valid values are:
190  //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_0
191  //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_1
192  //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_2
193  uint16_t compareRegister;
194  //! Specifies the output mode.
195  //! \n Valid values are:
196  //! - \b TIMER_A_OUTPUTMODE_OUTBITVALUE [Default]
197  //! - \b TIMER_A_OUTPUTMODE_SET
198  //! - \b TIMER_A_OUTPUTMODE_TOGGLE_RESET
199  //! - \b TIMER_A_OUTPUTMODE_SET_RESET
200  //! - \b TIMER_A_OUTPUTMODE_TOGGLE
201  //! - \b TIMER_A_OUTPUTMODE_RESET
202  //! - \b TIMER_A_OUTPUTMODE_TOGGLE_SET
203  //! - \b TIMER_A_OUTPUTMODE_RESET_SET
205  //! Specifies the dutycycle for the generated waveform
206  uint16_t dutyCycle;
208 
209 //*****************************************************************************
210 //
211 //! \brief Used in the Timer_A_initUpMode() function as the param parameter.
212 //
213 //*****************************************************************************
214 typedef struct Timer_A_initUpModeParam {
215  //! Selects Clock source.
216  //! \n Valid values are:
217  //! - \b TIMER_A_CLOCKSOURCE_EXTERNAL_TXCLK [Default]
218  //! - \b TIMER_A_CLOCKSOURCE_ACLK
219  //! - \b TIMER_A_CLOCKSOURCE_SMCLK
220  //! - \b TIMER_A_CLOCKSOURCE_INVERTED_EXTERNAL_TXCLK
221  uint16_t clockSource;
222  //! Is the desired divider for the clock source
223  //! \n Valid values are:
224  //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_1 [Default]
225  //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_2
226  //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_4
227  //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_8
229  //! Is the specified Timer_A period. This is the value that gets written
230  //! into the CCR0. Limited to 16 bits[uint16_t]
231  uint16_t timerPeriod;
232  //! Is to enable or disable Timer_A interrupt
233  //! \n Valid values are:
234  //! - \b TIMER_A_TAIE_INTERRUPT_ENABLE
235  //! - \b TIMER_A_TAIE_INTERRUPT_DISABLE [Default]
237  //! Is to enable or disable Timer_A CCR0 captureComapre interrupt.
238  //! \n Valid values are:
239  //! - \b TIMER_A_CCIE_CCR0_INTERRUPT_ENABLE
240  //! - \b TIMER_A_CCIE_CCR0_INTERRUPT_DISABLE [Default]
242  //! Decides if Timer_A clock divider, count direction, count need to be
243  //! reset.
244  //! \n Valid values are:
245  //! - \b TIMER_A_DO_CLEAR
246  //! - \b TIMER_A_SKIP_CLEAR [Default]
247  uint16_t timerClear;
248  //! Whether to start the timer immediately
251 
252 //*****************************************************************************
253 //
254 //! \brief Used in the Timer_A_initCompareMode() function as the param
255 //! parameter.
256 //
257 //*****************************************************************************
259  //! Selects the Capture register being used. Refer to datasheet to ensure
260  //! the device has the capture compare register being used.
261  //! \n Valid values are:
262  //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_0
263  //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_1
264  //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_2
265  uint16_t compareRegister;
266  //! Is to enable or disable timer captureComapre interrupt.
267  //! \n Valid values are:
268  //! - \b TIMER_A_CAPTURECOMPARE_INTERRUPT_DISABLE [Default]
269  //! - \b TIMER_A_CAPTURECOMPARE_INTERRUPT_ENABLE
271  //! Specifies the output mode.
272  //! \n Valid values are:
273  //! - \b TIMER_A_OUTPUTMODE_OUTBITVALUE [Default]
274  //! - \b TIMER_A_OUTPUTMODE_SET
275  //! - \b TIMER_A_OUTPUTMODE_TOGGLE_RESET
276  //! - \b TIMER_A_OUTPUTMODE_SET_RESET
277  //! - \b TIMER_A_OUTPUTMODE_TOGGLE
278  //! - \b TIMER_A_OUTPUTMODE_RESET
279  //! - \b TIMER_A_OUTPUTMODE_TOGGLE_SET
280  //! - \b TIMER_A_OUTPUTMODE_RESET_SET
282  //! Is the count to be compared with in compare mode
283  uint16_t compareValue;
285 
286 
287 //*****************************************************************************
288 //
289 // The following are values that can be passed to the param parameter for
290 // functions: Timer_A_initContinuousMode(), Timer_A_initUpMode(),
291 // Timer_A_initUpDownMode(), and Timer_A_outputPWM().
292 //
293 //*****************************************************************************
294 #define TIMER_A_CLOCKSOURCE_DIVIDER_1 0x00
295 #define TIMER_A_CLOCKSOURCE_DIVIDER_2 0x08
296 #define TIMER_A_CLOCKSOURCE_DIVIDER_4 0x10
297 #define TIMER_A_CLOCKSOURCE_DIVIDER_8 0x18
298 
299 //*****************************************************************************
300 //
301 // The following are values that can be passed to the timerMode parameter for
302 // functions: Timer_A_startCounter().
303 //
304 //*****************************************************************************
305 #define TIMER_A_STOP_MODE MC_0
306 #define TIMER_A_UP_MODE MC_1
307 #define TIMER_A_CONTINUOUS_MODE MC_2
308 #define TIMER_A_UPDOWN_MODE MC_3
309 
310 //*****************************************************************************
311 //
312 // The following are values that can be passed to the param parameter for
313 // functions: Timer_A_initContinuousMode(), Timer_A_initUpMode(), and
314 // Timer_A_initUpDownMode().
315 //
316 //*****************************************************************************
317 #define TIMER_A_DO_CLEAR TACLR
318 #define TIMER_A_SKIP_CLEAR 0x00
319 
320 //*****************************************************************************
321 //
322 // The following are values that can be passed to the param parameter for
323 // functions: Timer_A_initContinuousMode(), Timer_A_initUpMode(),
324 // Timer_A_initUpDownMode(), and Timer_A_outputPWM().
325 //
326 //*****************************************************************************
327 #define TIMER_A_CLOCKSOURCE_EXTERNAL_TXCLK TASSEL__TACLK
328 #define TIMER_A_CLOCKSOURCE_ACLK TASSEL__ACLK
329 #define TIMER_A_CLOCKSOURCE_SMCLK TASSEL__SMCLK
330 #define TIMER_A_CLOCKSOURCE_INVERTED_EXTERNAL_TXCLK TASSEL__INCLK
331 
332 //*****************************************************************************
333 //
334 // The following are values that can be passed to the param parameter for
335 // functions: Timer_A_initContinuousMode(), Timer_A_initUpMode(), and
336 // Timer_A_initUpDownMode().
337 //
338 //*****************************************************************************
339 #define TIMER_A_TAIE_INTERRUPT_ENABLE TAIE
340 #define TIMER_A_TAIE_INTERRUPT_DISABLE 0x00
341 
342 //*****************************************************************************
343 //
344 // The following are values that can be passed to the param parameter for
345 // functions: Timer_A_initUpMode(), and Timer_A_initUpDownMode().
346 //
347 //*****************************************************************************
348 #define TIMER_A_CCIE_CCR0_INTERRUPT_ENABLE CCIE
349 #define TIMER_A_CCIE_CCR0_INTERRUPT_DISABLE 0x00
350 
351 //*****************************************************************************
352 //
353 // The following are values that can be passed to the param parameter for
354 // functions: Timer_A_initCaptureMode(), and Timer_A_initCompareMode().
355 //
356 //*****************************************************************************
357 #define TIMER_A_CAPTURECOMPARE_INTERRUPT_DISABLE 0x00
358 #define TIMER_A_CAPTURECOMPARE_INTERRUPT_ENABLE CCIE
359 
360 //*****************************************************************************
361 //
362 // The following are values that can be passed to the param parameter for
363 // functions: Timer_A_initCaptureMode().
364 //
365 //*****************************************************************************
366 #define TIMER_A_CAPTURE_INPUTSELECT_CCIxA CCIS_0
367 #define TIMER_A_CAPTURE_INPUTSELECT_CCIxB CCIS_1
368 #define TIMER_A_CAPTURE_INPUTSELECT_GND CCIS_2
369 #define TIMER_A_CAPTURE_INPUTSELECT_Vcc CCIS_3
370 
371 //*****************************************************************************
372 //
373 // The following are values that can be passed to the compareOutputMode
374 // parameter for functions: Timer_A_setOutputMode(); the param parameter for
375 // functions: Timer_A_initCaptureMode(), Timer_A_initCompareMode(), and
376 // Timer_A_outputPWM().
377 //
378 //*****************************************************************************
379 #define TIMER_A_OUTPUTMODE_OUTBITVALUE OUTMOD_0
380 #define TIMER_A_OUTPUTMODE_SET OUTMOD_1
381 #define TIMER_A_OUTPUTMODE_TOGGLE_RESET OUTMOD_2
382 #define TIMER_A_OUTPUTMODE_SET_RESET OUTMOD_3
383 #define TIMER_A_OUTPUTMODE_TOGGLE OUTMOD_4
384 #define TIMER_A_OUTPUTMODE_RESET OUTMOD_5
385 #define TIMER_A_OUTPUTMODE_TOGGLE_SET OUTMOD_6
386 #define TIMER_A_OUTPUTMODE_RESET_SET OUTMOD_7
387 
388 //*****************************************************************************
389 //
390 // The following are values that can be passed to the compareRegister parameter
391 // for functions: Timer_A_setCompareValue(), and Timer_A_setOutputMode(); the
392 // captureCompareRegister parameter for functions:
393 // Timer_A_enableCaptureCompareInterrupt(),
394 // Timer_A_disableCaptureCompareInterrupt(),
395 // Timer_A_getCaptureCompareInterruptStatus(),
396 // Timer_A_getSynchronizedCaptureCompareInput(),
397 // Timer_A_getOutputForOutputModeOutBitValue(),
398 // Timer_A_getCaptureCompareCount(),
399 // Timer_A_setOutputForOutputModeOutBitValue(), and
400 // Timer_A_clearCaptureCompareInterrupt(); the param parameter for functions:
401 // Timer_A_initCaptureMode(), Timer_A_initCompareMode(), and
402 // Timer_A_outputPWM().
403 //
404 //*****************************************************************************
405 #define TIMER_A_CAPTURECOMPARE_REGISTER_0 0x02
406 #define TIMER_A_CAPTURECOMPARE_REGISTER_1 0x04
407 #define TIMER_A_CAPTURECOMPARE_REGISTER_2 0x06
408 
409 //*****************************************************************************
410 //
411 // The following are values that can be passed to the param parameter for
412 // functions: Timer_A_initCaptureMode().
413 //
414 //*****************************************************************************
415 #define TIMER_A_CAPTUREMODE_NO_CAPTURE CM_0
416 #define TIMER_A_CAPTUREMODE_RISING_EDGE CM_1
417 #define TIMER_A_CAPTUREMODE_FALLING_EDGE CM_2
418 #define TIMER_A_CAPTUREMODE_RISING_AND_FALLING_EDGE CM_3
419 
420 //*****************************************************************************
421 //
422 // The following are values that can be passed to the param parameter for
423 // functions: Timer_A_initCaptureMode().
424 //
425 //*****************************************************************************
426 #define TIMER_A_CAPTURE_ASYNCHRONOUS 0x00
427 #define TIMER_A_CAPTURE_SYNCHRONOUS SCS
428 
429 //*****************************************************************************
430 //
431 // The following are values that can be passed to the mask parameter for
432 // functions: Timer_A_getCaptureCompareInterruptStatus() as well as returned by
433 // the Timer_A_getCaptureCompareInterruptStatus() function.
434 //
435 //*****************************************************************************
436 #define TIMER_A_CAPTURE_OVERFLOW COV
437 #define TIMER_A_CAPTURECOMPARE_INTERRUPT_FLAG CCIFG
438 
439 //*****************************************************************************
440 //
441 // The following are values that can be passed to the synchronized parameter
442 // for functions: Timer_A_getSynchronizedCaptureCompareInput().
443 //
444 //*****************************************************************************
445 #define TIMER_A_READ_SYNCHRONIZED_CAPTURECOMPAREINPUT SCCI
446 #define TIMER_A_READ_CAPTURE_COMPARE_INPUT CCI
447 
448 //*****************************************************************************
449 //
450 // The following are values that can be passed toThe following are values that
451 // can be returned by the Timer_A_getSynchronizedCaptureCompareInput()
452 // function.
453 //
454 //*****************************************************************************
455 #define TIMER_A_CAPTURECOMPARE_INPUT_HIGH 0x01
456 #define TIMER_A_CAPTURECOMPARE_INPUT_LOW 0x00
457 
458 //*****************************************************************************
459 //
460 // The following are values that can be passed to the outputModeOutBitValue
461 // parameter for functions: Timer_A_setOutputForOutputModeOutBitValue() as well
462 // as returned by the Timer_A_getOutputForOutputModeOutBitValue() function.
463 //
464 //*****************************************************************************
465 #define TIMER_A_OUTPUTMODE_OUTBITVALUE_HIGH OUT
466 #define TIMER_A_OUTPUTMODE_OUTBITVALUE_LOW 0x00
467 
468 //*****************************************************************************
469 //
470 // The following are values that can be passed toThe following are values that
471 // can be returned by the Timer_A_getInterruptStatus() function.
472 //
473 //*****************************************************************************
474 #define TIMER_A_INTERRUPT_NOT_PENDING 0x00
475 #define TIMER_A_INTERRUPT_PENDING 0x01
476 
477 //*****************************************************************************
478 //
479 // Prototypes for the APIs.
480 //
481 //*****************************************************************************
482 
483 //*****************************************************************************
484 //
485 //! \brief Starts Timer_A counter
486 //!
487 //! This function assumes that the timer has been previously configured using
488 //! Timer_A_initContinuousMode, Timer_A_initUpMode or Timer_A_initUpDownMode.
489 //!
490 //! \param baseAddress is the base address of the TIMER_A module.
491 //! \param timerMode mode to put the timer in
492 //! Valid values are:
493 //! - \b TIMER_A_STOP_MODE
494 //! - \b TIMER_A_UP_MODE
495 //! - \b TIMER_A_CONTINUOUS_MODE [Default]
496 //! - \b TIMER_A_UPDOWN_MODE
497 //!
498 //! Modified bits of \b TAxCTL register.
499 //!
500 //! \return None
501 //
502 //*****************************************************************************
503 extern void Timer_A_startCounter(uint16_t baseAddress,
504  uint16_t timerMode);
505 
506 //*****************************************************************************
507 //
508 //! \brief Configures Timer_A in continuous mode.
509 //!
510 //! \param baseAddress is the base address of the TIMER_A module.
511 //! \param param is the pointer to struct for continuous mode initialization.
512 //!
513 //! Modified bits of \b TAxCTL register.
514 //!
515 //! \return None
516 //
517 //*****************************************************************************
518 extern void Timer_A_initContinuousMode(uint16_t baseAddress,
520 
521 //*****************************************************************************
522 //
523 //! \brief Configures Timer_A in up mode.
524 //!
525 //! \param baseAddress is the base address of the TIMER_A module.
526 //! \param param is the pointer to struct for up mode initialization.
527 //!
528 //! Modified bits of \b TAxCTL register, bits of \b TAxCCTL0 register and bits
529 //! of \b TAxCCR0 register.
530 //!
531 //! \return None
532 //
533 //*****************************************************************************
534 extern void Timer_A_initUpMode(uint16_t baseAddress,
535  Timer_A_initUpModeParam *param);
536 
537 //*****************************************************************************
538 //
539 //! \brief Configures Timer_A in up down mode.
540 //!
541 //! \param baseAddress is the base address of the TIMER_A module.
542 //! \param param is the pointer to struct for up-down mode initialization.
543 //!
544 //! Modified bits of \b TAxCTL register, bits of \b TAxCCTL0 register and bits
545 //! of \b TAxCCR0 register.
546 //!
547 //! \return None
548 //
549 //*****************************************************************************
550 extern void Timer_A_initUpDownMode(uint16_t baseAddress,
552 
553 //*****************************************************************************
554 //
555 //! \brief Initializes Capture Mode
556 //!
557 //! \param baseAddress is the base address of the TIMER_A module.
558 //! \param param is the pointer to struct for capture mode initialization.
559 //!
560 //! Modified bits of \b TAxCCTLn register.
561 //!
562 //! \return None
563 //
564 //*****************************************************************************
565 extern void Timer_A_initCaptureMode(uint16_t baseAddress,
567 
568 //*****************************************************************************
569 //
570 //! \brief Initializes Compare Mode
571 //!
572 //! \param baseAddress is the base address of the TIMER_A module.
573 //! \param param is the pointer to struct for compare mode initialization.
574 //!
575 //! Modified bits of \b TAxCCRn register and bits of \b TAxCCTLn register.
576 //!
577 //! \return None
578 //
579 //*****************************************************************************
580 extern void Timer_A_initCompareMode(uint16_t baseAddress,
582 
583 //*****************************************************************************
584 //
585 //! \brief Enable timer interrupt
586 //!
587 //! Does not clear interrupt flags
588 //!
589 //! \param baseAddress is the base address of the TIMER_A module.
590 //!
591 //! Modified bits of \b TAxCTL register.
592 //!
593 //! \return None
594 //
595 //*****************************************************************************
596 extern void Timer_A_enableInterrupt(uint16_t baseAddress);
597 
598 //*****************************************************************************
599 //
600 //! \brief Disable timer interrupt
601 //!
602 //! \param baseAddress is the base address of the TIMER_A module.
603 //!
604 //! Modified bits of \b TAxCTL register.
605 //!
606 //! \return None
607 //
608 //*****************************************************************************
609 extern void Timer_A_disableInterrupt(uint16_t baseAddress);
610 
611 //*****************************************************************************
612 //
613 //! \brief Get timer interrupt status
614 //!
615 //! \param baseAddress is the base address of the TIMER_A module.
616 //!
617 //! \return One of the following:
618 //! - \b TIMER_A_INTERRUPT_NOT_PENDING
619 //! - \b TIMER_A_INTERRUPT_PENDING
620 //! \n indicating the Timer_A interrupt status
621 //
622 //*****************************************************************************
623 extern uint32_t Timer_A_getInterruptStatus(uint16_t baseAddress);
624 
625 //*****************************************************************************
626 //
627 //! \brief Enable capture compare interrupt
628 //!
629 //! Does not clear interrupt flags
630 //!
631 //! \param baseAddress is the base address of the TIMER_A module.
632 //! \param captureCompareRegister is the selected capture compare register
633 //! Valid values are:
634 //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_0
635 //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_1
636 //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_2
637 //!
638 //! Modified bits of \b TAxCCTLn register.
639 //!
640 //! \return None
641 //
642 //*****************************************************************************
643 extern void Timer_A_enableCaptureCompareInterrupt(uint16_t baseAddress,
644  uint16_t captureCompareRegister);
645 
646 //*****************************************************************************
647 //
648 //! \brief Disable capture compare interrupt
649 //!
650 //! \param baseAddress is the base address of the TIMER_A module.
651 //! \param captureCompareRegister is the selected capture compare register
652 //! Valid values are:
653 //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_0
654 //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_1
655 //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_2
656 //!
657 //! Modified bits of \b TAxCCTLn register.
658 //!
659 //! \return None
660 //
661 //*****************************************************************************
662 extern void Timer_A_disableCaptureCompareInterrupt(uint16_t baseAddress,
663  uint16_t captureCompareRegister);
664 
665 //*****************************************************************************
666 //
667 //! \brief Return capture compare interrupt status
668 //!
669 //! \param baseAddress is the base address of the TIMER_A module.
670 //! \param captureCompareRegister is the selected capture compare register
671 //! Valid values are:
672 //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_0
673 //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_1
674 //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_2
675 //! \param mask is the mask for the interrupt status
676 //! Mask value is the logical OR of any of the following:
677 //! - \b TIMER_A_CAPTURE_OVERFLOW
678 //! - \b TIMER_A_CAPTURECOMPARE_INTERRUPT_FLAG
679 //!
680 //! \return Logical OR of any of the following:
681 //! - \b TIMER_A_CAPTURE_OVERFLOW
682 //! - \b TIMER_A_CAPTURECOMPARE_INTERRUPT_FLAG
683 //! \n indicating the status of the masked interrupts
684 //
685 //*****************************************************************************
686 extern uint32_t Timer_A_getCaptureCompareInterruptStatus(uint16_t baseAddress,
687  uint16_t captureCompareRegister,
688  uint16_t mask);
689 
690 //*****************************************************************************
691 //
692 //! \brief Reset/Clear the timer clock divider, count direction, count
693 //!
694 //! \param baseAddress is the base address of the TIMER_A module.
695 //!
696 //! Modified bits of \b TAxCTL register.
697 //!
698 //! \return None
699 //
700 //*****************************************************************************
701 extern void Timer_A_clear(uint16_t baseAddress);
702 
703 //*****************************************************************************
704 //
705 //! \brief Get synchronized capturecompare input
706 //!
707 //! \param baseAddress is the base address of the TIMER_A module.
708 //! \param captureCompareRegister
709 //! Valid values are:
710 //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_0
711 //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_1
712 //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_2
713 //! \param synchronized
714 //! Valid values are:
715 //! - \b TIMER_A_READ_SYNCHRONIZED_CAPTURECOMPAREINPUT
716 //! - \b TIMER_A_READ_CAPTURE_COMPARE_INPUT
717 //!
718 //! \return One of the following:
719 //! - \b TIMER_A_CAPTURECOMPARE_INPUT_HIGH
720 //! - \b TIMER_A_CAPTURECOMPARE_INPUT_LOW
721 //
722 //*****************************************************************************
723 extern uint8_t Timer_A_getSynchronizedCaptureCompareInput(uint16_t baseAddress,
724  uint16_t captureCompareRegister,
725  uint16_t synchronized);
726 
727 //*****************************************************************************
728 //
729 //! \brief Get output bit for output mode
730 //!
731 //! \param baseAddress is the base address of the TIMER_A module.
732 //! \param captureCompareRegister
733 //! Valid values are:
734 //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_0
735 //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_1
736 //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_2
737 //!
738 //! \return One of the following:
739 //! - \b TIMER_A_OUTPUTMODE_OUTBITVALUE_HIGH
740 //! - \b TIMER_A_OUTPUTMODE_OUTBITVALUE_LOW
741 //
742 //*****************************************************************************
743 extern uint8_t Timer_A_getOutputForOutputModeOutBitValue(uint16_t baseAddress,
744  uint16_t captureCompareRegister);
745 
746 //*****************************************************************************
747 //
748 //! \brief Get current capturecompare count
749 //!
750 //! \param baseAddress is the base address of the TIMER_A module.
751 //! \param captureCompareRegister
752 //! Valid values are:
753 //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_0
754 //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_1
755 //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_2
756 //!
757 //! \return Current count as an uint16_t
758 //
759 //*****************************************************************************
760 extern uint16_t Timer_A_getCaptureCompareCount(uint16_t baseAddress,
761  uint16_t captureCompareRegister);
762 
763 //*****************************************************************************
764 //
765 //! \brief Set output bit for output mode
766 //!
767 //! \param baseAddress is the base address of the TIMER_A module.
768 //! \param captureCompareRegister
769 //! Valid values are:
770 //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_0
771 //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_1
772 //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_2
773 //! \param outputModeOutBitValue is the value to be set for out bit
774 //! Valid values are:
775 //! - \b TIMER_A_OUTPUTMODE_OUTBITVALUE_HIGH
776 //! - \b TIMER_A_OUTPUTMODE_OUTBITVALUE_LOW
777 //!
778 //! Modified bits of \b TAxCCTLn register.
779 //!
780 //! \return None
781 //
782 //*****************************************************************************
783 extern void Timer_A_setOutputForOutputModeOutBitValue(uint16_t baseAddress,
784  uint16_t captureCompareRegister,
785  uint8_t outputModeOutBitValue);
786 
787 //*****************************************************************************
788 //
789 //! \brief Generate a PWM with timer running in up mode
790 //!
791 //! \param baseAddress is the base address of the TIMER_A module.
792 //! \param param is the pointer to struct for PWM configuration.
793 //!
794 //! Modified bits of \b TAxCTL register, bits of \b TAxCCTL0 register, bits of
795 //! \b TAxCCR0 register and bits of \b TAxCCTLn register.
796 //!
797 //! \return None
798 //
799 //*****************************************************************************
800 extern void Timer_A_outputPWM(uint16_t baseAddress,
801  Timer_A_outputPWMParam *param);
802 
803 //*****************************************************************************
804 //
805 //! \brief Stops the timer
806 //!
807 //! \param baseAddress is the base address of the TIMER_A module.
808 //!
809 //! Modified bits of \b TAxCTL register.
810 //!
811 //! \return None
812 //
813 //*****************************************************************************
814 extern void Timer_A_stop(uint16_t baseAddress);
815 
816 //*****************************************************************************
817 //
818 //! \brief Sets the value of the capture-compare register
819 //!
820 //! \param baseAddress is the base address of the TIMER_A module.
821 //! \param compareRegister selects the Capture register being used. Refer to
822 //! datasheet to ensure the device has the capture compare register
823 //! being used.
824 //! Valid values are:
825 //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_0
826 //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_1
827 //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_2
828 //! \param compareValue is the count to be compared with in compare mode
829 //!
830 //! Modified bits of \b TAxCCRn register.
831 //!
832 //! \return None
833 //
834 //*****************************************************************************
835 extern void Timer_A_setCompareValue(uint16_t baseAddress,
836  uint16_t compareRegister,
837  uint16_t compareValue);
838 
839 //*****************************************************************************
840 //
841 //! \brief Sets the output mode
842 //!
843 //! Sets the output mode for the timer even the timer is already running.
844 //!
845 //! \param baseAddress is the base address of the TIMER_A module.
846 //! \param compareRegister selects the compare register being used.
847 //! Valid values are:
848 //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_0
849 //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_1
850 //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_2
851 //! \param compareOutputMode specifies the output mode.
852 //! Valid values are:
853 //! - \b TIMER_A_OUTPUTMODE_OUTBITVALUE [Default]
854 //! - \b TIMER_A_OUTPUTMODE_SET
855 //! - \b TIMER_A_OUTPUTMODE_TOGGLE_RESET
856 //! - \b TIMER_A_OUTPUTMODE_SET_RESET
857 //! - \b TIMER_A_OUTPUTMODE_TOGGLE
858 //! - \b TIMER_A_OUTPUTMODE_RESET
859 //! - \b TIMER_A_OUTPUTMODE_TOGGLE_SET
860 //! - \b TIMER_A_OUTPUTMODE_RESET_SET
861 //!
862 //! Modified bits are \b OUTMOD of \b TAxCCTLn register.
863 //!
864 //! \return None
865 //
866 //*****************************************************************************
867 extern void Timer_A_setOutputMode(uint16_t baseAddress,
868  uint16_t compareRegister,
869  uint16_t compareOutputMode);
870 
871 //*****************************************************************************
872 //
873 //! \brief Clears the Timer TAIFG interrupt flag
874 //!
875 //! \param baseAddress is the base address of the TIMER_A module.
876 //!
877 //! Modified bits are \b TAIFG of \b TAxCTL register.
878 //!
879 //! \return None
880 //
881 //*****************************************************************************
882 extern void Timer_A_clearTimerInterrupt(uint16_t baseAddress);
883 
884 //*****************************************************************************
885 //
886 //! \brief Clears the capture-compare interrupt flag
887 //!
888 //! \param baseAddress is the base address of the TIMER_A module.
889 //! \param captureCompareRegister selects the Capture-compare register being
890 //! used.
891 //! Valid values are:
892 //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_0
893 //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_1
894 //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_2
895 //!
896 //! Modified bits are \b CCIFG of \b TAxCCTLn register.
897 //!
898 //! \return None
899 //
900 //*****************************************************************************
901 extern void Timer_A_clearCaptureCompareInterrupt(uint16_t baseAddress,
902  uint16_t captureCompareRegister);
903 
904 //*****************************************************************************
905 //
906 //! \brief Reads the current timer count value
907 //!
908 //! Reads the current count value of the timer. There is a majority vote system
909 //! in place to confirm an accurate value is returned. The TIMER_A_THRESHOLD
910 //! #define in the corresponding header file can be modified so that the votes
911 //! must be closer together for a consensus to occur.
912 //!
913 //! \param baseAddress is the base address of the TIMER_A module.
914 //!
915 //! \return Majority vote of timer count value
916 //
917 //*****************************************************************************
918 extern uint16_t Timer_A_getCounterValue(uint16_t baseAddress);
919 
920 //*****************************************************************************
921 //
922 // Mark the end of the C bindings section for C++ compilers.
923 //
924 //*****************************************************************************
925 #ifdef __cplusplus
926 }
927 #endif
928 
929 #endif
930 #endif // __MSP430WARE_TIMER_A_H__
void Timer_A_initContinuousMode(uint16_t baseAddress, Timer_A_initContinuousModeParam *param)
Configures Timer_A in continuous mode.
Definition: timer_a.c:29
uint16_t captureOutputMode
Definition: timer_a.h:119
uint16_t timerClear
Definition: timer_a.h:66
uint16_t synchronizeCaptureSource
Definition: timer_a.h:103
bool startTimer
Whether to start the timer immediately.
Definition: timer_a.h:68
void Timer_A_disableCaptureCompareInterrupt(uint16_t baseAddress, uint16_t captureCompareRegister)
Disable capture compare interrupt.
Definition: timer_a.c:170
uint16_t captureRegister
Definition: timer_a.h:84
void Timer_A_startCounter(uint16_t baseAddress, uint16_t timerMode)
Starts Timer_A counter.
Definition: timer_a.c:21
uint16_t clockSourceDivider
Definition: timer_a.h:184
void Timer_A_stop(uint16_t baseAddress)
Stops the timer.
Definition: timer_a.c:258
void Timer_A_clearCaptureCompareInterrupt(uint16_t baseAddress, uint16_t captureCompareRegister)
Clears the capture-compare interrupt flag.
Definition: timer_a.c:283
uint16_t compareOutputMode
Definition: timer_a.h:204
uint16_t timerClear
Definition: timer_a.h:247
uint16_t timerPeriod
Is the specified Timer_A period.
Definition: timer_a.h:144
void Timer_A_enableInterrupt(uint16_t baseAddress)
Enable timer interrupt.
Definition: timer_a.c:148
void Timer_A_clearTimerInterrupt(uint16_t baseAddress)
Clears the Timer TAIFG interrupt flag.
Definition: timer_a.c:278
uint16_t Timer_A_getCaptureCompareCount(uint16_t baseAddress, uint16_t captureCompareRegister)
Get current capturecompare count.
Definition: timer_a.c:216
Used in the Timer_A_initUpDownMode() function as the param parameter.
Definition: timer_a.h:128
uint16_t clockSource
Definition: timer_a.h:48
uint8_t Timer_A_getSynchronizedCaptureCompareInput(uint16_t baseAddress, uint16_t captureCompareRegister, uint16_t synchronized)
Get synchronized capturecompare input.
Definition: timer_a.c:191
uint16_t compareOutputMode
Definition: timer_a.h:281
uint16_t timerInterruptEnable_TAIE
Definition: timer_a.h:149
void Timer_A_initCompareMode(uint16_t baseAddress, Timer_A_initCompareModeParam *param)
Initializes Compare Mode.
Definition: timer_a.c:131
uint16_t dutyCycle
Specifies the dutycycle for the generated waveform.
Definition: timer_a.h:206
bool startTimer
Whether to start the timer immediately.
Definition: timer_a.h:249
uint16_t timerClear
Definition: timer_a.h:160
uint16_t captureCompareInterruptEnable_CCR0_CCIE
Definition: timer_a.h:154
uint16_t compareInterruptEnable
Definition: timer_a.h:270
uint16_t timerPeriod
Definition: timer_a.h:231
void Timer_A_setOutputForOutputModeOutBitValue(uint16_t baseAddress, uint16_t captureCompareRegister, uint8_t outputModeOutBitValue)
Set output bit for output mode.
Definition: timer_a.c:224
uint16_t clockSourceDivider
Definition: timer_a.h:228
Used in the Timer_A_initCaptureMode() function as the param parameter.
Definition: timer_a.h:77
Used in the Timer_A_initUpMode() function as the param parameter.
Definition: timer_a.h:214
Used in the Timer_A_initCompareMode() function as the param parameter.
Definition: timer_a.h:258
void Timer_A_enableCaptureCompareInterrupt(uint16_t baseAddress, uint16_t captureCompareRegister)
Enable capture compare interrupt.
Definition: timer_a.c:163
uint16_t captureMode
Definition: timer_a.h:91
void Timer_A_disableInterrupt(uint16_t baseAddress)
Disable timer interrupt.
Definition: timer_a.c:153
void Timer_A_initUpDownMode(uint16_t baseAddress, Timer_A_initUpDownModeParam *param)
Configures Timer_A in up down mode.
Definition: timer_a.c:80
uint16_t clockSource
Definition: timer_a.h:177
uint16_t compareValue
Is the count to be compared with in compare mode.
Definition: timer_a.h:283
uint16_t captureInputSelect
Definition: timer_a.h:98
void Timer_A_setCompareValue(uint16_t baseAddress, uint16_t compareRegister, uint16_t compareValue)
Sets the value of the capture-compare register.
Definition: timer_a.c:263
void Timer_A_initCaptureMode(uint16_t baseAddress, Timer_A_initCaptureModeParam *param)
Initializes Capture Mode.
Definition: timer_a.c:109
uint16_t Timer_A_getCounterValue(uint16_t baseAddress)
Reads the current timer count value.
Definition: timer_a.c:290
uint32_t Timer_A_getInterruptStatus(uint16_t baseAddress)
Get timer interrupt status.
Definition: timer_a.c:158
Used in the Timer_A_outputPWM() function as the param parameter.
Definition: timer_a.h:170
void Timer_A_outputPWM(uint16_t baseAddress, Timer_A_outputPWMParam *param)
Generate a PWM with timer running in up mode.
Definition: timer_a.c:234
uint16_t compareRegister
Definition: timer_a.h:265
uint16_t timerInterruptEnable_TAIE
Definition: timer_a.h:236
void Timer_A_initUpMode(uint16_t baseAddress, Timer_A_initUpModeParam *param)
Configures Timer_A in up mode.
Definition: timer_a.c:50
bool startTimer
Whether to start the timer immediately.
Definition: timer_a.h:162
uint16_t clockSourceDivider
Definition: timer_a.h:55
uint32_t Timer_A_getCaptureCompareInterruptStatus(uint16_t baseAddress, uint16_t captureCompareRegister, uint16_t mask)
Return capture compare interrupt status.
Definition: timer_a.c:177
uint16_t clockSource
Definition: timer_a.h:135
uint8_t Timer_A_getOutputForOutputModeOutBitValue(uint16_t baseAddress, uint16_t captureCompareRegister)
Get output bit for output mode.
Definition: timer_a.c:204
uint16_t clockSourceDivider
Definition: timer_a.h:142
Used in the Timer_A_initContinuousMode() function as the param parameter.
Definition: timer_a.h:41
void Timer_A_setOutputMode(uint16_t baseAddress, uint16_t compareRegister, uint16_t compareOutputMode)
Sets the output mode.
Definition: timer_a.c:271
uint16_t compareRegister
Definition: timer_a.h:193
void Timer_A_clear(uint16_t baseAddress)
Reset/Clear the timer clock divider, count direction, count.
Definition: timer_a.c:185
uint16_t captureInterruptEnable
Definition: timer_a.h:108
uint16_t timerPeriod
Selects the desired timer period.
Definition: timer_a.h:186
uint16_t timerInterruptEnable_TAIE
Definition: timer_a.h:60
uint16_t captureCompareInterruptEnable_CCR0_CCIE
Definition: timer_a.h:241
uint16_t clockSource
Definition: timer_a.h:221

Copyright 2020, Texas Instruments Incorporated