MSP430 DriverLib for MSP430i2xx Devices  2.10.00.09
 All Data Structures Functions Variables Modules Pages
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 param parameter for
374 // functions: Timer_A_initCaptureMode(), Timer_A_initCompareMode(), and
375 // Timer_A_outputPWM().
376 //
377 //*****************************************************************************
378 #define TIMER_A_OUTPUTMODE_OUTBITVALUE OUTMOD_0
379 #define TIMER_A_OUTPUTMODE_SET OUTMOD_1
380 #define TIMER_A_OUTPUTMODE_TOGGLE_RESET OUTMOD_2
381 #define TIMER_A_OUTPUTMODE_SET_RESET OUTMOD_3
382 #define TIMER_A_OUTPUTMODE_TOGGLE OUTMOD_4
383 #define TIMER_A_OUTPUTMODE_RESET OUTMOD_5
384 #define TIMER_A_OUTPUTMODE_TOGGLE_SET OUTMOD_6
385 #define TIMER_A_OUTPUTMODE_RESET_SET OUTMOD_7
386 
387 //*****************************************************************************
388 //
389 // The following are values that can be passed to the compareRegister parameter
390 // for functions: Timer_A_setCompareValue(); the captureCompareRegister
391 // parameter for functions: Timer_A_enableCaptureCompareInterrupt(),
392 // Timer_A_disableCaptureCompareInterrupt(),
393 // Timer_A_getCaptureCompareInterruptStatus(),
394 // Timer_A_getSynchronizedCaptureCompareInput(),
395 // Timer_A_getOutputForOutputModeOutBitValue(),
396 // Timer_A_getCaptureCompareCount(),
397 // Timer_A_setOutputForOutputModeOutBitValue(), and
398 // Timer_A_clearCaptureCompareInterrupt(); the param parameter for functions:
399 // Timer_A_initCaptureMode(), Timer_A_initCompareMode(), and
400 // Timer_A_outputPWM().
401 //
402 //*****************************************************************************
403 #define TIMER_A_CAPTURECOMPARE_REGISTER_0 0x02
404 #define TIMER_A_CAPTURECOMPARE_REGISTER_1 0x04
405 #define TIMER_A_CAPTURECOMPARE_REGISTER_2 0x06
406 
407 //*****************************************************************************
408 //
409 // The following are values that can be passed to the param parameter for
410 // functions: Timer_A_initCaptureMode().
411 //
412 //*****************************************************************************
413 #define TIMER_A_CAPTUREMODE_NO_CAPTURE CM_0
414 #define TIMER_A_CAPTUREMODE_RISING_EDGE CM_1
415 #define TIMER_A_CAPTUREMODE_FALLING_EDGE CM_2
416 #define TIMER_A_CAPTUREMODE_RISING_AND_FALLING_EDGE CM_3
417 
418 //*****************************************************************************
419 //
420 // The following are values that can be passed to the param parameter for
421 // functions: Timer_A_initCaptureMode().
422 //
423 //*****************************************************************************
424 #define TIMER_A_CAPTURE_ASYNCHRONOUS 0x00
425 #define TIMER_A_CAPTURE_SYNCHRONOUS SCS
426 
427 //*****************************************************************************
428 //
429 // The following are values that can be passed to the mask parameter for
430 // functions: Timer_A_getCaptureCompareInterruptStatus() as well as returned by
431 // the Timer_A_getCaptureCompareInterruptStatus() function.
432 //
433 //*****************************************************************************
434 #define TIMER_A_CAPTURE_OVERFLOW COV
435 #define TIMER_A_CAPTURECOMPARE_INTERRUPT_FLAG CCIFG
436 
437 //*****************************************************************************
438 //
439 // The following are values that can be passed to the synchronized parameter
440 // for functions: Timer_A_getSynchronizedCaptureCompareInput().
441 //
442 //*****************************************************************************
443 #define TIMER_A_READ_SYNCHRONIZED_CAPTURECOMPAREINPUT SCCI
444 #define TIMER_A_READ_CAPTURE_COMPARE_INPUT CCI
445 
446 //*****************************************************************************
447 //
448 // The following are values that can be passed toThe following are values that
449 // can be returned by the Timer_A_getSynchronizedCaptureCompareInput()
450 // function.
451 //
452 //*****************************************************************************
453 #define TIMER_A_CAPTURECOMPARE_INPUT_HIGH 0x01
454 #define TIMER_A_CAPTURECOMPARE_INPUT_LOW 0x00
455 
456 //*****************************************************************************
457 //
458 // The following are values that can be passed to the outputModeOutBitValue
459 // parameter for functions: Timer_A_setOutputForOutputModeOutBitValue() as well
460 // as returned by the Timer_A_getOutputForOutputModeOutBitValue() function.
461 //
462 //*****************************************************************************
463 #define TIMER_A_OUTPUTMODE_OUTBITVALUE_HIGH OUT
464 #define TIMER_A_OUTPUTMODE_OUTBITVALUE_LOW 0x00
465 
466 //*****************************************************************************
467 //
468 // The following are values that can be passed toThe following are values that
469 // can be returned by the Timer_A_getInterruptStatus() function.
470 //
471 //*****************************************************************************
472 #define TIMER_A_INTERRUPT_NOT_PENDING 0x00
473 #define TIMER_A_INTERRUPT_PENDING 0x01
474 
475 //*****************************************************************************
476 //
477 // Prototypes for the APIs.
478 //
479 //*****************************************************************************
480 
481 //*****************************************************************************
482 //
483 //! \brief Starts Timer_A counter
484 //!
485 //! This function assumes that the timer has been previously configured using
486 //! Timer_A_initContinuousMode, Timer_A_initUpMode or Timer_A_initUpDownMode.
487 //!
488 //! \param baseAddress is the base address of the TIMER_A module.
489 //! \param timerMode mode to put the timer in
490 //! Valid values are:
491 //! - \b TIMER_A_STOP_MODE
492 //! - \b TIMER_A_UP_MODE
493 //! - \b TIMER_A_CONTINUOUS_MODE [Default]
494 //! - \b TIMER_A_UPDOWN_MODE
495 //!
496 //! Modified bits of \b TAxCTL register.
497 //!
498 //! \return None
499 //
500 //*****************************************************************************
501 extern void Timer_A_startCounter(uint16_t baseAddress,
502  uint16_t timerMode);
503 
504 //*****************************************************************************
505 //
506 //! \brief Configures Timer_A in continuous mode.
507 //!
508 //! \param baseAddress is the base address of the TIMER_A module.
509 //! \param param is the pointer to struct for continuous mode initialization.
510 //!
511 //! Modified bits of \b TAxCTL register.
512 //!
513 //! \return None
514 //
515 //*****************************************************************************
516 extern void Timer_A_initContinuousMode(uint16_t baseAddress,
518 
519 //*****************************************************************************
520 //
521 //! \brief Configures Timer_A in up mode.
522 //!
523 //! \param baseAddress is the base address of the TIMER_A module.
524 //! \param param is the pointer to struct for up mode initialization.
525 //!
526 //! Modified bits of \b TAxCTL register, bits of \b TAxCCTL0 register and bits
527 //! of \b TAxCCR0 register.
528 //!
529 //! \return None
530 //
531 //*****************************************************************************
532 extern void Timer_A_initUpMode(uint16_t baseAddress,
533  Timer_A_initUpModeParam *param);
534 
535 //*****************************************************************************
536 //
537 //! \brief Configures Timer_A in up down mode.
538 //!
539 //! \param baseAddress is the base address of the TIMER_A module.
540 //! \param param is the pointer to struct for up-down mode initialization.
541 //!
542 //! Modified bits of \b TAxCTL register, bits of \b TAxCCTL0 register and bits
543 //! of \b TAxCCR0 register.
544 //!
545 //! \return None
546 //
547 //*****************************************************************************
548 extern void Timer_A_initUpDownMode(uint16_t baseAddress,
550 
551 //*****************************************************************************
552 //
553 //! \brief Initializes Capture Mode
554 //!
555 //! \param baseAddress is the base address of the TIMER_A module.
556 //! \param param is the pointer to struct for capture mode initialization.
557 //!
558 //! Modified bits of \b TAxCCTLn register.
559 //!
560 //! \return None
561 //
562 //*****************************************************************************
563 extern void Timer_A_initCaptureMode(uint16_t baseAddress,
565 
566 //*****************************************************************************
567 //
568 //! \brief Initializes Compare Mode
569 //!
570 //! \param baseAddress is the base address of the TIMER_A module.
571 //! \param param is the pointer to struct for compare mode initialization.
572 //!
573 //! Modified bits of \b TAxCCRn register and bits of \b TAxCCTLn register.
574 //!
575 //! \return None
576 //
577 //*****************************************************************************
578 extern void Timer_A_initCompareMode(uint16_t baseAddress,
580 
581 //*****************************************************************************
582 //
583 //! \brief Enable timer interrupt
584 //!
585 //! Does not clear interrupt flags
586 //!
587 //! \param baseAddress is the base address of the TIMER_A module.
588 //!
589 //! Modified bits of \b TAxCTL register.
590 //!
591 //! \return None
592 //
593 //*****************************************************************************
594 extern void Timer_A_enableInterrupt(uint16_t baseAddress);
595 
596 //*****************************************************************************
597 //
598 //! \brief Disable timer interrupt
599 //!
600 //! \param baseAddress is the base address of the TIMER_A module.
601 //!
602 //! Modified bits of \b TAxCTL register.
603 //!
604 //! \return None
605 //
606 //*****************************************************************************
607 extern void Timer_A_disableInterrupt(uint16_t baseAddress);
608 
609 //*****************************************************************************
610 //
611 //! \brief Get timer interrupt status
612 //!
613 //! \param baseAddress is the base address of the TIMER_A module.
614 //!
615 //! \return One of the following:
616 //! - \b Timer_A_INTERRUPT_NOT_PENDING
617 //! - \b Timer_A_INTERRUPT_PENDING
618 //! \n indicating the Timer_A interrupt status
619 //
620 //*****************************************************************************
621 extern uint32_t Timer_A_getInterruptStatus(uint16_t baseAddress);
622 
623 //*****************************************************************************
624 //
625 //! \brief Enable capture compare interrupt
626 //!
627 //! Does not clear interrupt flags
628 //!
629 //! \param baseAddress is the base address of the TIMER_A module.
630 //! \param captureCompareRegister is the selected capture compare register
631 //! Valid values are:
632 //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_0
633 //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_1
634 //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_2
635 //!
636 //! Modified bits of \b TAxCCTLn register.
637 //!
638 //! \return None
639 //
640 //*****************************************************************************
641 extern void Timer_A_enableCaptureCompareInterrupt(uint16_t baseAddress,
642  uint16_t captureCompareRegister);
643 
644 //*****************************************************************************
645 //
646 //! \brief Disable capture compare interrupt
647 //!
648 //! \param baseAddress is the base address of the TIMER_A module.
649 //! \param captureCompareRegister is the selected capture compare register
650 //! Valid values are:
651 //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_0
652 //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_1
653 //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_2
654 //!
655 //! Modified bits of \b TAxCCTLn register.
656 //!
657 //! \return None
658 //
659 //*****************************************************************************
660 extern void Timer_A_disableCaptureCompareInterrupt(uint16_t baseAddress,
661  uint16_t captureCompareRegister);
662 
663 //*****************************************************************************
664 //
665 //! \brief Return capture compare interrupt status
666 //!
667 //! \param baseAddress is the base address of the TIMER_A module.
668 //! \param captureCompareRegister is the selected capture compare register
669 //! Valid values are:
670 //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_0
671 //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_1
672 //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_2
673 //! \param mask is the mask for the interrupt status
674 //! Mask value is the logical OR of any of the following:
675 //! - \b TIMER_A_CAPTURE_OVERFLOW
676 //! - \b TIMER_A_CAPTURECOMPARE_INTERRUPT_FLAG
677 //!
678 //! \return Logical OR of any of the following:
679 //! - \b Timer_A_CAPTURE_OVERFLOW
680 //! - \b Timer_A_CAPTURECOMPARE_INTERRUPT_FLAG
681 //! \n indicating the status of the masked interrupts
682 //
683 //*****************************************************************************
684 extern uint32_t Timer_A_getCaptureCompareInterruptStatus(uint16_t baseAddress,
685  uint16_t captureCompareRegister,
686  uint16_t mask);
687 
688 //*****************************************************************************
689 //
690 //! \brief Reset/Clear the timer clock divider, count direction, count
691 //!
692 //! \param baseAddress is the base address of the TIMER_A module.
693 //!
694 //! Modified bits of \b TAxCTL register.
695 //!
696 //! \return None
697 //
698 //*****************************************************************************
699 extern void Timer_A_clear(uint16_t baseAddress);
700 
701 //*****************************************************************************
702 //
703 //! \brief Get synchronized capturecompare input
704 //!
705 //! \param baseAddress is the base address of the TIMER_A module.
706 //! \param captureCompareRegister
707 //! Valid values are:
708 //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_0
709 //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_1
710 //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_2
711 //! \param synchronized
712 //! Valid values are:
713 //! - \b TIMER_A_READ_SYNCHRONIZED_CAPTURECOMPAREINPUT
714 //! - \b TIMER_A_READ_CAPTURE_COMPARE_INPUT
715 //!
716 //! \return One of the following:
717 //! - \b Timer_A_CAPTURECOMPARE_INPUT_HIGH
718 //! - \b Timer_A_CAPTURECOMPARE_INPUT_LOW
719 //
720 //*****************************************************************************
721 extern uint8_t Timer_A_getSynchronizedCaptureCompareInput(uint16_t baseAddress,
722  uint16_t captureCompareRegister,
723  uint16_t synchronized);
724 
725 //*****************************************************************************
726 //
727 //! \brief Get output bit for output mode
728 //!
729 //! \param baseAddress is the base address of the TIMER_A module.
730 //! \param captureCompareRegister
731 //! Valid values are:
732 //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_0
733 //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_1
734 //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_2
735 //!
736 //! \return One of the following:
737 //! - \b Timer_A_OUTPUTMODE_OUTBITVALUE_HIGH
738 //! - \b Timer_A_OUTPUTMODE_OUTBITVALUE_LOW
739 //
740 //*****************************************************************************
741 extern uint8_t Timer_A_getOutputForOutputModeOutBitValue(uint16_t baseAddress,
742  uint16_t captureCompareRegister);
743 
744 //*****************************************************************************
745 //
746 //! \brief Get current capturecompare count
747 //!
748 //! \param baseAddress is the base address of the TIMER_A module.
749 //! \param captureCompareRegister
750 //! Valid values are:
751 //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_0
752 //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_1
753 //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_2
754 //!
755 //! \return Current count as an uint16_t
756 //
757 //*****************************************************************************
758 extern uint16_t Timer_A_getCaptureCompareCount(uint16_t baseAddress,
759  uint16_t captureCompareRegister);
760 
761 //*****************************************************************************
762 //
763 //! \brief Set output bit for output mode
764 //!
765 //! \param baseAddress is the base address of the TIMER_A module.
766 //! \param captureCompareRegister
767 //! Valid values are:
768 //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_0
769 //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_1
770 //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_2
771 //! \param outputModeOutBitValue is the value to be set for out bit
772 //! Valid values are:
773 //! - \b TIMER_A_OUTPUTMODE_OUTBITVALUE_HIGH
774 //! - \b TIMER_A_OUTPUTMODE_OUTBITVALUE_LOW
775 //!
776 //! Modified bits of \b TAxCCTLn register.
777 //!
778 //! \return None
779 //
780 //*****************************************************************************
781 extern void Timer_A_setOutputForOutputModeOutBitValue(uint16_t baseAddress,
782  uint16_t captureCompareRegister,
783  uint8_t outputModeOutBitValue);
784 
785 //*****************************************************************************
786 //
787 //! \brief Generate a PWM with timer running in up mode
788 //!
789 //! \param baseAddress is the base address of the TIMER_A module.
790 //! \param param is the pointer to struct for PWM configuration.
791 //!
792 //! Modified bits of \b TAxCTL register, bits of \b TAxCCTL0 register, bits of
793 //! \b TAxCCR0 register and bits of \b TAxCCTLn register.
794 //!
795 //! \return None
796 //
797 //*****************************************************************************
798 extern void Timer_A_outputPWM(uint16_t baseAddress,
799  Timer_A_outputPWMParam *param);
800 
801 //*****************************************************************************
802 //
803 //! \brief Stops the timer
804 //!
805 //! \param baseAddress is the base address of the TIMER_A module.
806 //!
807 //! Modified bits of \b TAxCTL register.
808 //!
809 //! \return None
810 //
811 //*****************************************************************************
812 extern void Timer_A_stop(uint16_t baseAddress);
813 
814 //*****************************************************************************
815 //
816 //! \brief Sets the value of the capture-compare register
817 //!
818 //! \param baseAddress is the base address of the TIMER_A module.
819 //! \param compareRegister selects the Capture register being used. Refer to
820 //! datasheet to ensure the device has the capture compare register
821 //! being used.
822 //! Valid values are:
823 //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_0
824 //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_1
825 //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_2
826 //! \param compareValue is the count to be compared with in compare mode
827 //!
828 //! Modified bits of \b TAxCCRn register.
829 //!
830 //! \return None
831 //
832 //*****************************************************************************
833 extern void Timer_A_setCompareValue(uint16_t baseAddress,
834  uint16_t compareRegister,
835  uint16_t compareValue);
836 
837 //*****************************************************************************
838 //
839 //! \brief Clears the Timer TAIFG interrupt flag
840 //!
841 //! \param baseAddress is the base address of the TIMER_A module.
842 //!
843 //! Modified bits are \b TAIFG of \b TAxCTL register.
844 //!
845 //! \return None
846 //
847 //*****************************************************************************
848 extern void Timer_A_clearTimerInterrupt(uint16_t baseAddress);
849 
850 //*****************************************************************************
851 //
852 //! \brief Clears the capture-compare interrupt flag
853 //!
854 //! \param baseAddress is the base address of the TIMER_A module.
855 //! \param captureCompareRegister selects the Capture-compare register being
856 //! used.
857 //! Valid values are:
858 //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_0
859 //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_1
860 //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_2
861 //!
862 //! Modified bits are \b CCIFG of \b TAxCCTLn register.
863 //!
864 //! \return None
865 //
866 //*****************************************************************************
867 extern void Timer_A_clearCaptureCompareInterrupt(uint16_t baseAddress,
868  uint16_t captureCompareRegister);
869 
870 //*****************************************************************************
871 //
872 //! \brief Reads the current timer count value
873 //!
874 //! Reads the current count value of the timer. There is a majority vote system
875 //! in place to confirm an accurate value is returned. The TIMER_A_THRESHOLD
876 //! #define in the corresponding header file can be modified so that the votes
877 //! must be closer together for a consensus to occur.
878 //!
879 //! \param baseAddress is the base address of the TIMER_A module.
880 //!
881 //! \return Majority vote of timer count value
882 //
883 //*****************************************************************************
884 extern uint16_t Timer_A_getCounterValue(uint16_t baseAddress);
885 
886 //*****************************************************************************
887 //
888 // Mark the end of the C bindings section for C++ compilers.
889 //
890 //*****************************************************************************
891 #ifdef __cplusplus
892 }
893 #endif
894 
895 #endif
896 #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:28
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:169
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:256
void Timer_A_clearCaptureCompareInterrupt(uint16_t baseAddress, uint16_t captureCompareRegister)
Clears the capture-compare interrupt flag.
Definition: timer_a.c:274
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:147
void Timer_A_clearTimerInterrupt(uint16_t baseAddress)
Clears the Timer TAIFG interrupt flag.
Definition: timer_a.c:269
uint16_t Timer_A_getCaptureCompareCount(uint16_t baseAddress, uint16_t captureCompareRegister)
Get current capturecompare count.
Definition: timer_a.c:215
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:190
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:130
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:223
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:162
uint16_t captureMode
Definition: timer_a.h:91
void Timer_A_disableInterrupt(uint16_t baseAddress)
Disable timer interrupt.
Definition: timer_a.c:152
void Timer_A_initUpDownMode(uint16_t baseAddress, Timer_A_initUpDownModeParam *param)
Configures Timer_A in up down mode.
Definition: timer_a.c:79
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:261
void Timer_A_initCaptureMode(uint16_t baseAddress, Timer_A_initCaptureModeParam *param)
Initializes Capture Mode.
Definition: timer_a.c:108
uint16_t Timer_A_getCounterValue(uint16_t baseAddress)
Reads the current timer count value.
Definition: timer_a.c:281
uint32_t Timer_A_getInterruptStatus(uint16_t baseAddress)
Get timer interrupt status.
Definition: timer_a.c:157
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:233
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:49
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:176
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:203
uint16_t clockSourceDivider
Definition: timer_a.h:142
Used in the Timer_A_initContinuousMode() function as the param parameter.
Definition: timer_a.h:41
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:184
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 2015, Texas Instruments Incorporated