#include <reg52.h>
#include <intrins.h>
sbit SCLK=P3^6;
sbit IO =P3^4;
sbit RST =P3^5;
sbit FLAG=P3^3;
void delay500ms(unsigned ms)
{unsigned char i;
while(ms--) //每一次循环1ms
{for(i = 0;i < 120;i++);}
}
void write8bit(unsigned char wri)
{unsigned char i;
for(i=0;i<8;i++)
{SCLK=0;
_nop_();
_nop_();
_nop_();
if((wri&&0x001)==0x001)
IO=1;
elseIO=0;
wri>>=1;
SCLK=1;
_nop_();
_nop_();
_nop_();}
}
unsigned char read8bit()
{unsigned char i,result=0x00;
for(i=0;i<8;i++)
{SCLK=1;
_nop_();
_nop_();
_nop_();
SCLK=0;
_nop_();
_nop_();
_nop_();
if(IO==1)result|=0x80;
elseresult|=0x00;
result>>=1;}
return result;
}
void main()
{FLAG=0;
RST=0;
_nop_();
_nop_();
_nop_();
_nop_();
_nop_();
RST=1;
_nop_();
_nop_();
_nop_();
_nop_();
_nop_(); //FLAG=1;write8bit(0x8d);
FLAG=1;
P2=read8bit();
_nop_();
_nop_();
_nop_();
_nop_();
_nop_();
RST=0;
delayms(500);
P2=0;
}
哪个大侠帮我帮我看看,我程序有问题吗?为什么我总得不出正确的结果啊。。。
#include <intrins.h>
sbit SCLK=P3^6;
sbit IO =P3^4;
sbit RST =P3^5;
sbit FLAG=P3^3;
void delay500ms(unsigned ms)
{unsigned char i;
while(ms--) //每一次循环1ms
{for(i = 0;i < 120;i++);}
}
void write8bit(unsigned char wri)
{unsigned char i;
for(i=0;i<8;i++)
{SCLK=0;
_nop_();
_nop_();
_nop_();
if((wri&&0x001)==0x001)
IO=1;
elseIO=0;
wri>>=1;
SCLK=1;
_nop_();
_nop_();
_nop_();}
}
unsigned char read8bit()
{unsigned char i,result=0x00;
for(i=0;i<8;i++)
{SCLK=1;
_nop_();
_nop_();
_nop_();
SCLK=0;
_nop_();
_nop_();
_nop_();
if(IO==1)result|=0x80;
elseresult|=0x00;
result>>=1;}
return result;
}
void main()
{FLAG=0;
RST=0;
_nop_();
_nop_();
_nop_();
_nop_();
_nop_();
RST=1;
_nop_();
_nop_();
_nop_();
_nop_();
_nop_(); //FLAG=1;write8bit(0x8d);
FLAG=1;
P2=read8bit();
_nop_();
_nop_();
_nop_();
_nop_();
_nop_();
RST=0;
delayms(500);
P2=0;
}
哪个大侠帮我帮我看看,我程序有问题吗?为什么我总得不出正确的结果啊。。。