#include<reg52.h>
#include<intrins.h>
#define uint unsigned int;
#define uchar unsigned char;
uchar dat,i,cmd,temp,num;
uint AD_Value;
uint x,y,z;
uchar code table[]={
0x3f,0x06,0x5b,0x4f,
0x66,0x6d,0x7d,0x07,
0x7f,0x6f,0x77,0x7c,
0x39,0x5e,0x79,0x71};
sbit wela=P2^6;
sbit dula=P2^7;
sbit DOUT = P3 ^ 7;
sbit CLK = P3 ^ 6;
sbit DIN = P3 ^ 4;
sbit CS = P3 ^ 5;
void delay(uint);
void SPI_Write();
uint SP_Read() ;
uint Read_AD_Data();
void main()
{ while(1)
{
SP_Read();
SPI_Write(dat);
Read_AD_Data(cmd);
temp=0xfe;
P1=temp;
dula=1;
P0=table[AD_Value];
dula=0;
wela=1;
P0=0xc0;
wela=0;
num=1;
delay(10);
temp=_crol_(temp,1);
P1=temp;
delay(100);
}
}
void delay(uint z)
{ uint x,y;
for(x=z;x>0;x--){
for(y=110;y>0;y--){};
};
}
void SPI_Write(uchar dat)
{
uchar i;
CLK = 0;
for(i=0; i<8; i++)
{
DIN = dat >> 7;
dat <<= 1;
CLK = 0;
CLK = 1;
}
}
uint SP_Read(void)
{
uint i, dat = 0;
CLK = 0;
for(i = 0; i < 12; i++)
{
dat <<= 1;
CLK = 1;
CLK = 0;
dat |= DOUT;
}
return dat;
}
uint Read_AD_Data(uchar cmd)
{
CLK = 0;
CS = 0;
SPI_Write(cmd);
for(i = 6; i > 0; i--);
CLK = 1;
_nop_();
_nop_();
CLK = 0;
_nop_();
_nop_();
AD_Value = SPI_Read();
CS = 1;
return AD_Value;
}
耽误各位时间了真的抱歉,我就是想用xpt2046做一个简单的温度测试装置....读了芯片资料,看了时序图,写了这个东西....但是
Build target 'Target 1'
compiling 温控2.0.c...
温控2.0.C(19): error C141: syntax error near ';'
温控2.0.C(47): error C141: syntax error near ';'
温控2.0.C(53): error C141: syntax error near ';'
温控2.0.C(83): error C141: syntax error near ';'
Target not created
可以帮我看看哪儿有问题吗。。。main函数先不管也行,那个ad操作有问题吗QAQ
|