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

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

[复制链接]
zhurong90s-3151 发布时间:2013-11-11 12:08
库函数TIM_UpdateRequestConfig用于设置寄存器,有两个参数:6 F5 {, m. o1 o/ @1 a
对于这个库函数参数的定义,说明一塌糊涂。" X; J) Y& v2 a" r
函数的原型如下:
  J4 r6 D5 y. d; U, O+ E" f手册原型:/ o, K. s( N" k* y6 I/ j2 p
void TIM_UpdateRequestConfig(TIM_TypeDef* TIMx, uint16_t TIM_UpdateSource)
2 u: N2 N; }+ v) e# e{  ~0 ^$ j4 s, t! ~" m9 L" c
  /* Check the parameters */
& d- L+ u3 \5 i+ v  assert_param(IS_TIM_ALL_PERIPH(TIMx));) J' O3 E& v  ~* a; ]3 p
  assert_param(IS_TIM_UPDATE_SOURCE(TIM_UpdateSource));# @3 L  k8 d" a; U
  if (TIM_UpdateSource != TIM_UpdateSource_Global)
4 C# r2 [) S# Q  {
, Q* w6 E1 P: P, e    /* Set the URS Bit */- M  |, k# b. p+ p. t+ V, u
    TIMx->CR1 |= TIM_CR1_URS;
) H2 Z2 X* L- ^& q/ |* {  }
* Q: f$ {; ]- l' q" O% `  else6 p' [3 L$ D% Z/ k2 s; X+ q
  {
0 |" [6 B/ ]: g    /* Reset the URS Bit */
; Z, D1 S5 {" F, }    TIMx->CR1 &= (uint16_t)~((uint16_t)TIM_CR1_URS);2 p- ^3 X/ ?9 n1 N3 V
  }
$ {% A1 d- p9 j  T% b2 T}
( m+ s9 e9 b0 ?库函数原型:
# d( i0 T& n9 Z8 k( ?void TIM_UpdateRequestConfig(TIM_TypeDef* TIMx, uint16_t TIM_UpdateSource)
# c) L& g4 i# Z1 R' w8 \. {{1 O' H5 }- s/ d  D
  /* Check the parameters */
1 f; O8 ^; x# @- {  assert_param(IS_TIM_ALL_PERIPH(TIMx));
1 F) K. O, N) x* P, z. R5 C  assert_param(IS_TIM_UPDATE_SOURCE(TIM_UpdateSource));
' @) Z5 o) s6 A: e  if (TIM_UpdateSource != TIM_UpdateSource_Global)
) p5 p# {) q  m3 u  {0 h0 K% g  {* x6 I+ x: v) i8 P% {8 h
    /* Set the URS Bit */8 k3 c& w5 `# s8 ~" i/ g3 o
    TIMx->CR1 |= TIM_CR1_URS;+ y; f0 b% r9 a" V, U* }+ e
  }
7 a6 R1 p1 V$ _3 ?5 m2 V+ ?  else
' b0 a' i; X% h# p' p  {  D, h" ^0 T9 ~$ n5 h" L( ?+ }
    /* Reset the URS Bit */
8 r% S' ?+ I' X+ ~& }! @2 w    TIMx->CR1 &= (uint16_t)~((uint16_t)TIM_CR1_URS);$ c% o1 T3 ?4 |
  }, m$ T0 e2 B5 [: f4 ~
}
* q, M( I# M! a5 O! p各位看官,至于她什么地方一塌糊涂,自己研究。' [8 _9 s6 z( y$ {  k7 w
我说一下,如何正确使用这个函数。4 g; X3 l; M& I' k; e
1.手册中的参数两个参数解释,反了(stm32f10x_stdperiph_lib_um.chm):
; K( _) r1 b: A
       
    , C& R7 P' S/ q3 x
  • 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.   
    ; M8 k# T1 @" S& [+ ]7 h  e& X
  • TIM_UpdateSource_Global: Source of update is counter overflow/underflow
    % n" p9 A' ~- |! y6 Y7 g2 l& u
 ( l, ?; b" l$ N
2.库函数定义处的说明同上一样反了。stm32f10x_time.c 第2109行。/**+ _; E% M# w! E) A1 X, g
  * @brief  Configures the TIMx Update Request Interrupt source.
  ~: O6 T. A- O3 |7 Y  * @param  TIMx: where x can be 1 to 17 to select the TIM peripheral.
4 q/ A( b" d4 I1 g* M. `. }7 j# k% \  * @param  TIM_UpdateSource: specifies the Update source.5 \% A; M9 R9 G
  *   This parameter can be one of the following values:! Y# @  m6 j: ?, J  K' a5 B
  *     @arg TIM_UpdateSource_Regular: Source of update is the counter overflow/underflow
1 P3 K: r( S) ~                                       or the setting of UG bit, or an update generation
$ h# n+ {# x' [8 T                                       through the slave mode controller.
) Y: f- p; |( d, X/ [  *     @arg TIM_UpdateSource_Global: Source of update is counter overflow/underflow.3 G" B- _8 t4 R, U' q7 M
  * @retval None7 P, x8 J& D# Y8 h! G+ s7 P
  */3.参数宏定义的说明正确;stm32f10x_time.h 第0806行。#define TIM_UpdateSource_Global            ((uint16_t)0x0000) /*!< Source of update is the counter overflow/underflow
6 @+ S: h5 m9 n                                                                   or the setting of UG bit, or an update generation
3 G" l  a$ b2 m4 y9 [/ e                                                                   through the slave mode controller. */
, m7 k( ^8 ]  g8 ?# c; v, I1 d#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 手机版