timerb.h
Go to the documentation of this file.
00001 #ifndef __MSP430WARE_TIMERB_H__
00002 #define __MSP430WARE_TIMERB_H__
00003 
00004 #define __MSP430_HAS_TxB7__
00005 //*****************************************************************************
00006 //
00007 //The following are values that can be passed to the
00008 //TimerB_startContinuousMode();, TimerB_startUpMode();, TimerB_startUpDownMode();,
00009 //TimerB_generatePWM(); APIs as the clockSource parameter.
00010 //
00011 //*****************************************************************************
00012 #define TIMERB_CLOCKSOURCE_EXTERNAL_TXCLK            TBSSEL__TBCLK
00013 #define TIMERB_CLOCKSOURCE_ACLK                      TBSSEL__ACLK
00014 #define TIMERB_CLOCKSOURCE_SMCLK                     TBSSEL__SMCLK
00015 #define TIMERB_CLOCKSOURCE_INVERTED_EXTERNAL_TXCLK   TBSSEL__INCLK
00016 
00017 //*****************************************************************************
00018 //
00019 //The following are values that can be passed to the
00020 //TimerB_startContinuousMode();, TimerB_startUpMode();, TimerB_startUpDownMode();,
00021 //TimerB_generatePWM(); APIs as the clockSourceDivider parameter.
00022 //
00023 //*****************************************************************************
00024 #define TIMERB_CLOCKSOURCE_DIVIDER_1     0x01
00025 #define TIMERB_CLOCKSOURCE_DIVIDER_2     0x02
00026 #define TIMERB_CLOCKSOURCE_DIVIDER_4     0x04
00027 #define TIMERB_CLOCKSOURCE_DIVIDER_8     0x08
00028 #define TIMERB_CLOCKSOURCE_DIVIDER_3     0x03
00029 #define TIMERB_CLOCKSOURCE_DIVIDER_5     0x05
00030 #define TIMERB_CLOCKSOURCE_DIVIDER_6     0x06
00031 #define TIMERB_CLOCKSOURCE_DIVIDER_7     0x07
00032 #define TIMERB_CLOCKSOURCE_DIVIDER_10    0x0A
00033 #define TIMERB_CLOCKSOURCE_DIVIDER_12    0x0C
00034 #define TIMERB_CLOCKSOURCE_DIVIDER_14    0x0E
00035 #define TIMERB_CLOCKSOURCE_DIVIDER_16    0x10
00036 #define TIMERB_CLOCKSOURCE_DIVIDER_20    0x14
00037 #define TIMERB_CLOCKSOURCE_DIVIDER_24    0x18
00038 #define TIMERB_CLOCKSOURCE_DIVIDER_28    0x1C
00039 #define TIMERB_CLOCKSOURCE_DIVIDER_32    0x20
00040 #define TIMERB_CLOCKSOURCE_DIVIDER_40    0x28
00041 #define TIMERB_CLOCKSOURCE_DIVIDER_48    0x30
00042 #define TIMERB_CLOCKSOURCE_DIVIDER_56    0x38
00043 #define TIMERB_CLOCKSOURCE_DIVIDER_64    0x40
00044 
00045 //*****************************************************************************
00046 //
00047 //The following are values that can be passed to TimerB_startContinuousMode();
00048 //TimerB_startUpMode();,  TimerB_startUpDownMode(); as the timerClear parameter.
00049 //
00050 //*****************************************************************************
00051 #define TIMERB_DO_CLEAR      TBCLR
00052 #define TIMERB_SKIP_CLEAR    0x00
00053 
00054 //*****************************************************************************
00055 //
00056 //The following are values that can be passed to the
00057 //TimerB_getSynchronizedCaptureCompareInput(); API as the synchronized
00058 //parameter.
00059 //
00060 //*****************************************************************************
00061 #define TIMERB_CAPTURECOMPARE_INPUT                  SCCI
00062 #define TIMERB_SYNCHRONIZED_CAPTURECOMPARE_INPUT     CCI
00063 
00064 //*****************************************************************************
00065 //
00066 //The following are values that is returned by the
00067 //TimerB_getSynchronizedCaptureCompareInput(); API
00068 //
00069 //*****************************************************************************
00070 #define TIMERB_CAPTURECOMPARE_INPUT_HIGH    0x01
00071 #define TIMERB_CAPTURECOMPARE_INPUT_LOW     0x00
00072 
00073 
00074 //*****************************************************************************
00075 //
00076 //The following are values that is returned by the
00077 //TimerB_getOutputForOutputModeOutBitValue(); and passed to
00078 //TimerB_setOutputForOutputModeOutBitValue(); as
00079 //outputModeOutBitValue parameter
00080 //
00081 //*****************************************************************************
00082 #define TIMERB_OUTPUTMODE_OUTBITVALUE_HIGH    OUT
00083 #define TIMERB_OUTPUTMODE_OUTBITVALUE_LOW     0x00
00084 
00085 //*****************************************************************************
00086 //
00087 //The following are values can be passed to the mask parameter of
00088 //TimerB_captureCompareInterruptStatus(); API
00089 //
00090 //*****************************************************************************
00091 #define TIMERB_CAPTURE_OVERFLOW                  COV
00092 #define TIMERB_CAPTURECOMPARE_INTERRUPT_FLAG     CCIFG
00093 
00094 //*****************************************************************************
00095 //
00096 //The following are values can be passed to the timerInterruptEnable_TBIE
00097 //parameter of TimerB_startContinuousMode();, TimerB_startUpMode();,
00098 //TimerB_startUpDownMode();
00099 //
00100 //*****************************************************************************
00101 #define TIMERB_TBIE_INTERRUPT_ENABLE            TBIE
00102 #define TIMERB_TBIE_INTERRUPT_DISABLE           0x00
00103 
00104 //*****************************************************************************
00105 //
00106 //The following are values can be passed to the
00107 //captureCompareInterruptEnable_CCR0_CCIE parameter of TimerB_startUpMode();,
00108 //TimerB_startUpDownMode API
00109 //
00110 //*****************************************************************************
00111 #define TIMERB_CCIE_CCR0_INTERRUPT_ENABLE   CCIE
00112 #define TIMERB_CCIE_CCR0_INTERRUPT_DISABLE  0x00
00113 
00114 //*****************************************************************************
00115 //
00116 //The following are timer modes possible.
00117 //
00118 //*****************************************************************************
00119 #define TIMERB_STOP_MODE         MC_0
00120 #define TIMERB_UP_MODE           MC_1
00121 #define TIMERB_CONTINUOUS_MODE   MC_2
00122 #define TIMERB_UPDOWN_MODE       MC_3
00123 
00124 //*****************************************************************************
00125 //
00126 //The following are values can be passed to the
00127 //compareRegister, captureCompareRegister or captureRegister parameter
00128 //of TimerB_initCapture();, TimerB_enableCaptureCompareInterrupt();,
00129 //TimerB_disableCaptureCompareInterrupt();,TimerB_captureCompareInterruptStatus();,
00130 //TimerB_getSynchronizedCaptureCompareInput();,TimerB_initCompare();
00131 //
00132 //*****************************************************************************
00133 #define TIMERB_CAPTURECOMPARE_REGISTER_0     0x02
00134 #define TIMERB_CAPTURECOMPARE_REGISTER_1     0x04
00135 #define TIMERB_CAPTURECOMPARE_REGISTER_2     0x06
00136 #define TIMERB_CAPTURECOMPARE_REGISTER_3     0x08
00137 #define TIMERB_CAPTURECOMPARE_REGISTER_4     0x0A
00138 #define TIMERB_CAPTURECOMPARE_REGISTER_5     0x0C
00139 #define TIMERB_CAPTURECOMPARE_REGISTER_6     0x0E
00140 
00141 //*****************************************************************************
00142 //
00143 //The following are values can be passed to the
00144 //captureMode parameter of TimerB_initCompare();, TimerB_initCapture();,
00145 //TimerB_generatePWM();,
00146 //
00147 //*****************************************************************************
00148 #define TIMERB_OUTPUTMODE_OUTBITVALUE        OUTMOD_0
00149 #define TIMERB_OUTPUTMODE_SET                OUTMOD_1
00150 #define TIMERB_OUTPUTMODE_TOGGLE_RESET       OUTMOD_2
00151 #define TIMERB_OUTPUTMODE_SET_RESET          OUTMOD_3
00152 #define TIMERB_OUTPUTMODE_TOGGLE             OUTMOD_4
00153 #define TIMERB_OUTPUTMODE_RESET              OUTMOD_5
00154 #define TIMERB_OUTPUTMODE_TOGGLE_SET         OUTMOD_6
00155 #define TIMERB_OUTPUTMODE_RESET_SET          OUTMOD_7
00156 
00157 //*****************************************************************************
00158 //
00159 //The following are values can be passed to the
00160 //captureMode parameter of TimerB_initCapture(); API
00161 //
00162 //*****************************************************************************
00163 #define TIMERB_CAPTUREMODE_NO_CAPTURE                CM_0
00164 #define TIMERB_CAPTUREMODE_RISING_EDGE               CM_1
00165 #define TIMERB_CAPTUREMODE_FALLING_EDGE              CM_2
00166 #define TIMERB_CAPTUREMODE_RISING_AND_FALLING_EDGE   CM_3
00167 
00168 //*****************************************************************************
00169 //
00170 //The following are values can be passed to the
00171 //synchronizeCaptureSource parameter of TimerB_initCapture(); API
00172 //
00173 //*****************************************************************************
00174 #define TIMERB_CAPTURE_ASYNCHRONOUS                  0x00
00175 #define TIMERB_CAPTURE_SYNCHRONOUS                   SCS
00176 
00177 //*****************************************************************************
00178 //
00179 //The following are values can be passed to the
00180 //captureInterruptEnable, compareInterruptEnable parameter of
00181 //TimerB_initCapture(); API
00182 //
00183 //*****************************************************************************
00184 #define TIMERB_CAPTURECOMPARE_INTERRUPT_ENABLE       CCIE
00185 #define TIMERB_CAPTURECOMPARE_INTERRUPT_DISABLE      0x00
00186 
00187 //*****************************************************************************
00188 //
00189 //The following are values can be passed to the
00190 //captureInputSelect parameter of TimerB_initCapture(); API
00191 //
00192 //*****************************************************************************
00193 #define TIMERB_CAPTURE_INPUTSELECT_CCIxA             CCIS_0
00194 #define TIMERB_CAPTURE_INPUTSELECT_CCIxB             CCIS_1
00195 #define TIMERB_CAPTURE_INPUTSELECT_GND               CCIS_2
00196 #define TIMERB_CAPTURE_INPUTSELECT_Vcc               CCIS_3
00197 
00198 //*****************************************************************************
00199 //
00200 //The following are values can be passed to the
00201 //counterLength parameter of TimerB_selectCounterLength(); API
00202 //
00203 //*****************************************************************************
00204 #define TIMERB_COUNTER_8BIT CNTL_0
00205 #define TIMERB_COUNTER_10BIT CNTL_1
00206 #define TIMERB_COUNTER_12BIT CNTL_2
00207 #define TIMERB_COUNTER_16BIT CNTL_3
00208 
00209 //*****************************************************************************
00210 //
00211 //The following are values can be passed to the
00212 //groupLatch parameter of TimerB_selectLatchingGroup(); API
00213 //
00214 //*****************************************************************************
00215 #define TIMERB_GROUP_NONE                               TBCLGRP_0
00216 #define TIMERB_GROUP_CL12_CL23_CL56     TBCLGRP_1
00217 #define TIMERB_GROUP_CL123_CL456                TBCLGRP_2
00218 #define TIMERB_GROUP_ALL                                TBCLGRP_3
00219 
00220 
00221 //*****************************************************************************
00222 //
00223 //The following are values can be passed to the
00224 //compareLatchLoadEvent parameter of TimerB_initCompareLatchLoadEvent(); API
00225 //
00226 //*****************************************************************************
00227 #define TIMERB_LATCH_ON_WRITE_TO_TBxCCRn_COMPARE_REGISTER               CLLD_0
00228 #define TIMERB_LATCH_WHEN_COUNTER_COUNTS_TO_0_IN_UP_OR_CONT_MODE        CLLD_1
00229 #define TIMERB_LATCH_WHEN_COUNTER_COUNTS_TO_0_IN_UPDOWN_MODE            CLLD_2
00230 #define TIMERB_LATCH_WHEN_COUNTER_COUNTS_TO_CURRENT_COMPARE_LATCH_VALUE  CLLD_3
00231 
00232 
00233 //*****************************************************************************
00234 //
00235 //The following are values that may be returned by
00236 //TimerB_getInterruptStatus(); API
00237 //
00238 //*****************************************************************************
00239 #define TIMERB_INTERRUPT_NOT_PENDING     0x00
00240 #define TIMERB_INTERRUPT_PENDING         0x01
00241 
00242 //*****************************************************************************
00243 //
00244 //The following are values can be passed to the
00245 //synchronized parameter of TimerB_getSynchronizedCaptureCompareInput(); API
00246 //
00247 //*****************************************************************************
00248 #define TIMERB_READ_SYNCHRONIZED_CAPTURECOMPAREINPUT SCCI
00249 #define TIMERB_READ_CAPTURE_COMPARE_INPUT            CCI
00250 
00251 //*****************************************************************************
00252 //
00253 //Prototypes for the APIs.
00254 //
00255 //*****************************************************************************
00256 extern void TimerB_startCounter ( unsigned int baseAddress,
00257     unsigned int timerMode
00258     );
00259 extern void TimerB_configureContinuousMode ( unsigned int baseAddress,
00260     unsigned int clockSource,
00261     unsigned int clockSourceDivider,
00262     unsigned int timerInterruptEnable_TBIE,
00263     unsigned int timerClear
00264     );
00265 extern void TimerB_configureUpMode (   unsigned int baseAddress,
00266     unsigned int clockSource,
00267     unsigned int clockSourceDivider,
00268     unsigned int timerPeriod,
00269     unsigned int timerInterruptEnable_TBIE,
00270     unsigned int captureCompareInterruptEnable_CCR0_CCIE,
00271     unsigned int timerClear
00272     );
00273 extern void TimerB_configureUpDownMode (
00274     unsigned int baseAddress,
00275     unsigned int clockSource,
00276     unsigned int clockSourceDivider,
00277     unsigned int timerPeriod,
00278     unsigned int timerInterruptEnable_TBIE,
00279     unsigned int captureCompareInterruptEnable_CCR0_CCIE,
00280     unsigned int timerClear
00281     );
00282 extern void TimerB_startContinuousMode ( unsigned int baseAddress,
00283     unsigned int clockSource,
00284     unsigned int clockSourceDivider,
00285     unsigned int timerInterruptEnable_TBIE,
00286     unsigned int timerClear
00287     );
00288 extern void TimerB_startContinousMode ( unsigned int baseAddress,
00289     unsigned int clockSource,
00290     unsigned int clockSourceDivider,
00291     unsigned int timerInterruptEnable_TBIE,
00292     unsigned int timerClear
00293     );
00294 extern void TimerB_startUpMode (   unsigned int baseAddress,
00295     unsigned int clockSource,
00296     unsigned int clockSourceDivider,
00297     unsigned int timerPeriod,
00298     unsigned int timerInterruptEnable_TBIE,
00299     unsigned int captureCompareInterruptEnable_CCR0_CCIE,
00300     unsigned int timerClear
00301     );
00302 extern void TimerB_startUpDownMode (
00303     unsigned int baseAddress,
00304     unsigned int clockSource,
00305     unsigned int clockSourceDivider,
00306     unsigned int timerPeriod,
00307     unsigned int timerInterruptEnable_TBIE,
00308     unsigned int captureCompareInterruptEnable_CCR0_CCIE,
00309     unsigned int timerClear
00310     );
00311 extern void TimerB_initCapture (unsigned int baseAddress,
00312     unsigned int captureRegister,
00313     unsigned int captureMode,
00314     unsigned int captureInputSelect,
00315     unsigned short synchronizeCaptureSource,
00316     unsigned short captureInterruptEnable,
00317     unsigned int captureOutputMode
00318     );
00319 extern void TimerB_initCompare (  unsigned int baseAddress,
00320     unsigned int compareRegister,
00321     unsigned short compareInterruptEnable,
00322     unsigned int compareOutputMode,
00323     unsigned int compareValue
00324     );
00325 extern void TimerB_enableInterrupt (unsigned int baseAddress);
00326 extern void TimerB_disableInterrupt (unsigned int baseAddress);
00327 extern unsigned long TimerB_getInterruptStatus (unsigned int baseAddress);
00328 extern void TimerB_enableCaptureCompareInterrupt (unsigned int baseAddress,
00329     unsigned int captureCompareRegister
00330     );
00331 extern void TimerB_disableCaptureCompareInterrupt (unsigned int baseAddress,
00332     unsigned int captureCompareRegister
00333     );
00334 extern unsigned long TimerB_getCaptureCompareInterruptStatus (unsigned int baseAddress,
00335                  unsigned int captureCompareRegister,
00336                  unsigned int mask
00337                  );
00338 extern void TimerB_clear (unsigned int baseAddress);
00339 unsigned short TimerB_getSynchronizedCaptureCompareInput
00340     (unsigned int baseAddress,
00341     unsigned int captureCompareRegister,
00342     unsigned short synchronized
00343     );
00344 extern unsigned char TimerB_getOutputForOutputModeOutBitValue
00345     (unsigned int baseAddress,
00346     unsigned int captureCompareRegister
00347     );
00348 extern unsigned int TimerB_getCaptureCompareCount
00349     (unsigned int baseAddress,
00350     unsigned int captureCompareRegister
00351     );
00352 extern void TimerB_setOutputForOutputModeOutBitValue
00353     (unsigned int baseAddress,
00354     unsigned int captureCompareRegister,
00355     unsigned char outputModeOutBitValue
00356     );
00357 extern void TimerB_generatePWM (  unsigned int baseAddress,
00358     unsigned int clockSource,
00359     unsigned int clockSourceDivider,
00360     unsigned int timerPeriod,
00361     unsigned int compareRegister,
00362     unsigned int compareOutputMode,
00363     unsigned int dutyCycle
00364     );
00365 extern void TimerB_stop ( unsigned int baseAddress );
00366 extern void privateTimerBProcessClockSourceDivider (unsigned int baseAddress,
00367     unsigned int clockSourceDivider);
00368 extern void TimerB_setCompareValue (  unsigned int baseAddress,
00369     unsigned int compareRegister,
00370     unsigned int compareValue
00371     );
00372 extern void TimerB_clearTimerInterruptFlag (unsigned int baseAddress);
00373 extern void TimerB_clearCaptureCompareInterruptFlag (unsigned int baseAddress,
00374     unsigned int captureCompareRegister
00375     );
00376 extern void TimerB_selectCounterLength (unsigned int  baseAddress,
00377                 unsigned int counterLength
00378                 );
00379 extern void TimerB_selectLatchingGroup(unsigned int  baseAddress,
00380                 unsigned int  groupLatch);
00381 extern void TimerB_initCompareLatchLoadEvent(unsigned int  baseAddress,
00382                 unsigned int  compareRegister,
00383                 unsigned int  compareLatchLoadEvent
00384                 );
00385 
00386 
00387 #endif

Copyright 2012, Texas Instruments Incorporated