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

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

[复制链接]
zhurong90s-3151 发布时间:2013-11-11 12:08
库函数TIM_UpdateRequestConfig用于设置寄存器,有两个参数:
+ U/ j6 P3 C( h1 `6 _* A5 E对于这个库函数参数的定义,说明一塌糊涂。
  i  D: ~+ O+ t; n函数的原型如下:
( B* Y1 u* S  k4 f手册原型:
+ w, c- J2 c# q% a' Qvoid TIM_UpdateRequestConfig(TIM_TypeDef* TIMx, uint16_t TIM_UpdateSource)  j- R7 `$ o. s$ ]
{; f' q6 P, [  H2 k( k9 `- Y
  /* Check the parameters */2 m8 S5 V/ A( S9 q7 G; w
  assert_param(IS_TIM_ALL_PERIPH(TIMx));
8 K+ D* a+ `7 s" j) Z5 p  assert_param(IS_TIM_UPDATE_SOURCE(TIM_UpdateSource));
! E5 t/ `& {$ q$ {, K2 {8 L" o  if (TIM_UpdateSource != TIM_UpdateSource_Global)" t, u' p* H# j: N1 u
  {: H& o, Q) v& _: d
    /* Set the URS Bit */- u1 l: d$ \4 T( n* I
    TIMx->CR1 |= TIM_CR1_URS;
$ _! R! L9 @, T: D0 B  }$ _* h4 H4 b" c3 |# N! z
  else2 S) s3 k* f2 }* ^; V% X# D
  {  I, w  F( c" p
    /* Reset the URS Bit */
0 O0 s8 W6 f* b3 U7 w, `    TIMx->CR1 &= (uint16_t)~((uint16_t)TIM_CR1_URS);
/ V3 a& X; e6 h! B! I7 `  W  }, R: R( @2 L. M! L/ o
}- Q& x( B, q( \
库函数原型:
! ]! e* z& G) u! z9 Zvoid TIM_UpdateRequestConfig(TIM_TypeDef* TIMx, uint16_t TIM_UpdateSource)7 p' w% y+ \4 p+ _. ?. H4 @) ^
{
/ \) V' S  B( D- ]9 d0 ~  /* Check the parameters */
) C9 v- O' o$ w* ]% n% O0 T  J  assert_param(IS_TIM_ALL_PERIPH(TIMx));
5 b8 d5 A4 J6 ?; R. ^  assert_param(IS_TIM_UPDATE_SOURCE(TIM_UpdateSource));8 R: d1 {0 o- b% W0 @
  if (TIM_UpdateSource != TIM_UpdateSource_Global)
) V6 z/ l8 A; w  {8 u3 {7 @, Q; n4 ?$ V5 I( w
    /* Set the URS Bit */
; s' i8 n0 A2 r5 s( a6 \  b1 c0 L    TIMx->CR1 |= TIM_CR1_URS;
! M: W8 D. ~- u; i' K+ L4 S& k  }5 |; W$ N- ?/ m3 k
  else
) y3 b" O3 J& B3 G1 e- y  {8 `$ k" w1 z# y, {1 E1 ^3 E
    /* Reset the URS Bit */. Y6 B. ^3 x; Z- l% R( m2 c* h
    TIMx->CR1 &= (uint16_t)~((uint16_t)TIM_CR1_URS);
; D3 k$ D* X7 \# q  z  }1 H& Q7 @0 d% |9 S8 }5 z) l) o' @
}% {0 `4 x9 H( H2 D
各位看官,至于她什么地方一塌糊涂,自己研究。& q' O  E) Q$ j9 r. o$ W2 P
我说一下,如何正确使用这个函数。
+ {1 X8 p# _; Z3 O1.手册中的参数两个参数解释,反了(stm32f10x_stdperiph_lib_um.chm):
' g4 g9 g8 M% x
       
    & x8 p: i% V+ g/ [# r, B
  • 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.    ; b% u( S8 N& E6 M+ p* {) o- x
  • TIM_UpdateSource_Global: Source of update is counter overflow/underflow9 a' ]. Y6 N5 l& y: R
 
2 t2 Y& h: h/ ]2.库函数定义处的说明同上一样反了。stm32f10x_time.c 第2109行。/**
" E& r: W4 {( y. O, h4 q; L$ p  * @brief  Configures the TIMx Update Request Interrupt source.& l) J8 U& }( G
  * @param  TIMx: where x can be 1 to 17 to select the TIM peripheral.0 Q2 R$ Z2 v# E6 h
  * @param  TIM_UpdateSource: specifies the Update source.: v8 Y1 \$ }( c% d1 c
  *   This parameter can be one of the following values:3 ^& B7 h. i/ @: @8 c& N& O' m5 s
  *     @arg TIM_UpdateSource_Regular: Source of update is the counter overflow/underflow
" B5 X' ]0 X& F                                       or the setting of UG bit, or an update generation, |4 R# g# w1 A
                                       through the slave mode controller.' S5 y2 a2 g. G  v' {7 {' J
  *     @arg TIM_UpdateSource_Global: Source of update is counter overflow/underflow.; K( e, j; U* @* S
  * @retval None
1 g9 N! w7 O4 b: W' m' `  */3.参数宏定义的说明正确;stm32f10x_time.h 第0806行。#define TIM_UpdateSource_Global            ((uint16_t)0x0000) /*!< Source of update is the counter overflow/underflow/ J8 m6 u( X# |$ e2 X- C$ ?1 @# M
                                                                   or the setting of UG bit, or an update generation& q2 Y5 ^' D. k3 O8 J& a
                                                                   through the slave mode controller. */
! P: J) D4 Z6 ^/ t* {, c' n#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管理
行使您的权利
官方最新发布
STM32N6 AI生态系统
STM32MCU,MPU高性能GUI
ST ACEPACK电源模块
意法半导体生物传感器
STM32Cube扩展软件包
关注我们
st-img 微信公众号
st-img 手机版