在线看毛片网站电影-亚洲国产欧美日韩精品一区二区三区,国产欧美乱夫不卡无乱码,国产精品欧美久久久天天影视,精品一区二区三区视频在线观看,亚洲国产精品人成乱码天天看,日韩久久久一区,91精品国产91免费

<menu id="6qfwx"><li id="6qfwx"></li></menu>
    1. <menu id="6qfwx"><dl id="6qfwx"></dl></menu>

      <label id="6qfwx"><ol id="6qfwx"></ol></label><menu id="6qfwx"></menu><object id="6qfwx"><strike id="6qfwx"><noscript id="6qfwx"></noscript></strike></object>
        1. <center id="6qfwx"><dl id="6qfwx"></dl></center>

            新聞中心

            EEPW首頁 > 嵌入式系統(tǒng) > 設計應用 > 51單片機與RC500射頻

            51單片機與RC500射頻

            作者: 時間:2016-11-26 來源:網絡 收藏


            char PcdRequest(uchar req_code)
            {
            char status;
            idata struct TranSciveBuffer MfComData;
            struct TranSciveBuffer *pi;
            pi=&MfComData;
            PcdSetTmo(106);
            PcdAntennaOn();
            WriteRC(RegChannelRedundancy,0x03);
            ClearBitMask(RegControl,0x08);//Crypto1on=0
            WriteRC(RegBitFraming,0x07);
            MfComData.MfCommand=PCD_TRANSCEIVE;
            MfComData.MfLength=1;
            MfComData.MfData[0]=req_code;
            status=PcdComTransceive(pi);
            if(!status)
            {
            if(MfComData.MfLength!=0x10)
            {
            status=MI_BITCOUNTERR;
            }
            }
            return status;
            }

            uchar PiccCascAnticoll(uchar *snr)//這個指針變量沒有用,但少了就會報錯
            {
            uchar i;
            uchar snr_check=0;
            char status=MI_OK;
            idata struct TranSciveBuffer MfComData;
            struct TranSciveBuffer *pi;
            pi=&MfComData;
            PcdAntennaOn();
            PcdSetTmo(106);//設置定時器
            WriteRC(RegDecoderControl,0x28);//設置碰撞后接收的所有位都用0表示
            ClearBitMask(RegControl,0x08);//Crypto1=0
            WriteRC(RegChannelRedundancy,0x03);//使能奇校驗
            MfComData.MfCommand=PCD_TRANSCEIVE;//發(fā)送接收命令
            MfComData.MfLength=2;//發(fā)送兩個字節(jié)
            MfComData.MfData[0]=PICC_ANTICOLL1;//PICC_ANTICOLL1=93H,PiCC反碰撞指令
            MfComData.MfData[1]=0x20;//反碰撞還需要在發(fā)送一個20H,即想picc發(fā)送兩個字節(jié)
            status=PcdComTransceive(pi);//PcdComTransceive函數將Mfdate中的數據發(fā)送給Picc
            if(!status)//表示執(zhí)行命令沒出錯
            {

            for(i=0;i<4;i++)//執(zhí)行命令后返回的前4個字節(jié)
            {
            snr_check^=MfComData.MfData[i];//接收到的前四個字節(jié)按位異或存入snr_check中
            }
            if(snr_check!=MfComData.MfData[i])//判斷所接收序列號是否正確
            {
            status=MI_SERNRERR;//接收到的5個字節(jié)出錯
            }
            else
            {
            for(i=0;i<5;i++)
            {
            *(snr+i)=MfComData.MfData[i];
            }
            }

            }
            ClearBitMask(RegDecoderControl,0x20);
            return status;
            }

            char PcdSelect(uchar *snr,uchar *sar)
            {
            uchar i;
            char status;
            uchar snr_check=0;
            idata struct TranSciveBuffer{uchar MfCommand;
            uchar MfLength;
            uchar MfData[7];
            }MfComData;
            struct TranSciveBuffer *pi;

            本文引用地址:http://www.biyoush.com/article/201611/321654.htm

            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個字節(jié)
            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);
            }


            上一頁 1 2 下一頁

            關鍵詞: 51單片機RC500射

            評論


            技術專區(qū)

            關閉