你的浏览器版本过低,可能导致网站不能正常访问!
为了你能正常使用网站功能,请使用这些浏览器。

STM32 定时器库函数,TIM_UpdateRequestConfig,不正确。

[复制链接]
zhurong90s-3151 发布时间:2013-11-11 12:08
库函数TIM_UpdateRequestConfig用于设置寄存器,有两个参数:
, s2 z$ d- V- ^2 ]- u对于这个库函数参数的定义,说明一塌糊涂。' o8 N- R5 l" K0 i
函数的原型如下:
" Y/ S8 S5 [( v4 C手册原型:
4 o- a( K9 n. C( qvoid TIM_UpdateRequestConfig(TIM_TypeDef* TIMx, uint16_t TIM_UpdateSource)
1 a+ M+ {& `8 ?; E7 p* _7 I{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)
: p5 K" J4 F+ R; V" i  {- 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$ _
  }
) n& K2 z* x9 ~0 O5 D  else
% z! z% l0 C+ E7 _3 H& j  {
' D8 G" F! r6 O. |( B5 z3 e% n    /* 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
  }
% H% Q. H. G+ G. k6 g! m/ t1 s}- K/ Q+ U" C) L, P
库函数原型:
; s' V2 j! C8 Evoid TIM_UpdateRequestConfig(TIM_TypeDef* TIMx, uint16_t TIM_UpdateSource)
; b7 Q% ~/ k2 _  l2 L{
, `0 F( W1 Q( Q( w, x: n, t% A  /* Check the parameters */4 o6 v/ _4 F+ i0 k7 M* s7 C
  assert_param(IS_TIM_ALL_PERIPH(TIMx));
* e: ?& R* Y* U* T; ^% G+ y  assert_param(IS_TIM_UPDATE_SOURCE(TIM_UpdateSource));
5 u0 x6 b) h' z7 B5 g' F$ Z  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 */
' F8 V/ R+ r6 P3 K" c    TIMx->CR1 |= TIM_CR1_URS;
# x. @& j6 ]1 Z' a) E8 G  M  }
1 ~9 G, L* B* O5 e9 @9 s2 x  else
5 M6 \1 f6 E+ G# F  {
3 d9 @2 q7 {) U+ Z6 e2 n, ]    /* Reset the URS Bit */
; S  y1 V* T" n1 c0 W/ s    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
       
    9 i3 E* v( A7 U( \& s' p" H
  • 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.    1 `. C% k. `- ]: M& ]/ v2 a. u, P
  • TIM_UpdateSource_Global: Source of update is counter overflow/underflow
    - B( J% m+ b. Y' Z$ W  F
 
0 K3 j% p# m4 `4 [  L: C( C2.库函数定义处的说明同上一样反了。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
3 i: E8 S8 V" C. X. X                                                                   or the setting of UG bit, or an update generation; [# ]' `- Z& P! R' ~. E3 B
                                                                   through the slave mode controller. */
5 c( H3 W3 B! F. J3 w#define TIM_UpdateSource_Regular           ((uint16_t)0x0001) /*!< Source of update is counter overflow/underflow. */ 
360软件小助手截图20131111114320.jpg
1 收藏 评论5 发布时间:2013-11-11 12:08

举报

5个回答
废鱼 回答时间:2013-11-11 15:15:48

RE:STM32 定时器库函数,TIM_UpdateRequestConfig,不正确。

谢谢楼主提出的意见。
回答时间:2013-11-12 22:10:10

RE:STM32 定时器库函数,TIM_UpdateRequestConfig,不正确。

不错哦,楼主很细心!
feiante-155820 回答时间:2013-11-13 07:50:27

RE:STM32 定时器库函数,TIM_UpdateRequestConfig,不正确。

楼主研究的很深啊
温柔的武士刀 回答时间:2013-11-13 22:37:35

RE:STM32 定时器库函数,TIM_UpdateRequestConfig,不正确。

涨姿势,谢谢楼主!
小景在线 回答时间:2017-4-11 11:43:01
楼主说的没错,库函数是解释错误了,在头文件中是正确的,但是行数应该是0860行【3.参数宏定义的说明正确;stm32f10x_time.h 第0806行。 】,我的库文件是3.5.0

所属标签

关于
我们是谁
投资者关系
意法半导体可持续发展举措
创新与技术
意法半导体官网
联系我们
联系ST分支机构
寻找销售人员和分销渠道
社区
媒体中心
活动与培训
隐私策略
隐私策略
Cookies管理
行使您的权利
官方最新发布
人形机器人运动控制、感知与智能配电
半导体创新技术与应用方向
EE架构与软件定义汽车
12V/48V 汽车智能配电(SPD)
区域控制单元(ZCU)与分区架构
关注我们
st-img 微信公众号
st-img 手机版