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

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

[复制链接]
zhurong90s-3151 发布时间:2013-11-11 12:08
库函数TIM_UpdateRequestConfig用于设置寄存器,有两个参数:8 G( y& n# o( F$ q. R
对于这个库函数参数的定义,说明一塌糊涂。% D* T& e1 w  L! x
函数的原型如下:
% V9 g: }; {! j$ c  C( ]  s手册原型:3 n# R  z1 A' b! e3 Q# p
void TIM_UpdateRequestConfig(TIM_TypeDef* TIMx, uint16_t TIM_UpdateSource)
3 I8 p3 {# i+ `: y& _# s3 M{% |4 ?( Z5 M+ j8 R% N6 A
  /* Check the parameters */
! C& f" Z5 M- B3 J& |  assert_param(IS_TIM_ALL_PERIPH(TIMx));
0 g: ^! _, d0 E  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 */
5 v( n' T' k/ D    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);
8 R6 w2 B) a: R) ~* F  }
, }5 s: ]! @- a}  b" L- o# P" O' g! `
库函数原型:
2 r% g! V( C1 I" z9 Pvoid TIM_UpdateRequestConfig(TIM_TypeDef* TIMx, uint16_t TIM_UpdateSource)
! J6 d/ Q4 l2 r( ]{
0 _- h4 U( g# E* b& Y  /* Check the parameters */
9 c6 |' z& d7 T" v: E( v/ t  assert_param(IS_TIM_ALL_PERIPH(TIMx));; x7 _) j3 R2 X- N" P0 \
  assert_param(IS_TIM_UPDATE_SOURCE(TIM_UpdateSource));
0 `$ \# D9 k. N8 |  if (TIM_UpdateSource != TIM_UpdateSource_Global)
- K. B' k6 q5 j* F% X; k0 F  {& R5 F, ?+ J3 {% \0 l, [+ \' J7 [
    /* Set the URS Bit */
- g5 c) z' j9 ?. [8 X    TIMx->CR1 |= TIM_CR1_URS;: s4 B& m/ d5 V
  }
! N- C! u; q4 D' G" X2 A  else% A! P- c# {* P) z
  {
8 V# t3 e6 a$ h* Y* i  b    /* Reset the URS Bit */
  p/ _  A8 Q  }6 z: F    TIMx->CR1 &= (uint16_t)~((uint16_t)TIM_CR1_URS);
. N2 ~' I, O* l# ]5 h  }& x9 F- |/ p$ u6 V0 k2 x% R/ N# F
}7 D7 H! e, f- b2 w; v
各位看官,至于她什么地方一塌糊涂,自己研究。
6 E3 ^2 e$ v# O' l+ ~5 x2 ^我说一下,如何正确使用这个函数。: G7 W$ @$ H. @5 q& o& s
1.手册中的参数两个参数解释,反了(stm32f10x_stdperiph_lib_um.chm):' G" [5 l3 k7 U) {3 V, y% k1 ^( A& O
       
    % H# Z8 M! X3 I( c2 |) N  \
  • 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.    # w" n7 }; z( Q/ P
  • TIM_UpdateSource_Global: Source of update is counter overflow/underflow7 r$ {4 D/ g. k+ o
 & B0 Z7 [8 T. o: R0 W0 ]) ]2 v( R
2.库函数定义处的说明同上一样反了。stm32f10x_time.c 第2109行。/**
5 ]3 J0 s3 E: S$ y  * @brief  Configures the TIMx Update Request Interrupt source.
# S4 {; c$ E# j: J! _7 N! n4 o  * @param  TIMx: where x can be 1 to 17 to select the TIM peripheral.
( x8 z  D- ]9 p% s5 _  * @param  TIM_UpdateSource: specifies the Update source.
! U! j8 O" o# l$ |  *   This parameter can be one of the following values:
1 U$ h* q5 `- I! @: I: R  Y  *     @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
5 X- E$ p6 q; c6 q8 D# w9 M                                       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. */
7 l9 H5 L  o7 I9 f#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 手机版