#include "reg52.h"
#include "intrins.h"
#define FOSC 29837000L
#define BAUD 9600
typedef unsigned char BYTE;
typedef unsigned int WORD;
sfr ADC_CONTR = 0xBC;
sfr ADC_RES = 0xBD;
sfr ADC_LOW2 = 0xBE;
sfr P1ASF = 0x9D;
#define ADC_POWER 0x80;
#define ADC_FLAG 0x10;
#define ADC_START 0x08;
#define ADC_SPEEDLL 0x00;
#define ADC_SPEEDL 0x20;
#define ADC_SPEEDH 0x40;
#define ADC_SPEEDHH 0x60;
void InitUart();
void SendData(BYTE dat);
void Delay(WORD n);
void InitADC();
BYTE ch=0;
void main()
{
InitUart();
InitADC();
IE=0xa0;
while(1);
}
void adc_isr()interrupt 5 using 1
{
ADC_CONTR&=!ADC_FLAG;
SendData(ch);
SendData(ADC_RES);
if(++ch>7)ch=0;
ADC_CONTR=ADC_POWER|ADC_SPEEDLL|ADC_START|ch;
}
void InitADC()
{
P1ASF=0xff;
ADC_RES=0;
ADC_CONTR = ADC_POWER|ADC_SPEEDLL|ADC_START|ch;
Delay(2);
}
void InitUart()
{
SCON=0x5a;
TMOD=0x20;
TH1=TL1=-(FOSC/12/32/BAUD);
TR1=1;
}
void SendData(BYTE dat)
{
while(!
ti);
TI=0;
SBUF=dat;
}
void Delay(WORD n)
{
WORD X;
while(n--)
{
x=5000;
while(x--);
}
}
下面是提示的错误!
Rebuild target 'Target 1'compiling 角度传感器.plg.c...角度传感器.plg.c(10): error C231: 'ADC_CONTR': redefinition角度传感器.plg.c(11): error C231: 'ADC_RES': redefinition角度传感器.plg.c(13): error C231: 'P1ASF': redefinition角度传感器.plg.c(45): error C141: syntax error near '|'角度传感器.plg.c(45): error C141: syntax error near '|'角度传感器.plg.c(45): error C141: syntax error near '|'角度传感器.plg.c(53): error C141: syntax error near '|'角度传感器.plg.c(53): error C141: syntax error near '|'角度传感器.plg.c(53): error C141: syntax error near '|'角度传感器.plg.c(77): error C202: 'x': undefined identifier角度传感器.plg.c(78): error C202: 'x': undefined identifierTarget not created
然后再由简入繁
我注释过了,又会提示其他的错误!而且错误更多了!我很郁闷!
谢谢了!我已经找到问题了!前面定义的常量多加了分号!
一周热门 更多>