pi=&MfComData;
PcdSetTmo(106);
WriteRC(RegChannelRedundancy,0x0F);
ClearBitMask(RegControl,0x08);
MfComData.MfCommand=PCD_TRANSCEIVE;
MfComData.MfLength=7;
MfComData.MfData[0]=PICC_ANTICOLL1;
MfComData.MfData[1]=0x70;
for(i=0;i<4;i++)
{
snr_check^=*(snr+i);
MfComData.MfData[i+2]=*(snr+i);
}
MfComData.MfData[6]=snr_check;//select要传7个字节
status=PcdComTransceive(pi);
if(status==MI_OK)
{if(MfComData.MfLength!=0x8)
{
status = MI_BITCOUNTERR;
}
*sar=MfComData.MfData[0];
}
return status;
}
void init()
{
delay(500);
RC500CS=1;//这个位定义在rc500文件里
RC500RST=1;
delay(100);
RC500RST=0;
TMOD=0x20;//串口通讯的设置,采用9600波特率
TH1=0xfd;
TL1=0xfd;
TR1=1;
SCON=0x52;
PCON&=0x7f;
TI=0;
delay(10);//这个延时很重要,否则会写不进数据到RC500
}
void main()
{
uchar i,a[5],b[5],status,*snr,c;//传递数组的首地址可以,传递指针必须初始化,且每个指针都要知道指向的地址,所以传递数组比较好
snr=&c;
init();
PcdRequest(PICC_REQALL);
PiccCascAnticoll(a);
for(i=0;i<5;i++)
{
b[i]=a[i];
SBUF=b[i];
while(!TI);
TI=0;
}
status=PcdSelect(b,snr);
SBUF=status;
while(!TI);
TI=0;
SBUF=*snr;
while(!TI);
TI=0;
while(1);
}