Build target 'Target 1'
compiling delay.c...
delay.c(13): warning C316: unterminated conditionals
compiling ads7822.c...
ads7822.c(38): warning C316: unterminated conditionals
compiling display.c...
display.c(29): warning C316: unterminated conditionals
compiling motor_control.c...
motor_control.c(55): warning C316: unterminated conditionals
compiling main.c...
main.c(57): warning C316: unterminated conditionals
compiling motor.c...
motor.c(31): warning C316: unterminated conditionals
linking...
*** ERROR L104: MULTIPLE PUBLIC DEFINITIONS
SYMBOL: LEDWEI
MODULE: ads7822.obj (ADS7822)
*** ERROR L104: MULTIPLE PUBLIC DEFINITIONS
SYMBOL: LEDTABLE
MODULE: ads7822.obj (ADS7822)
*** ERROR L104: MULTIPLE PUBLIC DEFINITIONS
SYMBOL: LEDWEI
MODULE: display.obj (DISPLAY)
*** ERROR L104: MULTIPLE PUBLIC DEFINITIONS
SYMBOL: LEDTABLE
MODULE: display.obj (DISPLAY)
*** ERROR L104: MULTIPLE PUBLIC DEFINITIONS
SYMBOL: LEDWEI
MODULE: motor_control.obj (MOTOR_CONTROL)
*** ERROR L104: MULTIPLE PUBLIC DEFINITIONS
SYMBOL: LEDTABLE
MODULE: motor_control.obj (MOTOR_CONTROL)
*** ERROR L104: MULTIPLE PUBLIC DEFINITIONS
SYMBOL: LEDWEI
MODULE: main.obj (MAIN)
*** ERROR L104: MULTIPLE PUBLIC DEFINITIONS
SYMBOL: LEDTABLE
MODULE: main.obj (MAIN)
*** ERROR L104: MULTIPLE PUBLIC DEFINITIONS
SYMBOL: LEDWEI
MODULE: motor.obj (MOTOR)
*** ERROR L104: MULTIPLE PUBLIC DEFINITIONS
SYMBOL: LEDTABLE
MODULE: motor.obj (MOTOR)
*** WARNING L16: UNCALLED SEGMENT, IGNORED FOR OVERLAY PROCESS
SEGMENT: ?CO?DELAY
*** WARNING L16: UNCALLED SEGMENT, IGNORED FOR OVERLAY PROCESS
SEGMENT: ?CO?ADS7822
*** WARNING L16: UNCALLED SEGMENT, IGNORED FOR OVERLAY PROCESS
SEGMENT: ?CO?MOTOR_CONTROL
*** WARNING L16: UNCALLED SEGMENT, IGNORED FOR OVERLAY PROCESS
SEGMENT: ?CO?MAIN
*** WARNING L16: UNCALLED SEGMENT, IGNORED FOR OVERLAY PROCESS
SEGMENT: ?CO?MOTOR
Program Size: data=9.0 xdata=12 code=1734
Target not created
#define MAIN_C
#include"includes.h"
void main()
{
TMOD=0x01;//************定时器0方式1(16位)
TH0=(65536-10000)/256;
TL0=(65536-10000)%256;
EA=1;
ET0=1;
TR0=1;
// IT1=1;//-----------stop接int1,下降沿触发
// EX1=1;//-----------开中断
IT0=1;//-----------start接int0,下降沿触发
EX0=1;
// PX1=1;//------------设置外中断1的优先级高于T0
temp0=0x01;
delay_10us(5);
// CS1_0=0;
while(CS1_0==0)
{
while(1)
motor_control();
}
}
/*******************中断函数*******************************************/
void time0(void) interrupt 1
{
TR0=0; //进中断后先把定时器0中断关闭,防止内部程序过多而造成中断丢失
TH0=(65536-10000)/256;//10ms
TL0=(65536-10000)%256;
count++;
if(count==10)//count*10ms
{
count=0;
temp=ads7822();
delay_10us(5);
display(5,temp&0x0F);
display(6,temp>>4);
}
TR0=1;
}
void int1() interrupt 2//按下stop 关电机 外部1中断,下降沿触发
{
EX1=0;
CS1_0=1;
delayms(10);
EX1=1;
}
void int0() interrupt 0//按下start 开电机 外部0中断,下降沿触发
{
EX0=0;
CS1_0=0;
delayms(10);
rest6606();
EX0=1;
}
/******************以上主程序***********************/
下面是我的各个模块程序(我想要模块化写)
/------------*include.h---------------*/
#include<reg2051.h>
#include<intrins.h>
#include"main.h"
#include"motor.h"
#include"ads7822.h"
#include"delay.h"
#include"motor_control.h"
#include"display.h"
#include"IO.h"
/--------------main.h---------*/
#ifndef _MAIN_H
#define _MAIN_H
#ifdef MAIN_C
unsigned int count;
unsigned char temp,temp0;(我想在这定义全局变量)
unsigned char code ledtable[]={0xEE,0x28,0xCD,0x6D,0x2B,0x67,0xE7,0x2C,0xEF,0x6F,0xAF,0xE3,0xC1,0xE9,0xC7,0x87};
unsigned char code ledwei[]={0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8};//9个数码管的位选
#else
extern unsigned int count;
extern unsigned char temp,temp0;
extern unsigned char code ledtable[16]={0xEE,0x28,0xCD,0x6D,0x2B,0x67,0xE7,0x2C,0xEF,0x6F,0xAF,0xE3,0xC1,0xE9,0xC7,0x87};
extern unsigned char code ledwei[9]={0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8};//9个数码管的位选
#endif
#endif
/--------------motor.h-----------------------/
#ifndef _MOTOR_H_
#define _MOTOR_H_
#ifdef MOTOR_C
void rest6606();
void dianjigo1(unsigned int s,unsigned int fx,unsigned int BU);
#else
extern void rest6606();
extern void dianjigo1(unsigned int s,unsigned int fx,unsigned int BU);
#endif
#endif
/-------------ads7822.h-----------------/
#ifndef _ADS7822_H_
#define _ADS7822_H_
#ifdef ADS7822_C
ads7822();
#else
extern ads7822();
#endif
#endif
/-----------------delay.h-----------------/
#ifndef _DELAY_H_
#define _DELAY_H_
#ifdef DELAY_C
void delayms(unsigned int m);//m*1ms
void delay_10us(unsigned int i); //短延时 10us
#else
extern void delayms(unsigned int m);
extern void delay_10us(unsigned int i);
//#endif
#endif
/-----------motor-control.h-------------------/
#ifndef _MOTOR_CONTROL_H_
#define _MOTOR_CONTROL_H_
#ifdef MOTOR_CONTROL_C
void motor_control();
#else
extern void motor_control();
#endif
#endif
/--------------display.h------------------------/
#ifndef _DISPLAY_H_
#define _DISPLAY_H_
#ifdef DISPLAY_C
void diswritebyte(unsigned char wdata);
void display(unsigned char wei,unsigned char shu);
#else
extern void diswritebyte(unsigned char wdata);
extern void display(unsigned char wei,unsigned char shu);
#endif
//#endif
/----------------io.h-------------------/
#ifndef _IO_H_
#define _IO_H_
//#include<reg2051.h>
/*******ADS7822引脚*********************/
sbit AD_CK=P1^2;
sbit AD_DA=P1^1;
sbit AD_CS=P1^0;
/*********电机驱动STI6606引脚***********/
sbit RE=P3^1;
sbit F=P3^5;
sbit CW=P3^7;
/**********继电器引脚 0,开,1关***********/
sbit CS1_0=P3^0;
/*****************按键引脚********************/
sbit start=P3^2;
//sbit stop=P3^3;
/**************数码管显示驱动********/
sbit DIS_SCLK=P3^3;
sbit DIS_DIN=P3^2;
sbit DIS_CS=P3^4;//6932cs 低电平有效
#endif
/--------------display.c-------------------/
#define DISPLAY_C
#include "includes.h"
/********************显示设置************************/
void diswritebyte(unsigned char wdata)//写数据传送指令
{
unsigned char i;
DIS_CS=0; //开片选
_nop_();
for(i=0;i<8;i++) //CIK上升沿读,写数据
{
DIS_SCLK=0;
DIS_DIN=(bit)(wdata&0x01);
DIS_SCLK=1;
wdata>>=1;
}
}
void display(unsigned char wei,unsigned char shu)//选取数码管位 和应该显示的数
{
diswritebyte(0x9C);//固定地址显示 和亮度控制
DIS_CS=1;
diswritebyte(ledwei[wei-1]);//设置位选,wei=1.选择了第一个数码管的位选0
diswritebyte(ledtable[shu]);//显示数据,shu=0,1,2,3......18,依次代表0,1,2,3,4,5,6,7,8,9.a.b.c..d.e.f关,全亮P
DIS_CS=1;
}
/--------------delay.c----------------/
#define DELAY_C
#include "includes.h"
void delayms(unsigned int m)//m*1ms
{
unsigned int i,j;
for(i=m;i>0;i--)
for(j=125;j>0;j--);
}
void delay_10us(unsigned int i) //短延时 10us
{
while(i--);
}
/*-------------ads7822.c-------------------------/
#define ADS7822_C
#include"includes.h"
/************ADS7822 A/D转换函数,采集数据********************************************/
ads7822()
{
unsigned char k,i;
k=0;
AD_DA=1;//**********************准备接收数据
_nop_();
AD_CK=0;
_nop_();
AD_CS=0;
_nop_();
AD_CK=0;
_nop_();
AD_CK=1;
_nop_();
AD_CK=0;
_nop_();
AD_CK=1;
_nop_();
AD_CK=0;
_nop_();
AD_CK=1;
_nop_();//========================3个上升沿后,第四个跳变开始接收数据
for(i=0;i<8;i++)//********取高8位
{
AD_CK=0; //AD_CLK上升沿接收数据
_nop_();
AD_CK=1;
_nop_();
k=(k<<1)|AD_DA; //temp左移一位后再与刚读回来的那位数相与,把AD_DA最高位从左到右依次装入到temp中
_nop_();
}
AD_CS=1; //关片选,将8位转换值返回
return k;
}
/----------------motor.c---------------------------/
#define MOTOR_C
#include"includes.h"
/**********************电机控制******************************/
void rest6606()
{
CS1_0=0;
delayms(100);
RE=0;
F=0;
_nop_();
_nop_();
RE=1;
delayms(1);
F=0;
_nop_();
_nop_();
CW=0;
_nop_();
_nop_();
}
void dianjigo1(unsigned int s,unsigned int fx,unsigned int BU) // s 是延时时间的长短,控制转速,
{ // BU电机的步数,fx 转动方向
unsigned int i;
for(i=0;i<BU;i++)
{ F=0;
_nop_();
CW=fx;
delay_10us(s);
F=1;
}
}
/-----------------motor_control.c----------------/
#define MOTOR_CONTROL_C
#include"includes.h"
/*****************速度与方向控制*************************/
void motor_control()
{
unsigned char flag,flag1;
if(temp>temp0)//----------------如果电位器转动后采集的数据大于前一次采集的数据 正转
{ .
.
...
........
...........}
一周热门 更多>