|
库函数TIM_UpdateRequestConfig用于设置寄存器,有两个参数: 对于这个库函数参数的定义,说明一塌糊涂。' o8 N- R5 l" K0 i 函数的原型如下: 手册原型: void TIM_UpdateRequestConfig(TIM_TypeDef* TIMx, uint16_t TIM_UpdateSource) {6 k3 I/ ~. ~& e: }: }1 @9 q/ [ /* Check the parameters */, s, a$ o3 ]1 r1 ~3 p) h. g" r assert_param(IS_TIM_ALL_PERIPH(TIMx));$ p6 j' h* a. [. V4 l assert_param(IS_TIM_UPDATE_SOURCE(TIM_UpdateSource));4 J9 b4 {5 Q8 j+ N4 r& M3 U if (TIM_UpdateSource != TIM_UpdateSource_Global) {- h7 c( Z) W( O! p. V /* Set the URS Bit */# M1 L, L, v3 t% w TIMx->CR1 |= TIM_CR1_URS;% j/ f0 T8 B4 E$ _ } else { /* Reset the URS Bit */1 o( a, @( D4 W, R TIMx->CR1 &= (uint16_t)~((uint16_t)TIM_CR1_URS);+ W. G6 o4 m' z+ B2 N: J9 b } }- K/ Q+ U" C) L, P 库函数原型: void TIM_UpdateRequestConfig(TIM_TypeDef* TIMx, uint16_t TIM_UpdateSource) { /* Check the parameters */4 o6 v/ _4 F+ i0 k7 M* s7 C assert_param(IS_TIM_ALL_PERIPH(TIMx)); assert_param(IS_TIM_UPDATE_SOURCE(TIM_UpdateSource)); if (TIM_UpdateSource != TIM_UpdateSource_Global)4 [9 X+ ~" }1 W1 D4 q" P6 g {7 s2 T: H+ h( M: f- @ /* Set the URS Bit */ TIMx->CR1 |= TIM_CR1_URS; } else { /* Reset the URS Bit */ TIMx->CR1 &= (uint16_t)~((uint16_t)TIM_CR1_URS);8 |; z' ]) @: b9 u }# O' C0 ]; G0 ] }" b: g- g$ p% N7 x/ H6 F4 k; X 各位看官,至于她什么地方一塌糊涂,自己研究。* e$ K* l% Q3 _ 我说一下,如何正确使用这个函数。( a! D+ c+ E( _# x 1.手册中的参数两个参数解释,反了(stm32f10x_stdperiph_lib_um.chm):) ?8 v/ U1 k2 j5 H6 ]1 U; n
2.库函数定义处的说明同上一样反了。stm32f10x_time.c 第2109行。/**5 a6 b/ F% A: G9 j+ | * @brief Configures the TIMx Update Request Interrupt source.) b6 J; h; @1 |( X% X" U * @param TIMx: where x can be 1 to 17 to select the TIM peripheral.1 i% A9 p! q* W6 c( T: i* ?+ a! s * @param TIM_UpdateSource: specifies the Update source.* D/ [4 K& u- p+ D8 _* x * This parameter can be one of the following values:! L1 w/ |* U0 { * @arg TIM_UpdateSource_Regular: Source of update is the counter overflow/underflow: D) z, e1 |6 R or the setting of UG bit, or an update generation# p2 y$ U0 Y K4 _& h, c through the slave mode controller.4 [3 E7 P4 Y- t * @arg TIM_UpdateSource_Global: Source of update is counter overflow/underflow.( ~0 z0 S6 e4 r H* v; ?+ \ * @retval None. z1 B4 ]* @# Q. J' F */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; [# ]' `- Z& P! R' ~. E3 B 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,不正确。