OpenEdv-开源电子网

 找回密码
 立即注册
正点原子全套STM32/Linux/FPGA开发资料,上千讲STM32视频教程免费下载...
查看: 4509|回复: 1

编译错误,谁能告诉我怎可改呀,谢谢

[复制链接]

2

主题

4

帖子

0

精华

新手入门

积分
32
金钱
32
注册时间
2015-4-29
在线时间
0 小时
发表于 2015-4-29 21:46:40 | 显示全部楼层 |阅读模式
5金钱
#include <stm32f10x_lib.h>
#include "sys.h"
#include "usart.h"
#include "delay.h"
void TIM3_External_Clock_CountingMode(void)
{
 GPIO_InitTypeDef GPIO_InitStructure; // 定义管脚函数;
 TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure;
 // TIM_ICInitTypeDef? TIM_ICInitStructure;
 RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE);//开启时钟

 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7;
 GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
 GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
 GPIO_Init(GPIOA, &GPIO_InitStructure); //初始化调用

 RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM3, ENABLE);
 TIM_DeInit(TIM3);
 TIM_TimeBaseStructure.TIM_Period = 0xFFFF;
 TIM_TimeBaseStructure.TIM_Prescaler = 0x00;
 TIM_TimeBaseStructure.TIM_ClockDivision = 0x0; /*定时器时钟(CK_INT)频率与数字滤波器(ETR,TIx)
使用的采样频率之间的分频比为1*/
 TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
 TIM_TimeBaseInit( TIM3, &TIM_TimeBaseStructure); // Time base configuration函数调用

/*
 tmpccmr1 |= (uint16_t)(TIM_ICFilter << 12); // CCMR1_IC2F
 tmpccmr1 |= (uint16_t)(TIM_ICSelection << 8); // CCMR1_CC2S
 由TIM_TIxExternalCLK1Source_TI2决定了
 TIM_ICSelection=TIM_ICSelection_DirectTI: CCMR1_CC2S = 01;
 TIM_ICPolarity_Rising = CCER_CC2P
 TIM_TIxExternalCLK1Source_TI2 = TIM_SMCR_TS
 该函数定义了TIM_SlaveMode_External1;外部时钟模式1
*/
 TIM_TIxExternalClockConfig(TIM3,TIM_TIxExternalCLK1Source_TI2,TIM_ICPolarity_Rising,0);
// TIM_SetCounter(TIM3, 0); // 清零计数器CNT
//TIM_Cmd(TIM3,ENABLE);
}
int main(void)

   u16 i ;
   TIM3_External_Clock_CountingMode();
   TIM_SetCounter(TIM3, 0); // 清零计数器CNT
   TIM_Cmd(TIM3,ENABLE);
   SecCnt = 0;
   TFgs.Secok = 0;
   i=0;
 while(1)
 {
extern Delay_Nms(1000);
       CountPulse = TIM_GetCounter(TIM3);
       DisplayDat(10,10+24*i,CountPulse,5);
extern TFgs.Secok = 0;
     if(++CountTims>=120)
   {
 TIM_Cmd(TIM3,DISABLE);
 CountPulse = TIM_GetCounter(TIM3);
 DisplayDat(10,10+24*i,CountPulse,5);
 if(++i>11)i=0;
 TIM_SetCounter(TIM3, 0);// 清零计数器CNT
 TIM_Cmd(TIM3,ENABLE);
 SecCnt = 0;
 TFgs.Secok = 0;
 CountTims =0;
 }
 }
 }
编译后:
Build target 'Target 1'
compiling test.c...
test.c(48): error:  #154: expression must have struct or union type
test.c(52): error:  #79: expected a type specifier
test.c(53): error:  #20: identifier "CountPulse" is undefined
test.c(54): warning:  #223-D: function "DisplayDat" declared implicitly
test.c(55): error:  #268: declaration may not appear after executable statement in block
test.c(55): warning:  #260-D: explicit type is missing ("int" assumed)
test.c(55): error:  #65: expected a ";"
test.c(56): error:  #20: identifier "CountTims" is undefined
test.c(65): error:  #154: expression must have struct or union type
test.c(42): warning:  #550-D: variable "SecCnt" was set but never used
Target not created

正点原子逻辑分析仪DL16劲爆上市
回复

使用道具 举报

530

主题

11万

帖子

34

精华

管理员

Rank: 12Rank: 12Rank: 12

积分
165540
金钱
165540
注册时间
2010-12-1
在线时间
2117 小时
发表于 2015-4-29 22:35:07 | 显示全部楼层
类型不匹配,自己修改。
我是开源电子网www.openedv.com站长,有关站务问题请与我联系。
正点原子STM32开发板购买店铺http://openedv.taobao.com
正点原子官方微信公众平台,点击这里关注“正点原子”
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则



关闭

原子哥极力推荐上一条 /2 下一条

正点原子公众号

QQ|手机版|OpenEdv-开源电子网 ( 粤ICP备12000418号-1 )

GMT+8, 2025-6-23 01:51

Powered by OpenEdv-开源电子网

© 2001-2030 OpenEdv-开源电子网

快速回复 返回顶部 返回列表