程序:
#include <stm32f10x_lib.h>
#include "sys.h"
#include "usart.h"
#include "delay.h"
#include "led.h"
#include "key.h"
#include "exti.h"
extern int Q1; //申明检测金属脉冲数Q1为外部变量,以便在exit.c和text.c两文件中都能调用i这个变量
extern int Q2;
extern int Q3;
//注意,此代码还是无法进行SWD仿真!因为使用了中断,没法用普通的方法来考虑间歇复用SWD口!
int main(void)
{
int D; //车轮直径
int lucheng1; //第一块金属片距起点的距离
int lucheng2; //第二块金属片距起点的距离
int lucheng3; //第三块金属片距起点的距离
Stm32_Clock_Init(9); //系统时钟设置
delay_init(72); //延时初始化
uart_init(72,9600); //串口初始化
EXTIX_Init(); //外部中断初始化
while(1)
{
lucheng1=(3.14*D/20*Q1);//路程计算公式
lucheng2=(3.14*D/20*Q2);//路程计算公式
lucheng3=(3.14*D/20*Q3);//路程计算公式
}
}
编译出现如下警告:
test.c(17): warning: #550-D: variable "lucheng1" was set but never used
test.c(18): warning: #550-D: variable "lucheng2" was set but never used
test.c(19): warning: #550-D: variable "lucheng3" was set but never used
不知道为什么会出现这些警告,是不是WHILE里面几句程序没有执行呢???
|