
库函数TIM_UpdateRequestConfig用于设置寄存器,有两个参数: 对于这个库函数参数的定义,说明一塌糊涂。 函数的原型如下: 手册原型: void TIM_UpdateRequestConfig(TIM_TypeDef* TIMx, uint16_t TIM_UpdateSource) j- R7 `$ o. s$ ] {; f' q6 P, [ H2 k( k9 `- Y /* Check the parameters */2 m8 S5 V/ A( S9 q7 G; w assert_param(IS_TIM_ALL_PERIPH(TIMx)); assert_param(IS_TIM_UPDATE_SOURCE(TIM_UpdateSource)); if (TIM_UpdateSource != TIM_UpdateSource_Global)" t, u' p* H# j: N1 u {: H& o, Q) v& _: d /* Set the URS Bit */- u1 l: d$ \4 T( n* I TIMx->CR1 |= TIM_CR1_URS; }$ _* h4 H4 b" c3 |# N! z else2 S) s3 k* f2 }* ^; V% X# D { I, w F( c" p /* Reset the URS Bit */ TIMx->CR1 &= (uint16_t)~((uint16_t)TIM_CR1_URS); }, R: R( @2 L. M! L/ o }- Q& x( B, q( \ 库函数原型: void TIM_UpdateRequestConfig(TIM_TypeDef* TIMx, uint16_t TIM_UpdateSource)7 p' w% y+ \4 p+ _. ?. H4 @) ^ { /* Check the parameters */ assert_param(IS_TIM_ALL_PERIPH(TIMx)); assert_param(IS_TIM_UPDATE_SOURCE(TIM_UpdateSource));8 R: d1 {0 o- b% W0 @ if (TIM_UpdateSource != TIM_UpdateSource_Global) {8 u3 {7 @, Q; n4 ?$ V5 I( w /* Set the URS Bit */ TIMx->CR1 |= TIM_CR1_URS; }5 |; W$ N- ?/ m3 k else {8 `$ k" w1 z# y, {1 E1 ^3 E /* Reset the URS Bit */. Y6 B. ^3 x; Z- l% R( m2 c* h TIMx->CR1 &= (uint16_t)~((uint16_t)TIM_CR1_URS); }1 H& Q7 @0 d% |9 S8 }5 z) l) o' @ }% {0 `4 x9 H( H2 D 各位看官,至于她什么地方一塌糊涂,自己研究。& q' O E) Q$ j9 r. o$ W2 P 我说一下,如何正确使用这个函数。 1.手册中的参数两个参数解释,反了(stm32f10x_stdperiph_lib_um.chm):
2.库函数定义处的说明同上一样反了。stm32f10x_time.c 第2109行。/** * @brief Configures the TIMx Update Request Interrupt source.& l) J8 U& }( G * @param TIMx: where x can be 1 to 17 to select the TIM peripheral.0 Q2 R$ Z2 v# E6 h * @param TIM_UpdateSource: specifies the Update source.: v8 Y1 \$ }( c% d1 c * This parameter can be one of the following values:3 ^& B7 h. i/ @: @8 c& N& O' m5 s * @arg TIM_UpdateSource_Regular: Source of update is the counter overflow/underflow or the setting of UG bit, or an update generation, |4 R# g# w1 A through the slave mode controller.' S5 y2 a2 g. G v' {7 {' J * @arg TIM_UpdateSource_Global: Source of update is counter overflow/underflow.; K( e, j; U* @* S * @retval None */3.参数宏定义的说明正确;stm32f10x_time.h 第0806行。#define TIM_UpdateSource_Global ((uint16_t)0x0000) /*!< Source of update is the counter overflow/underflow/ J8 m6 u( X# |$ e2 X- C$ ?1 @# M or the setting of UG bit, or an update generation& q2 Y5 ^' D. k3 O8 J& a through the slave mode controller. */ #define TIM_UpdateSource_Regular ((uint16_t)0x0001) /*!< Source of update is counter overflow/underflow. */ |
RE:STM32 定时器库函数,TIM_UpdateRequestConfig,不正确。
RE:STM32 定时器库函数,TIM_UpdateRequestConfig,不正确。
RE:STM32 定时器库函数,TIM_UpdateRequestConfig,不正确。
RE:STM32 定时器库函数,TIM_UpdateRequestConfig,不正确。