
库函数TIM_UpdateRequestConfig用于设置寄存器,有两个参数:" i- n5 t5 I2 {7 E2 O6 S3 W 对于这个库函数参数的定义,说明一塌糊涂。4 Z- w8 i+ |0 r4 \7 y6 c- V 函数的原型如下: g4 Y, z: X4 X: Q( a( _8 s 手册原型:5 D) s1 r* U. _" z/ _ void TIM_UpdateRequestConfig(TIM_TypeDef* TIMx, uint16_t TIM_UpdateSource)( K( v: C H1 @! @7 a6 a/ i {. I- B" E" G1 N. E /* Check the parameters */ assert_param(IS_TIM_ALL_PERIPH(TIMx)); W) ~8 {9 Y$ ]9 N. `3 E7 e; J assert_param(IS_TIM_UPDATE_SOURCE(TIM_UpdateSource));2 `9 g+ Q$ ^, y/ `! \$ ~ if (TIM_UpdateSource != TIM_UpdateSource_Global)& E* O" w* V0 |$ ^- M {& e* k6 X9 k* y7 H! V /* Set the URS Bit */" M$ {' k/ H, e TIMx->CR1 |= TIM_CR1_URS; }. U* v. H8 I; d4 d- W/ | else3 @$ I4 p8 f, O- d+ T ^ {0 E1 y7 d) m z /* Reset the URS Bit */, i6 T- b+ \: Q4 O; k, r2 O TIMx->CR1 &= (uint16_t)~((uint16_t)TIM_CR1_URS); }8 ]- y' U" V- Y4 A+ E$ u* U9 d( c! j }6 S" B1 T8 K$ Q/ Q/ A: l" W 库函数原型:, N9 [$ b) G' f9 A void TIM_UpdateRequestConfig(TIM_TypeDef* TIMx, uint16_t TIM_UpdateSource)8 ?: Z* Z+ q4 D% t) O8 _ { /* Check the parameters */ assert_param(IS_TIM_ALL_PERIPH(TIMx));; s8 Z+ R B* J* Q" N assert_param(IS_TIM_UPDATE_SOURCE(TIM_UpdateSource)); ^; v2 [+ u" x4 i6 _2 p7 _* q if (TIM_UpdateSource != TIM_UpdateSource_Global), ?' H6 Z- ]2 O { /* Set the URS Bit */ TIMx->CR1 |= TIM_CR1_URS; }. H: c4 O# u4 ]5 ?4 _, p; R& [, o else+ W( @0 t5 b! ? { /* Reset the URS Bit */' |" `! p9 O# R: q# B4 T+ T% d TIMx->CR1 &= (uint16_t)~((uint16_t)TIM_CR1_URS); } }! _! ~' G) v2 i8 b 各位看官,至于她什么地方一塌糊涂,自己研究。 我说一下,如何正确使用这个函数。9 U7 v$ J" u1 q# @( X9 p2 C$ g 1.手册中的参数两个参数解释,反了(stm32f10x_stdperiph_lib_um.chm):3 ]/ \5 `. r1 v+ f
2.库函数定义处的说明同上一样反了。stm32f10x_time.c 第2109行。/**2 E0 W2 G6 k2 }* ? * @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:# t( E2 N2 K/ y! `# u( E * @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. * @retval None */3.参数宏定义的说明正确;stm32f10x_time.h 第0806行。#define TIM_UpdateSource_Global ((uint16_t)0x0000) /*!< Source of update is the counter overflow/underflow; O) b- v! V9 c" f) |& f) u or the setting of UG bit, or an update generation through the slave mode controller. */+ C: S4 L, i3 ]. U$ J$ a #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,不正确。