新聞中心

        EEPW首頁 > 嵌入式系統 > 設計應用 > PIC單片機紅外遙控編碼與解碼的問題分析

        PIC單片機紅外遙控編碼與解碼的問題分析

        作者: 時間:2012-09-02 來源:網絡 收藏

        本文引用地址:http://www.104case.com/article/170942.htm

        相應的C代碼如下:

        unsigned char rfcount,
        loop,
        rftime,//查詢定時器
        k;
        bit rfbit, //接收完標制
        lowbit1,
        lowbit2,
        downbit,
        rfgobit;
        unsigned char dispcount[5];//結果
        #define rfin RC6
        ////////////////////////////////////////////////////////////////////////////////
        rf( )//接收
        {
        if(rfbit==0)
        {
        if((lowbit1==0)(rfin==0))
        {
        downbit=1;
        rftime=0;
        lowbit1=1;
        return;
        }
        if((lowbit1==1)(rfin==1))
        {
        lowbit2=1;
        return;
        }
        if((lowbit1==1)(lowbit2==1)(RC6==0))
        {
        lowbit1=0;
        lowbit2=0;
        if((rftime>=40)(downbit==1))//接收;
        {
        rfgobit=1;
        loop=0;
        rfcount=0;
        k=1;
        rftime=0;
        return;
        }
        rfcount=rfcount+1;
        loop=loop+1;
        if(rfcount>=31)
        {
        rfgobit=0;
        downbit=0;
        rfcount=0;
        rfbit=1;
        loop=0;
        return;
        }
        if((rftime>=7)(rfgobit==1))
        {
        dispcount[k]=dispcount[k]|0x80;
        rftime=0;
        if(loop==8)
        {
        k=k+1;
        loop=0;
        return;
        }
        dispcount[k]=dispcount[k]>>1;
        return;
        }
        if((rftime5)(rfgobit==1))
        {
        dispcount[k]=dispcount[k]0x7f;
        rftime=0;
        if(loop==8)
        {
        k=k+1;
        loop=0;
        return;
        }
        dispcount[k]=dispcount[k]>>1;
        return;
        }
        }
        }
        }

        (查詢子程序同匯編)

        紅外遙控器相關文章:紅外遙控器原理


        評論


        相關推薦

        技術專區

        關閉
        主站蜘蛛池模板: 平遥县| 平陆县| 宜君县| 廉江市| 美姑县| 建宁县| 吴旗县| 巴彦县| 九江县| 宜昌市| 册亨县| 达州市| 和平区| 元氏县| 晋州市| 黎城县| 竹北市| 图片| 贡山| 富平县| 余干县| 涟水县| 温泉县| 小金县| 遂昌县| 丰原市| 泰和县| 泗水县| 南郑县| 赣榆县| 和政县| 郁南县| 临漳县| 晋江市| 威信县| 西贡区| 黑龙江省| 甘孜| 宜丰县| 长沙市| 昂仁县|