|
库函数TIM_UpdateRequestConfig用于设置寄存器,有两个参数:! v8 [9 ]) F3 Q. L 对于这个库函数参数的定义,说明一塌糊涂。 X( M. p8 F4 N' [0 U 函数的原型如下: 手册原型: void TIM_UpdateRequestConfig(TIM_TypeDef* TIMx, uint16_t TIM_UpdateSource); {6 e0 } o8 B& ^& D- @2 G { /* Check the parameters *// Q3 w) R; t, i, T2 q+ P, ^5 j assert_param(IS_TIM_ALL_PERIPH(TIMx)); assert_param(IS_TIM_UPDATE_SOURCE(TIM_UpdateSource));" r3 ~& j: H4 c$ T( Y& K if (TIM_UpdateSource != TIM_UpdateSource_Global)( s* k3 i7 b& E( x3 Z4 A& n {; \4 I6 w. J0 | /* Set the URS Bit */1 x8 Z7 |/ B5 j TIMx->CR1 |= TIM_CR1_URS;" q E7 v/ J( k* \0 K3 r' S! H0 | } else: c) ~# K& @+ M4 Y. ^9 b {0 A+ n% r, p, R /* Reset the URS Bit */2 B3 q0 z6 n& ~9 m6 X; O TIMx->CR1 &= (uint16_t)~((uint16_t)TIM_CR1_URS);6 X, I) Q7 Q2 Z4 j } }. S0 H3 A, Z. B0 o, R# n 库函数原型: void TIM_UpdateRequestConfig(TIM_TypeDef* TIMx, uint16_t TIM_UpdateSource) {; }4 p, J' h* z /* Check the parameters */( m; H6 F9 a$ { assert_param(IS_TIM_ALL_PERIPH(TIMx));& ?* W0 E* b9 E; h assert_param(IS_TIM_UPDATE_SOURCE(TIM_UpdateSource));: V: Q# G( g$ n if (TIM_UpdateSource != TIM_UpdateSource_Global) {4 d! F$ Y. j' F! l X6 |9 M4 H. F /* Set the URS Bit */ TIMx->CR1 |= TIM_CR1_URS;4 k3 ?: I Q/ W( W( P }: k8 T% ]1 x. M else8 }! V# x( o% _1 c; k: ^9 P {! q0 x1 t1 i) b6 {+ \; c /* Reset the URS Bit */ TIMx->CR1 &= (uint16_t)~((uint16_t)TIM_CR1_URS);- X2 m2 u0 N, q6 u } c& k( Q! b/ o3 b } 各位看官,至于她什么地方一塌糊涂,自己研究。; l4 [0 C3 c) B8 ~3 q; K8 e2 h 我说一下,如何正确使用这个函数。' I) D# f5 C0 x' y+ E* ` 1.手册中的参数两个参数解释,反了(stm32f10x_stdperiph_lib_um.chm):
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., E8 ^3 ~9 ^# k, l9 J * This parameter can be one of the following values:: p3 H$ v' h3 j3 _& u * @arg TIM_UpdateSource_Regular: Source of update is the counter overflow/underflow; q6 ~2 [, d% S3 K, c+ c# f' D or the setting of UG bit, or an update generation4 d* n- Q' e- Q; B: O3 H through the slave mode controller.- C2 ?+ p9 J. k9 }1 h0 s' H * @arg TIM_UpdateSource_Global: Source of update is counter overflow/underflow.: ~. r' F1 C: o4 d * @retval None, t1 P/ C' ?. U7 \( e* q* L5 @ */3.参数宏定义的说明正确;stm32f10x_time.h 第0806行。#define TIM_UpdateSource_Global ((uint16_t)0x0000) /*!< Source of update is the counter overflow/underflow$ t* l# `3 F/ V) M or the setting of UG bit, or an update generation3 y$ T# t; _, z: y2 H 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,不正确。