打印

定时器程序出现错误了,求教!

[复制链接]
1889|3
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
拿起书本|  楼主 | 2014-6-4 16:28 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
在编译定时器的程序时,编译后报错:
compiling main.c...
main.c(27): error:  #136: struct "<unnamed>" has no field "TIM_Channel"
main.c(30): warning:  #223-D: function "TIM_OCInit" declared implicitly
main.c(35): error:  #136: struct "<unnamed>" has no field "TIM_Channel"
main.c(43): error:  #136: struct "<unnamed>" has no field "TIM_Channel"
main.c(51): error:  #136: struct "<unnamed>" has no field "TIM_Channel"
Target not created


是哪里出错了,请大伙帮忙看看,附上一段源程序
/*通道1 输出比较模式*/
TIM_OCInitStructure.TIM_OCMode=TIM_OCMode_Toggle;
TIM_OCInitStructure.TIM_Channel=TIM_Channel_1;
TIM_OCInitStructure.TIM_Pulse=CCR1_Val;
TIM_OCInitStructure.TIM_OCPolarity=TIM_OCPolarity_Low;
TIM_OCInit(TIM2, &TIM_OCInitStructure);
TIM_OC1PreloadConfig(TIM2, TIM_OCPreload_Disable);

/*通道2 输出比较模式 */
TIM_OCInitStructure.TIM_OCMode=TIM_OCMode_Toggle;
TIM_OCInitStructure.TIM_Channel=TIM_Channel_2;
TIM_OCInitStructure.TIM_Pulse=CCR2_Val;
TIM_OCInitStructure.TIM_OCPolarity=TIM_OCPolarity_Low;
TIM_OCInit(TIM2, &TIM_OCInitStructure);
TIM_OC1PreloadConfig(TIM2, TIM_OCPreload_Disable);        
/*通道3 输出比较模式*/

TIM_OCInitStructure.TIM_OCMode=TIM_OCMode_Toggle;
TIM_OCInitStructure.TIM_Channel=TIM_Channel_3;
TIM_OCInitStructure.TIM_Pulse=CCR3_Val;
TIM_OCInitStructure.TIM_OCPolarity=TIM_OCPolarity_Low;
TIM_OCInit(TIM2, &TIM_OCInitStructure);
TIM_OC1PreloadConfig(TIM2, TIM_OCPreload_Disable);         
/*通道4 输出比较模式*/

TIM_OCInitStructure.TIM_OCMode=TIM_OCMode_Toggle;
TIM_OCInitStructure.TIM_Channel=TIM_Channel_4;
TIM_OCInitStructure.TIM_Pulse=CCR4_Val;
TIM_OCInitStructure.TIM_OCPolarity=TIM_OCPolarity_Low;
TIM_OCInit(TIM2, &TIM_OCInitStructure);
TIM_OC1PreloadConfig(TIM2, TIM_OCPreload_Disable);         

TIM_Cmd(TIM2, ENABLE);
TIM_ITConfig(TIM2, TIM_IT_CC1|TIM_IT_CC2|TIM_IT_CC3|TIM_IT_CC4,ENABLE);

沙发
mmuuss586| | 2014-6-4 18:35 | 只看该作者
XXX tim.c和XXX tim.h等文件包含进来;

使用特权

评论回复
板凳
huangfeng33| | 2014-6-5 09:39 | 只看该作者
两个结构定义USART Init Structure definition和USART Clock Init Structure definition
在main.c中的USART初始化时只用了一个结构类USART_InitStructure进行初始化设置。

使用特权

评论回复
地板

使用特权

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

本版积分规则

个人签名:好好学习,天天向上!

519

主题

4194

帖子

31

粉丝