打印

先别说FWLib V3,V1.0 or V2.0,手册是个问题!!!

[复制链接]
4272|1
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
eddy836|  楼主 | 2009-10-5 13:39 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
TI, ST, TE, ni, se
本帖最后由 eddy836 于 2009-10-5 13:43 编辑

九九的STM32笔记中写到:FWLib固件库目前的最新版应该是V2.0.x,V1.0.x版本固件库中,TIM1模块被独立出来,调用的函数与其他定时器不同;在V2.0系列版本中,取消了TIM1.h,所有的TIM模块统一调用TIM.h即可。网络上流传的各种代码有许多是基于v1版本的固件库,在移植到v2版本固件库时,需要做些修改。


当然现在最新的FWlib固件库是3.1.2的,先不说这个版本的。一直用的是V2.0的版本,也一直参考着据说是V2.0的中文手册(UM0427《32位基于 ARM 微控制器 STM32F101xx 与 STM32F103xx 固件函数库》)。但这两天发现问题了,原因是在调试TIM的时候发现例程中的函数TIM_OC1Init竟然在该 用户手册中找不到,有点纳闷,用了一个多月的手册难道是1.0版本的???


带着这样的疑问,我找到如下资料:

AN2776(《How to migrate from STM32F10xxx FWLib V1.0 to V2.0》),在2.2.2节中写道:

In FWLib V1.0 the timer peripherals are covered by two drivers:
● stm32f10x_tim.c/stm32f10x_tim.h: they cover the functionality of general-purpose timers (TIM2, TIM3 and TIM4). The function format in this driver is as follows:
   TIM_FunctionName(TIMx, param1, param2,...)
e.g.: TIM_ITConfig(TIM_TypeDef* TIMx, u16 TIM_IT, FunctionalState NewState)

●stm32f10x_tim1.c/stm32f10x_tim1.h: they cover the functionality of the advanced-control timer (TIM1). This driver provides the same set of functions as stm32f10x_tim.c/stm32f10x_tim.h plus dedicated functions to cover addtional TIM1 features (PWMI mode, complementary PWM with dead-time insertion, etc.). The function format in this driver is as follows:
   TIM1_FunctionName(param1, param2,...)
e.g.: TIM1_ITConfig(u16 TIM1_IT, FunctionalState NewState)


In FWLib V2.0, these two drivers have been merged into a single driver, stm32f10x_tim.c/stm32f10x_tim.h, that covers all the timers available in High-
density and Medium-density devices: general-purpose timers (TIM2, TIM3, TIM4 and TIM5), advanced-control timers (TIM1 and TIM8) and basic timers (TIM6&7).This change affects only application code based on the stm32f10x_tim1.c/stm32f10x_tim1.h driver. The set of functions for TIM1 are the same but the name is different. In the function name, “TIM1” was changed to “TIM” and a new parameter was added to specify the timer to be configured.


这么看来的确和九九说的一样,但是UM0427(再说下该文档标题,《STM32F10xxx_Library_Manual_ChineseV2.pdf》),一个是ST版本的,另一个是MXCHIP版本的,这两个版本中都没有出现例如TIM_OC1Init函数。所以我敢肯定这两个绝对不是V2版本的中文手册。于是再找到STM32F10x_FW_Archive,发现这才是真正V2.0的英文版本,**中已明显删去关于TIM1的任何东西,全部以TIM替换!

话说到这里,也不能怪别人,只怪自己太相信中文手册了,说手册是2.0就信以为是2.0。但是作为一个初探STM32的人,一切冠以ST或者MXCHIP的文档都仿佛是权威的象征,究竟是哪个天杀的把文档标题改成_ChineseV2的,还是官方出来的文档就是这样子的,去这两家的官网找不到文档已无从考证! 如果是前者还好说,但如果是后者,这样的错误总不能让我从文档底角下那行纤细的小字“译文仅供参考,与英文版冲突的,以英文版为准”来给予原谅的理由吧?


小弟刚接触STM32,不知道是不是把问题表达清楚了,不吝赐教。





最后附上FWLib v2.0下的TIM下OCToggle例程一部分代码:




TIM下OCToggle例程FWLib V2.0 版本TIM2初始化部分
/* ---------------------------------------------------------------
  TIM2 Configuration: Output Compare Toggle Mode:
  TIM2CLK = 36 MHz, Prescaler = 0x2, TIM2 counter clock = 12 MHz
  CC1 update rate = TIM2 counter clock / CCR1_Val = 366.2 Hz
  CC2 update rate = TIM2 counter clock / CCR2_Val = 732.4 Hz
  CC3 update rate = TIM2 counter clock / CCR3_Val = 1464.8 Hz
  CC4 update rate = TIM2 counter clock / CCR4_Val =  2929.6 Hz
--------------------------------------------------------------- */
  /* Time base configuration */
  TIM_TimeBaseStructure.TIM_Period = 0xFFFF;         
  TIM_TimeBaseStructure.TIM_Prescaler = 0x02;      
  TIM_TimeBaseStructure.TIM_ClockDivision = 0x0;   
  TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
  
  TIM_TimeBaseInit(TIM2, &TIM_TimeBaseStructure);
  /* Output Compare Toggle Mode configuration: Channel1 */
  TIM_OCInitStructure.TIM_OCMode = TIM_OCMode_Toggle;
  TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable;
  TIM_OCInitStructure.TIM_Pulse = 2047;
  TIM_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_Low;
  TIM_OC1Init(TIM2, &TIM_OCInitStructure);
  TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable;
  TIM_OCInitStructure.TIM_Pulse = 1023;
  TIM_OC2Init(TIM2, &TIM_OCInitStructure);
  TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable;
  TIM_OCInitStructure.TIM_Pulse = 511;
  TIM_OC3Init(TIM2, &TIM_OCInitStructure);
  TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable;
  TIM_OCInitStructure.TIM_Pulse = 255;
  TIM_OC4Init(TIM2, &TIM_OCInitStructure);
  
  /* TIM enable counter */
  TIM_Cmd(TIM2, ENABLE);
  /* TIM IT enable */
  TIM_ITConfig(TIM2, TIM_IT_CC1 | TIM_IT_CC2 | TIM_IT_CC3 | TIM_IT_CC4, ENABLE);
沙发
heqinlong2009| | 2009-10-5 18:49 | 只看该作者
你就看英文的那个吧!
中文的 很多小问题

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

8

主题

24

帖子

0

粉丝