|
库函数TIM_UpdateRequestConfig用于设置寄存器,有两个参数:8 G( y& n# o( F$ q. R 对于这个库函数参数的定义,说明一塌糊涂。% D* T& e1 w L! x 函数的原型如下: 手册原型:3 n# R z1 A' b! e3 Q# p void TIM_UpdateRequestConfig(TIM_TypeDef* TIMx, uint16_t TIM_UpdateSource) {% |4 ?( Z5 M+ j8 R% N6 A /* Check the parameters */ assert_param(IS_TIM_ALL_PERIPH(TIMx)); assert_param(IS_TIM_UPDATE_SOURCE(TIM_UpdateSource));4 Q+ n* P# T0 j. K& `6 y/ H/ s' Y9 `3 a if (TIM_UpdateSource != TIM_UpdateSource_Global)* u5 \3 d. [2 ^ Z {" U, n0 A+ U: _1 z1 {; p /* Set the URS Bit */ TIMx->CR1 |= TIM_CR1_URS;2 D; _+ C4 B4 }7 H& y+ h% | }8 [4 m% _0 A3 k! y' S& _ else. o" D) @( \7 k/ v! a3 C {( Y% U. j+ ~ J! c& N& k /* Reset the URS Bit */$ ], h& b+ U/ Z" t' }6 O TIMx->CR1 &= (uint16_t)~((uint16_t)TIM_CR1_URS); } } b" L- o# P" O' g! ` 库函数原型: void TIM_UpdateRequestConfig(TIM_TypeDef* TIMx, uint16_t TIM_UpdateSource) { /* Check the parameters */ assert_param(IS_TIM_ALL_PERIPH(TIMx));; x7 _) j3 R2 X- N" P0 \ assert_param(IS_TIM_UPDATE_SOURCE(TIM_UpdateSource)); if (TIM_UpdateSource != TIM_UpdateSource_Global) {& R5 F, ?+ J3 {% \0 l, [+ \' J7 [ /* Set the URS Bit */ TIMx->CR1 |= TIM_CR1_URS;: s4 B& m/ d5 V } else% A! P- c# {* P) z { /* Reset the URS Bit */ TIMx->CR1 &= (uint16_t)~((uint16_t)TIM_CR1_URS); }& x9 F- |/ p$ u6 V0 k2 x% R/ N# F }7 D7 H! e, f- b2 w; v 各位看官,至于她什么地方一塌糊涂,自己研究。 我说一下,如何正确使用这个函数。: G7 W$ @$ H. @5 q& o& s 1.手册中的参数两个参数解释,反了(stm32f10x_stdperiph_lib_um.chm):' G" [5 l3 k7 U) {3 V, y% k1 ^( A& O
2.库函数定义处的说明同上一样反了。stm32f10x_time.c 第2109行。/** * @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. * This parameter can be one of the following values: * @arg TIM_UpdateSource_Regular: Source of update is the counter overflow/underflow0 [" Z# a* o5 ~" ~ or the setting of UG bit, or an update generation through the slave mode controller.' ~4 g0 _2 G! E/ g/ O * @arg TIM_UpdateSource_Global: Source of update is counter overflow/underflow.8 E; l' V0 Z) z4 ^8 `" l8 f6 B. {! O * @retval None& { m" O7 \: P6 i7 ^& r */3.参数宏定义的说明正确;stm32f10x_time.h 第0806行。#define TIM_UpdateSource_Global ((uint16_t)0x0000) /*!< Source of update is the counter overflow/underflow+ u! j+ g9 e/ {* K, ?9 Y or the setting of UG bit, or an update generation; f2 n3 F" d: 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,不正确。