终于调出来了,原来是延迟的问题。
程序的头文件
#include<reg52.h>
#include<intrins.h>
#include<math.h>
sbit CS=P1^0;
sbit SCK=P1^2;
sbit SID=P1^1;
sbit Key=P1^3;
sbit DQ = P2 ^ 7; //定义端口DQ
unsigned char code AC_TABLE[]={
0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,
0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,
0x88,0x89,0x8a,0x8b,0x8c,0x8d,0x8e,0x8f,
0x98,0x99,0x9a,0x9b,0x9c,0x9d,0x9e,0x9f,
};
void delay(unsigned int x)
{
while(x--);
}
void SendByte(unsigned char Dbyte)
{
unsigned char i;
for(i=0;i<8;i++)
{
SCK = 0;
Dbyte=Dbyte<<1;
SID = CY;
SCK = 1;
SCK = 0;
}
}
unsigned char ReceiveByte(void)
{
unsigned char i,temp1,temp2;
temp1=temp2=0;
for(i=0;i<8;i++)
{
temp1=temp1<<1;
SCK = 0;