MSP430F5529 DriverLib 库函数学习笔记(七)定时器B
目錄
- 硬知識(shí)
- Timer_B特點(diǎn)及結(jié)構(gòu)
- Timer_B寄存器
- 定時(shí)器B API
- 處理計(jì)時(shí)器配置和控制的函數(shù)
- 參數(shù)
- 處理計(jì)時(shí)器輸出的函數(shù)
- 參數(shù)
- 管理定時(shí)器B中斷的函數(shù)
- 參數(shù)
平臺(tái):Code Composer Studio 10.3.1
MSP430F5529 LaunchPad? Development Kit
(MSP?EXP430F5529LP)
硬知識(shí)
???????16位定時(shí)器B(Timer_B)和Timer_A一樣,是MSP430單片機(jī)的重要資源。Timer_B往往比Timer_A功能更強(qiáng)大一些,MSP430F5529單片機(jī)的Timer_B定時(shí)器具有7個(gè)捕獲/比較寄存器。
Timer_B特點(diǎn)及結(jié)構(gòu)
???????Timer_B定時(shí)器具有以下特點(diǎn):
? 具有4種工作模式和4種可選計(jì)數(shù)長(zhǎng)度的異步16位定時(shí)/計(jì)數(shù)器;
? 參考時(shí)鐘源可配置;
? 高達(dá)7個(gè)可配置的捕獲/比較寄存器;
? 具有PWM輸出能力;
? 具有同步加載能力的雙緩沖區(qū)比較鎖存;
? 具有可對(duì)Timer_B中斷快速響應(yīng)的中斷向量寄存器。
Timer_B和Timer_A的不同之處列舉如下:
① Timer_B計(jì)數(shù)長(zhǎng)度為8位、10位、12位和16位可編程,而Timer_A的計(jì)數(shù)長(zhǎng)度固定為16位。
② Timer_B沒有實(shí)現(xiàn)Timer_A中的SCCI寄存器位的功能。
③ Timer_B在比較模式下的捕獲/比較寄存器功能與Timer_A的不同,增加了比較鎖存器。
④ 有些型號(hào)芯片中的Timer_B輸出實(shí)現(xiàn)了高阻抗輸出。
⑤ 比較模式的原理有所不同。在Timer_A中,CCRx寄存器中保存與TAR相比較的數(shù)據(jù),而在Timer_B中,CCRx寄存器中保存的是要比較的數(shù)據(jù),但并不直接與定時(shí)計(jì)數(shù)器TBR相比較,而是將CCRx送到與之相對(duì)應(yīng)的鎖存器之后,由鎖存器與定時(shí)計(jì)數(shù)器TBR相比較。從捕獲/比較寄存器向比較鎖存器傳輸數(shù)據(jù)的時(shí)機(jī)也是可以編程的,可以是在寫入捕獲/比較寄存器后立即傳輸,也可以由一個(gè)定時(shí)事件來觸發(fā)。
⑥ Timer_B支持多種、同步的定時(shí)功能,多重的捕獲/比較功能和多重的波形輸出功能。而且通過對(duì)比較數(shù)據(jù)的兩級(jí)緩沖,可以實(shí)現(xiàn)多個(gè)PWM信號(hào)周期的同步更新。
Timer_B寄存器
Timer_B寄存器列表如表所示,基址為03C0h。
定時(shí)器B API
TIMER_B API被分成三組函數(shù):
處理計(jì)時(shí)器配置和控制的函數(shù)、
處理計(jì)時(shí)器輸出的函數(shù)
處理中斷處理的函數(shù)
處理計(jì)時(shí)器配置和控制的函數(shù)
Timer_B_startCounter(uint16_t baseAddress, uint16_t timerMode) //開啟定時(shí)器 Timer_B_initUpMode(uint16_t baseAddress, Timer_B_initUpModeParam ?param) //配置Timer_B為增計(jì)數(shù)模式 Timer_B_initUpDownMode(uint16_t baseAddress, Timer_B_initUpDownModeParam ?param) //配置Timer_B為增/減計(jì)數(shù)模式 Timer_B_initContinuousMode(uint16_t baseAddress, Timer_B_initContinuousModeParam ?param) //配置Timer_B為連續(xù)計(jì)數(shù)模式 Timer_B_initCaptureMode(uint16_t baseAddress, Timer_B_initCaptureModeParam ?param) //初始化捕獲模式 Timer_B_initCompareMode(uint16_t baseAddress, Timer_B_initCompareModeParam ?param) //初始化比較模式 Timer_B_clear(uint16_t baseAddress) //重置/清除計(jì)時(shí)器、時(shí)鐘分頻器,計(jì)數(shù)方向,計(jì)數(shù)。 Timer_B_stop() //停止Timer_B Timer_B_initCompareLatchLoadEvent(uint16_t baseAddress, uint16_t compareRegister, uint16_t compareLatchLoadEvent) //Selects Compare Latch Load Event. Timer_B_selectLatchingGroup(uint16_t baseAddress, uint16_t groupLatch) //Selects Timer_B Latching Group. Timer_B_selectCounterLength(uint16_t baseAddress, uint16_t counterLength) //選擇Timer_B計(jì)數(shù)器長(zhǎng)度(位數(shù))參數(shù)
baseAddress
TIMER_B0_BASEtimerMode
TIMER_B_STOP_MODE TIMER_B_UP_MODE TIMER_B_CONTINUOUS_MODE //[Default] TIMER_B_UPDOWN_MODETimer_B_initUpModeParam
//***************************************************************************** // //! \brief Used in the Timer_B_initUpMode() function as the param parameter. // //***************************************************************************** typedef struct Timer_B_initUpModeParam {//! Selects the clock source//! \n Valid values are://! - \b TIMER_B_CLOCKSOURCE_EXTERNAL_TXCLK [Default]//! - \b TIMER_B_CLOCKSOURCE_ACLK//! - \b TIMER_B_CLOCKSOURCE_SMCLK//! - \b TIMER_B_CLOCKSOURCE_INVERTED_EXTERNAL_TXCLKuint16_t clockSource;//! Is the divider for Clock source.//! \n Valid values are://! - \b TIMER_B_CLOCKSOURCE_DIVIDER_1 [Default]//! - \b TIMER_B_CLOCKSOURCE_DIVIDER_2//! - \b TIMER_B_CLOCKSOURCE_DIVIDER_3//! - \b TIMER_B_CLOCKSOURCE_DIVIDER_4//! - \b TIMER_B_CLOCKSOURCE_DIVIDER_5//! - \b TIMER_B_CLOCKSOURCE_DIVIDER_6//! - \b TIMER_B_CLOCKSOURCE_DIVIDER_7//! - \b TIMER_B_CLOCKSOURCE_DIVIDER_8//! - \b TIMER_B_CLOCKSOURCE_DIVIDER_10//! - \b TIMER_B_CLOCKSOURCE_DIVIDER_12//! - \b TIMER_B_CLOCKSOURCE_DIVIDER_14//! - \b TIMER_B_CLOCKSOURCE_DIVIDER_16//! - \b TIMER_B_CLOCKSOURCE_DIVIDER_20//! - \b TIMER_B_CLOCKSOURCE_DIVIDER_24//! - \b TIMER_B_CLOCKSOURCE_DIVIDER_28//! - \b TIMER_B_CLOCKSOURCE_DIVIDER_32//! - \b TIMER_B_CLOCKSOURCE_DIVIDER_40//! - \b TIMER_B_CLOCKSOURCE_DIVIDER_48//! - \b TIMER_B_CLOCKSOURCE_DIVIDER_56//! - \b TIMER_B_CLOCKSOURCE_DIVIDER_64uint16_t clockSourceDivider;//! Is the specified Timer_B period. This is the value that gets written//! into the CCR0. Limited to 16 bits[uint16_t]uint16_t timerPeriod;//! Is to enable or disable Timer_B interrupt//! \n Valid values are://! - \b TIMER_B_TBIE_INTERRUPT_ENABLE//! - \b TIMER_B_TBIE_INTERRUPT_DISABLE [Default]uint16_t timerInterruptEnable_TBIE;//! Is to enable or disable Timer_B CCR0 capture compare interrupt.//! \n Valid values are://! - \b TIMER_B_CCIE_CCR0_INTERRUPT_ENABLE//! - \b TIMER_B_CCIE_CCR0_INTERRUPT_DISABLE [Default]uint16_t captureCompareInterruptEnable_CCR0_CCIE;//! Decides if Timer_B clock divider, count direction, count need to be//! reset.//! \n Valid values are://! - \b TIMER_B_DO_CLEAR//! - \b TIMER_B_SKIP_CLEAR [Default]uint16_t timerClear;//! Whether to start the timer immediatelybool startTimer; } Timer_B_initUpModeParam;Timer_B_initUpDownModeParam
//***************************************************************************** // //! \brief Used in the Timer_B_initUpDownMode() function as the param //! parameter. // //***************************************************************************** typedef struct Timer_B_initUpDownModeParam {//! Selects the clock source//! \n Valid values are://! - \b TIMER_B_CLOCKSOURCE_EXTERNAL_TXCLK [Default]//! - \b TIMER_B_CLOCKSOURCE_ACLK//! - \b TIMER_B_CLOCKSOURCE_SMCLK//! - \b TIMER_B_CLOCKSOURCE_INVERTED_EXTERNAL_TXCLKuint16_t clockSource;//! Is the divider for Clock source.//! \n Valid values are://! - \b TIMER_B_CLOCKSOURCE_DIVIDER_1 [Default]//! - \b TIMER_B_CLOCKSOURCE_DIVIDER_2//! - \b TIMER_B_CLOCKSOURCE_DIVIDER_3//! - \b TIMER_B_CLOCKSOURCE_DIVIDER_4//! - \b TIMER_B_CLOCKSOURCE_DIVIDER_5//! - \b TIMER_B_CLOCKSOURCE_DIVIDER_6//! - \b TIMER_B_CLOCKSOURCE_DIVIDER_7//! - \b TIMER_B_CLOCKSOURCE_DIVIDER_8//! - \b TIMER_B_CLOCKSOURCE_DIVIDER_10//! - \b TIMER_B_CLOCKSOURCE_DIVIDER_12//! - \b TIMER_B_CLOCKSOURCE_DIVIDER_14//! - \b TIMER_B_CLOCKSOURCE_DIVIDER_16//! - \b TIMER_B_CLOCKSOURCE_DIVIDER_20//! - \b TIMER_B_CLOCKSOURCE_DIVIDER_24//! - \b TIMER_B_CLOCKSOURCE_DIVIDER_28//! - \b TIMER_B_CLOCKSOURCE_DIVIDER_32//! - \b TIMER_B_CLOCKSOURCE_DIVIDER_40//! - \b TIMER_B_CLOCKSOURCE_DIVIDER_48//! - \b TIMER_B_CLOCKSOURCE_DIVIDER_56//! - \b TIMER_B_CLOCKSOURCE_DIVIDER_64uint16_t clockSourceDivider;//! Is the specified Timer_B perioduint16_t timerPeriod;//! Is to enable or disable Timer_B interrupt//! \n Valid values are://! - \b TIMER_B_TBIE_INTERRUPT_ENABLE//! - \b TIMER_B_TBIE_INTERRUPT_DISABLE [Default]uint16_t timerInterruptEnable_TBIE;//! Is to enable or disable Timer_B CCR0 capture compare interrupt.//! \n Valid values are://! - \b TIMER_B_CCIE_CCR0_INTERRUPT_ENABLE//! - \b TIMER_B_CCIE_CCR0_INTERRUPT_DISABLE [Default]uint16_t captureCompareInterruptEnable_CCR0_CCIE;//! Decides if Timer_B clock divider, count direction, count need to be//! reset.//! \n Valid values are://! - \b TIMER_B_DO_CLEAR//! - \b TIMER_B_SKIP_CLEAR [Default]uint16_t timerClear;//! Whether to start the timer immediatelybool startTimer; } Timer_B_initUpDownModeParam;Timer_B_initContinuousModeParam
//***************************************************************************** // //! \brief Used in the Timer_B_initContinuousMode() function as the param //! parameter. // //***************************************************************************** typedef struct Timer_B_initContinuousModeParam {//! Selects the clock source//! \n Valid values are://! - \b TIMER_B_CLOCKSOURCE_EXTERNAL_TXCLK [Default]//! - \b TIMER_B_CLOCKSOURCE_ACLK//! - \b TIMER_B_CLOCKSOURCE_SMCLK//! - \b TIMER_B_CLOCKSOURCE_INVERTED_EXTERNAL_TXCLKuint16_t clockSource;//! Is the divider for Clock source.//! \n Valid values are://! - \b TIMER_B_CLOCKSOURCE_DIVIDER_1 [Default]//! - \b TIMER_B_CLOCKSOURCE_DIVIDER_2//! - \b TIMER_B_CLOCKSOURCE_DIVIDER_3//! - \b TIMER_B_CLOCKSOURCE_DIVIDER_4//! - \b TIMER_B_CLOCKSOURCE_DIVIDER_5//! - \b TIMER_B_CLOCKSOURCE_DIVIDER_6//! - \b TIMER_B_CLOCKSOURCE_DIVIDER_7//! - \b TIMER_B_CLOCKSOURCE_DIVIDER_8//! - \b TIMER_B_CLOCKSOURCE_DIVIDER_10//! - \b TIMER_B_CLOCKSOURCE_DIVIDER_12//! - \b TIMER_B_CLOCKSOURCE_DIVIDER_14//! - \b TIMER_B_CLOCKSOURCE_DIVIDER_16//! - \b TIMER_B_CLOCKSOURCE_DIVIDER_20//! - \b TIMER_B_CLOCKSOURCE_DIVIDER_24//! - \b TIMER_B_CLOCKSOURCE_DIVIDER_28//! - \b TIMER_B_CLOCKSOURCE_DIVIDER_32//! - \b TIMER_B_CLOCKSOURCE_DIVIDER_40//! - \b TIMER_B_CLOCKSOURCE_DIVIDER_48//! - \b TIMER_B_CLOCKSOURCE_DIVIDER_56//! - \b TIMER_B_CLOCKSOURCE_DIVIDER_64uint16_t clockSourceDivider;//! Is to enable or disable Timer_B interrupt//! \n Valid values are://! - \b TIMER_B_TBIE_INTERRUPT_ENABLE//! - \b TIMER_B_TBIE_INTERRUPT_DISABLE [Default]uint16_t timerInterruptEnable_TBIE;//! Decides if Timer_B clock divider, count direction, count need to be//! reset.//! \n Valid values are://! - \b TIMER_B_DO_CLEAR//! - \b TIMER_B_SKIP_CLEAR [Default]uint16_t timerClear;//! Whether to start the timer immediatelybool startTimer; } Timer_B_initContinuousModeParam;Timer_B_initCaptureModeParam
//***************************************************************************** // //! \brief Used in the Timer_B_initCaptureMode() function as the param //! parameter. // //***************************************************************************** typedef struct Timer_B_initCaptureModeParam {//! Selects the capture register being used. Refer to datasheet to ensure//! the device has the capture register being used.//! \n Valid values are://! - \b TIMER_B_CAPTURECOMPARE_REGISTER_0//! - \b TIMER_B_CAPTURECOMPARE_REGISTER_1//! - \b TIMER_B_CAPTURECOMPARE_REGISTER_2//! - \b TIMER_B_CAPTURECOMPARE_REGISTER_3//! - \b TIMER_B_CAPTURECOMPARE_REGISTER_4//! - \b TIMER_B_CAPTURECOMPARE_REGISTER_5//! - \b TIMER_B_CAPTURECOMPARE_REGISTER_6uint16_t captureRegister;//! Is the capture mode selected.//! \n Valid values are://! - \b TIMER_B_CAPTUREMODE_NO_CAPTURE [Default]//! - \b TIMER_B_CAPTUREMODE_RISING_EDGE//! - \b TIMER_B_CAPTUREMODE_FALLING_EDGE//! - \b TIMER_B_CAPTUREMODE_RISING_AND_FALLING_EDGEuint16_t captureMode;//! Decides the Input Select//! \n Valid values are://! - \b TIMER_B_CAPTURE_INPUTSELECT_CCIxA [Default]//! - \b TIMER_B_CAPTURE_INPUTSELECT_CCIxB//! - \b TIMER_B_CAPTURE_INPUTSELECT_GND//! - \b TIMER_B_CAPTURE_INPUTSELECT_Vccuint16_t captureInputSelect;//! Decides if capture source should be synchronized with Timer_B clock//! \n Valid values are://! - \b TIMER_B_CAPTURE_ASYNCHRONOUS [Default]//! - \b TIMER_B_CAPTURE_SYNCHRONOUSuint16_t synchronizeCaptureSource;//! Is to enable or disable Timer_B capture compare interrupt.//! \n Valid values are://! - \b TIMER_B_CAPTURECOMPARE_INTERRUPT_DISABLE [Default]//! - \b TIMER_B_CAPTURECOMPARE_INTERRUPT_ENABLEuint16_t captureInterruptEnable;//! Specifies the output mode.//! \n Valid values are://! - \b TIMER_B_OUTPUTMODE_OUTBITVALUE [Default]//! - \b TIMER_B_OUTPUTMODE_SET//! - \b TIMER_B_OUTPUTMODE_TOGGLE_RESET//! - \b TIMER_B_OUTPUTMODE_SET_RESET//! - \b TIMER_B_OUTPUTMODE_TOGGLE//! - \b TIMER_B_OUTPUTMODE_RESET//! - \b TIMER_B_OUTPUTMODE_TOGGLE_SET//! - \b TIMER_B_OUTPUTMODE_RESET_SETuint16_t captureOutputMode; } Timer_B_initCaptureModeParam;Timer_B_initCompareModeParam
//***************************************************************************** // //! \brief Used in the Timer_B_initCompareMode() function as the param //! parameter. // //***************************************************************************** typedef struct Timer_B_initCompareModeParam {//! Selects the compare register being used. Refer to datasheet to ensure//! the device has the compare register being used.//! \n Valid values are://! - \b TIMER_B_CAPTURECOMPARE_REGISTER_0//! - \b TIMER_B_CAPTURECOMPARE_REGISTER_1//! - \b TIMER_B_CAPTURECOMPARE_REGISTER_2//! - \b TIMER_B_CAPTURECOMPARE_REGISTER_3//! - \b TIMER_B_CAPTURECOMPARE_REGISTER_4//! - \b TIMER_B_CAPTURECOMPARE_REGISTER_5//! - \b TIMER_B_CAPTURECOMPARE_REGISTER_6uint16_t compareRegister;//! Is to enable or disable Timer_B capture compare interrupt.//! \n Valid values are://! - \b TIMER_B_CAPTURECOMPARE_INTERRUPT_DISABLE [Default]//! - \b TIMER_B_CAPTURECOMPARE_INTERRUPT_ENABLEuint16_t compareInterruptEnable;//! Specifies the output mode.//! \n Valid values are://! - \b TIMER_B_OUTPUTMODE_OUTBITVALUE [Default]//! - \b TIMER_B_OUTPUTMODE_SET//! - \b TIMER_B_OUTPUTMODE_TOGGLE_RESET//! - \b TIMER_B_OUTPUTMODE_SET_RESET//! - \b TIMER_B_OUTPUTMODE_TOGGLE//! - \b TIMER_B_OUTPUTMODE_RESET//! - \b TIMER_B_OUTPUTMODE_TOGGLE_SET//! - \b TIMER_B_OUTPUTMODE_RESET_SETuint16_t compareOutputMode;//! Is the count to be compared with in compare modeuint16_t compareValue; } Timer_B_initCompareModeParam;compareRegister
/* selects the compare register being used. Refer to datasheet to ensure the device has the compare register being used. Valid values are: */ TIMER_B_CAPTURECOMPARE_REGISTER_0 TIMER_B_CAPTURECOMPARE_REGISTER_1 TIMER_B_CAPTURECOMPARE_REGISTER_2 TIMER_B_CAPTURECOMPARE_REGISTER_3 TIMER_B_CAPTURECOMPARE_REGISTER_4 TIMER_B_CAPTURECOMPARE_REGISTER_5 TIMER_B_CAPTURECOMPARE_REGISTER_6compareLatchLoadEvent
/* selects the latch load event Valid values are: */ TIMER_B_LATCH_ON_WRITE_TO_TBxCCRn_COMPARE_REGISTER //[Default] TIMER_B_LATCH_WHEN_COUNTER_COUNTS_TO_0_IN_UP_OR_CONT_MODE TIMER_B_LATCH_WHEN_COUNTER_COUNTS_TO_0_IN_UPDOWN_MODE TIMER_B_LATCH_WHEN_COUNTER_COUNTS_TO_CURRENT_COMPARE_LATCH_VALUEgroupLatch
//selects the latching group. Valid values are: TIMER_B_GROUP_NONE //[Default] TIMER_B_GROUP_CL12_CL23_CL56 TIMER_B_GROUP_CL123_CL456 TIMER_B_GROUP_ALLcounterLength
//selects the value of counter length. Valid values are: TIMER_B_COUNTER_16BIT //[Default] TIMER_B_COUNTER_12BIT TIMER_B_COUNTER_10BIT TIMER_B_COUNTER_8BIT處理計(jì)時(shí)器輸出的函數(shù)
Timer_B_getSynchronizedCaptureCompareInput(uint16_t baseAddress, uint16_t captureCompareRegister, uint16_t synchronized) //獲取同步的capturecompare輸入 Timer_B_getOutputForOutputModeOutBitValue(uint16_t baseAddress, uint16_t captureCompareRegister) //為輸出模式獲取輸出位 Timer_B_setOutputForOutputModeOutBitValue(uint16_t baseAddress, uint16_t captureCompareRegister, uint16_t outputModeOutBitValue) //為輸出模式設(shè)置輸出位 Timer_B_outputPWM(uint16_t baseAddress, Timer_B_outputPWMParam ?param) //通過增計(jì)數(shù)模式產(chǎn)生PWM信號(hào) Timer_B_getCaptureCompareCount(uint16_t baseAddress, uint16_t captureCompareRegister) //獲取當(dāng)前capturecompare計(jì)數(shù) Timer_B_setCompareValue(uint16_t baseAddress, uint16_t compareRegister, uint16_t compareValue) //設(shè)置捕獲比較寄存器的值 Timer_B_getCounterValue(uint16_t baseAddress) //讀取當(dāng)前計(jì)時(shí)器計(jì)數(shù)值參數(shù)
baseAddress
TIMER_B0_BASEcaptureCompareRegister
/* selects the capture compare register being used. Refer to datasheet to ensure the device has the capture compare register being used. Valid values are: */ TIMER_B_CAPTURECOMPARE_REGISTER_0 TIMER_B_CAPTURECOMPARE_REGISTER_1 TIMER_B_CAPTURECOMPARE_REGISTER_2 TIMER_B_CAPTURECOMPARE_REGISTER_3 TIMER_B_CAPTURECOMPARE_REGISTER_4 TIMER_B_CAPTURECOMPARE_REGISTER_5 TIMER_B_CAPTURECOMPARE_REGISTER_6synchronized
//selects the type of capture compare input Valid values are: TIMER_B_READ_SYNCHRONIZED_CAPTURECOMPAREINPUT TIMER_B_READ_CAPTURE_COMPARE_INPUToutputModeOutBitValue
//the value to be set for out bit Valid values are: TIMER_B_OUTPUTMODE_OUTBITVALUE_HIGH TIMER_B_OUTPUTMODE_OUTBITVALUE_LOWTimer_B_outputPWMParam
//***************************************************************************** // //! \brief Used in the Timer_B_outputPWM() function as the param parameter. // //***************************************************************************** typedef struct Timer_B_outputPWMParam {//! Selects the clock source//! \n Valid values are://! - \b TIMER_B_CLOCKSOURCE_EXTERNAL_TXCLK [Default]//! - \b TIMER_B_CLOCKSOURCE_ACLK//! - \b TIMER_B_CLOCKSOURCE_SMCLK//! - \b TIMER_B_CLOCKSOURCE_INVERTED_EXTERNAL_TXCLKuint16_t clockSource;//! Is the divider for Clock source.//! \n Valid values are://! - \b TIMER_B_CLOCKSOURCE_DIVIDER_1 [Default]//! - \b TIMER_B_CLOCKSOURCE_DIVIDER_2//! - \b TIMER_B_CLOCKSOURCE_DIVIDER_3//! - \b TIMER_B_CLOCKSOURCE_DIVIDER_4//! - \b TIMER_B_CLOCKSOURCE_DIVIDER_5//! - \b TIMER_B_CLOCKSOURCE_DIVIDER_6//! - \b TIMER_B_CLOCKSOURCE_DIVIDER_7//! - \b TIMER_B_CLOCKSOURCE_DIVIDER_8//! - \b TIMER_B_CLOCKSOURCE_DIVIDER_10//! - \b TIMER_B_CLOCKSOURCE_DIVIDER_12//! - \b TIMER_B_CLOCKSOURCE_DIVIDER_14//! - \b TIMER_B_CLOCKSOURCE_DIVIDER_16//! - \b TIMER_B_CLOCKSOURCE_DIVIDER_20//! - \b TIMER_B_CLOCKSOURCE_DIVIDER_24//! - \b TIMER_B_CLOCKSOURCE_DIVIDER_28//! - \b TIMER_B_CLOCKSOURCE_DIVIDER_32//! - \b TIMER_B_CLOCKSOURCE_DIVIDER_40//! - \b TIMER_B_CLOCKSOURCE_DIVIDER_48//! - \b TIMER_B_CLOCKSOURCE_DIVIDER_56//! - \b TIMER_B_CLOCKSOURCE_DIVIDER_64uint16_t clockSourceDivider;//! Selects the desired Timer_B perioduint16_t timerPeriod;//! Selects the compare register being used. Refer to datasheet to ensure//! the device has the compare register being used.//! \n Valid values are://! - \b TIMER_B_CAPTURECOMPARE_REGISTER_0//! - \b TIMER_B_CAPTURECOMPARE_REGISTER_1//! - \b TIMER_B_CAPTURECOMPARE_REGISTER_2//! - \b TIMER_B_CAPTURECOMPARE_REGISTER_3//! - \b TIMER_B_CAPTURECOMPARE_REGISTER_4//! - \b TIMER_B_CAPTURECOMPARE_REGISTER_5//! - \b TIMER_B_CAPTURECOMPARE_REGISTER_6uint16_t compareRegister;//! Specifies the output mode.//! \n Valid values are://! - \b TIMER_B_OUTPUTMODE_OUTBITVALUE [Default]//! - \b TIMER_B_OUTPUTMODE_SET//! - \b TIMER_B_OUTPUTMODE_TOGGLE_RESET//! - \b TIMER_B_OUTPUTMODE_SET_RESET//! - \b TIMER_B_OUTPUTMODE_TOGGLE//! - \b TIMER_B_OUTPUTMODE_RESET//! - \b TIMER_B_OUTPUTMODE_TOGGLE_SET//! - \b TIMER_B_OUTPUTMODE_RESET_SETuint16_t compareOutputMode;//! Specifies the dutycycle for the generated waveformuint16_t dutyCycle; } Timer_B_outputPWMParam;compareRegister
//selects the compare register being used. Refer to datasheet to ensure the device has the compare register being used. Valid values are: TIMER_B_CAPTURECOMPARE_REGISTER_0 TIMER_B_CAPTURECOMPARE_REGISTER_1 TIMER_B_CAPTURECOMPARE_REGISTER_2 TIMER_B_CAPTURECOMPARE_REGISTER_3 TIMER_B_CAPTURECOMPARE_REGISTER_4 TIMER_B_CAPTURECOMPARE_REGISTER_5 TIMER_B_CAPTURECOMPARE_REGISTER_6compareValue
比較模式下需要比較的計(jì)數(shù)值
管理定時(shí)器B中斷的函數(shù)
Timer_B_enableInterrupt(uint16_t baseAddress) //使能定時(shí)器B中斷 Timer_B_disableInterrupt(uint16_t baseAddress) //禁用定時(shí)器B中斷 Timer_B_getInterruptStatus(uint16_t baseAddress) //獲取定時(shí)器B中斷狀態(tài) Timer_B_enableCaptureCompareInterrupt(uint16_t baseAddress, uint16_t captureCompareRegister) //啟用捕獲比較中斷 Timer_B_disableCaptureCompareInterrupt(uint16_t baseAddress, uint16_t captureCompareRegister) //禁用捕獲比較中斷 Timer_B_getCaptureCompareInterruptStatus(uint16_t baseAddress, uint16_t captureCompareRegister, uint16_t mask) //清除捕獲比較中斷標(biāo)志 Timer_B_clearCaptureCompareInterrupt(uint16_t baseAddress, uint16_t captureCompareRegister) //清除捕獲比較中斷標(biāo)志 Timer_B_clearTimerInterrupt(uint16_t baseAddress) //清除Timer_ B TBIFG中斷標(biāo)志。參數(shù)
baseAddress
TIMER_B0_BASEcaptureCompareRegister
/* selects the capture compare register being used. Refer to datasheet to ensure the device has the capture compare register being used. Valid values are: */ TIMER_B_CAPTURECOMPARE_REGISTER_0 TIMER_B_CAPTURECOMPARE_REGISTER_1 TIMER_B_CAPTURECOMPARE_REGISTER_2 TIMER_B_CAPTURECOMPARE_REGISTER_3 TIMER_B_CAPTURECOMPARE_REGISTER_4 TIMER_B_CAPTURECOMPARE_REGISTER_5 TIMER_B_CAPTURECOMPARE_REGISTER_6mask
/* is the mask for the interrupt status Mask value is the logical OR of any of the following: */ TIMER_B_CAPTURE_OVERFLOW TIMER_B_CAPTURECOMPARE_INTERRUPT_FLAG總結(jié)
以上是生活随笔為你收集整理的MSP430F5529 DriverLib 库函数学习笔记(七)定时器B的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Android在全球的市场份额跃居全球第
- 下一篇: shell 杂记一(笨鸟)