OpenEdv-开源电子网

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

求大神帮忙,怎么改正编译时的错误。mdk3编的(外部脉冲计数)谢谢

[复制链接]

6

主题

19

帖子

0

精华

初级会员

Rank: 2

积分
63
金钱
63
注册时间
2015-4-29
在线时间
0 小时
发表于 2015-4-29 11:00:53 | 显示全部楼层 |阅读模式
5金钱
#include <stm32f10x_lib.h>
#include "sys.h"
#include "usart.h"
#include "delay.h"
int main(void)
{
  unsigned char i_Loop;
  unsigned char n_Counter;
#ifdef DEBUG
 debug();
#endif
  void RCC_Configuration(void); // System Clocks Configuration
  void NVIC_Configuration(void); // NVIC configuration
  void GPIO_Configuration(void); // Configure the GPIO ports
 
  TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure;
  TIM_TimeBaseStructure.TIM_Period = 0xFFFF;
  TIM_TimeBaseStructure.TIM_Prescaler = 0x00;
  TIM_TimeBaseStructure.TIM_ClockDivision = 0x0;
  TIM_TimeBaseStructure.TIM_CounterMode =TIM_CounterMode_Up;

  TIM_TimeBaseInit(TIM2, &TIM_TimeBaseStructure); // Time base configuration
  
  TIM_ETRClockMode2Config(TIM2, TIM_ExtTRGPSC_OFF, TIM_ExtTRGPolarity_NonInverted, 0);
  TIM_SetCounter(TIM2, 0);
  TIM_Cmd(TIM2, ENABLE);
  for(i_Loop = 0; i_Loop < 100; i_Loop ++)
  {
  void  GPIO_SetBits(GPIOC, GPIO_Pin_6);
   delay_init(10);
  void GPIO_ResetBits(GPIOC, GPIO_Pin_6);
   delay_init(10);
  }
   n_Counter = TIM_GetCounter(TIM2);
  return(n_Counter)
  while (1)
 {

  }
  }
  以下是编译错误:
Build target 'Target 1'
compiling test.c...
test.c(31): error:  #79: expected a type specifier
test.c(31): error:  #79: expected a type specifier
test.c(33): error:  #268: declaration may not appear after executable statement in block
test.c(33): error:  #79: expected a type specifier
test.c(33): error:  #79: expected a type specifier
test.c(38): error:  #65: expected a ";"
test.c(42): warning:  #12-D: parsing restarts here after previous syntax error
Target not created
谢谢,以上程序也是网上档的,但是自己编译就出错了,大神们帮帮忙,都弄了快一星期了,要疯了,我从来没有接触过STM32,真是菜鸟中的菜鸟!!!

最佳答案

查看完整内容[请看2#楼]

你函数申明都写到函数里面去了。。。。点击报错的信息,就可以定位到报错的行 然后  return(n_Counter),这里分号都没有。。。 这里也提醒你了:test.c(38): error:  #65: expected a ";"
正点原子逻辑分析仪DL16劲爆上市
回复

使用道具 举报

230

主题

1950

帖子

10

精华

论坛元老

Rank: 8Rank: 8

积分
4562
金钱
4562
注册时间
2010-12-14
在线时间
32 小时
发表于 2015-4-29 11:00:54 | 显示全部楼层
你函数申明都写到函数里面去了。。。。点击报错的信息,就可以定位到报错的行
然后  return(n_Counter),这里分号都没有。。。 这里也提醒你了:test.c(38): error:  #65: expected a ";"
我是开源电子网?网站管理员,对网站有任何问题,请与我联系!QQ:389063473Email:389063473@qq.com
回复

使用道具 举报

230

主题

1950

帖子

10

精华

论坛元老

Rank: 8Rank: 8

积分
4562
金钱
4562
注册时间
2010-12-14
在线时间
32 小时
发表于 2015-4-29 11:14:15 | 显示全部楼层
void RCC_Configuration(void); // System Clocks Configuration
  void NVIC_Configuration(void); // NVIC configuration
  void GPIO_Configuration(void); // Configure the GPIO ports
我是开源电子网?网站管理员,对网站有任何问题,请与我联系!QQ:389063473Email:389063473@qq.com
回复

使用道具 举报

6

主题

19

帖子

0

精华

初级会员

Rank: 2

积分
63
金钱
63
注册时间
2015-4-29
在线时间
0 小时
 楼主| 发表于 2015-4-29 11:20:57 | 显示全部楼层
回复【3楼】Admin:
---------------------------------
原先其实没有void 的,之后有人说加上,然后就这样了
回复

使用道具 举报

230

主题

1950

帖子

10

精华

论坛元老

Rank: 8Rank: 8

积分
4562
金钱
4562
注册时间
2010-12-14
在线时间
32 小时
发表于 2015-4-29 14:55:53 | 显示全部楼层
回复【4楼】天下:
---------------------------------
不是void。。是你这三个函数申明,你写到main函数里面啊。。。
函数申明在函数之外
我是开源电子网?网站管理员,对网站有任何问题,请与我联系!QQ:389063473Email:389063473@qq.com
回复

使用道具 举报

6

主题

19

帖子

0

精华

初级会员

Rank: 2

积分
63
金钱
63
注册时间
2015-4-29
在线时间
0 小时
 楼主| 发表于 2015-4-29 20:42:01 | 显示全部楼层
回复【5楼】Admin:
---------------------------------
我把那几句放到了外面结果出现了这种错误
Build target 'Target 1'
linking...
test.axf: Error: L6218E: Undefined symbol GPIO_ResetBits (referred from test.o).
test.axf: Error: L6218E: Undefined symbol GPIO_SetBits (referred from test.o).
test.axf: Error: L6218E: Undefined symbol TIM_Cmd (referred from test.o).
test.axf: Error: L6218E: Undefined symbol TIM_ETRClockMode2Config (referred from test.o).
test.axf: Error: L6218E: Undefined symbol TIM_GetCounter (referred from test.o).
test.axf: Error: L6218E: Undefined symbol TIM_SetCounter (referred from test.o).
test.axf: Error: L6218E: Undefined symbol TIM_TimeBaseInit (referred from test.o).
Target not created
回复

使用道具 举报

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

本版积分规则



关闭

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

正点原子公众号

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

GMT+8, 2025-6-23 04:17

Powered by OpenEdv-开源电子网

© 2001-2030 OpenEdv-开源电子网

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