|
库函数TIM_UpdateRequestConfig用于设置寄存器,有两个参数:6 F5 {, m. o1 o/ @1 a 对于这个库函数参数的定义,说明一塌糊涂。" X; J) Y& v2 a" r 函数的原型如下: 手册原型:/ o, K. s( N" k* y6 I/ j2 p void TIM_UpdateRequestConfig(TIM_TypeDef* TIMx, uint16_t TIM_UpdateSource) { ~0 ^$ j4 s, t! ~" m9 L" c /* Check the parameters */ assert_param(IS_TIM_ALL_PERIPH(TIMx));) J' O3 E& v ~* a; ]3 p assert_param(IS_TIM_UPDATE_SOURCE(TIM_UpdateSource));# @3 L k8 d" a; U if (TIM_UpdateSource != TIM_UpdateSource_Global) { /* Set the URS Bit */- M |, k# b. p+ p. t+ V, u TIMx->CR1 |= TIM_CR1_URS; } else6 p' [3 L$ D% Z/ k2 s; X+ q { /* Reset the URS Bit */ TIMx->CR1 &= (uint16_t)~((uint16_t)TIM_CR1_URS);2 p- ^3 X/ ?9 n1 N3 V } } 库函数原型: void TIM_UpdateRequestConfig(TIM_TypeDef* TIMx, uint16_t TIM_UpdateSource) {1 O' H5 }- s/ d D /* Check the parameters */ assert_param(IS_TIM_ALL_PERIPH(TIMx)); assert_param(IS_TIM_UPDATE_SOURCE(TIM_UpdateSource)); if (TIM_UpdateSource != TIM_UpdateSource_Global) {* x6 I+ x: v) i8 P% {8 h /* Set the URS Bit */8 k3 c& w5 `# s8 ~" i/ g3 o TIMx->CR1 |= TIM_CR1_URS;+ y; f0 b% r9 a" V, U* }+ e } else { D, h" ^0 T9 ~$ n5 h" L( ?+ } /* Reset the URS Bit */ TIMx->CR1 &= (uint16_t)~((uint16_t)TIM_CR1_URS);$ c% o1 T3 ?4 | }, m$ T0 e2 B5 [: f4 ~ } 各位看官,至于她什么地方一塌糊涂,自己研究。' [8 _9 s6 z( y$ { k7 w 我说一下,如何正确使用这个函数。4 g; X3 l; M& I' k; e 1.手册中的参数两个参数解释,反了(stm32f10x_stdperiph_lib_um.chm):
2.库函数定义处的说明同上一样反了。stm32f10x_time.c 第2109行。/**+ _; E% M# w! E) A1 X, g * @brief Configures the TIMx Update Request Interrupt source. * @param TIMx: where x can be 1 to 17 to select the TIM peripheral. * @param TIM_UpdateSource: specifies the Update source.5 \% A; M9 R9 G * This parameter can be one of the following values:! Y# @ m6 j: ?, J K' a5 B * @arg TIM_UpdateSource_Regular: Source of update is the counter overflow/underflow or the setting of UG bit, or an update generation through the slave mode controller. * @arg TIM_UpdateSource_Global: Source of update is counter overflow/underflow.3 G" B- _8 t4 R, U' q7 M * @retval None7 P, x8 J& D# Y8 h! G+ s7 P */3.参数宏定义的说明正确;stm32f10x_time.h 第0806行。#define TIM_UpdateSource_Global ((uint16_t)0x0000) /*!< Source of update is the counter overflow/underflow or the setting of UG bit, or an update generation 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,不正确。