新聞中心

        EEPW首頁 > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > 如何利用stm32的中斷和計(jì)數(shù)器即上升沿下降沿捕獲電平時長

        如何利用stm32的中斷和計(jì)數(shù)器即上升沿下降沿捕獲電平時長

        作者: 時間:2016-11-27 來源:網(wǎng)絡(luò) 收藏

        /*! @file
        ********************************************************************************


        模塊名 : 紅外解碼文件
        文件名 : IR_REMOTE.c
        相關(guān)文件 : IR_REMOTE.h
        文件實(shí)現(xiàn)功能 : 定時器紅外解碼
        作者 : 李

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

        版本 :
        --------------------------------------------------------------------------------
        硬件平臺 : STM32F107
        軟件開發(fā)平臺 : iar
        --------------------------------------------------------------------------------
        修改記錄 : 2015-8-17 建立
        日 期 版本 修改人 修改內(nèi)容
        2015/8/17 0.1 創(chuàng)建

        ********************************************************************************
        *******************************************************************************/
        //該類遙控器的引導(dǎo)碼為4MS 高電平 4MS低電平,bit1為2ms H,bit0為0.5ms L


        #include "IRM_Remote.h"
        #include

        static u8 user_code[3]={0};//用戶碼
        static u8 lead_flg=0;//引導(dǎo)碼狀態(tài)變量
        static u8 ir_cnt;//定時器電平時間計(jì)數(shù)量
        static u8 high_cnt=0;//24位
        static u8 REM_FLG=0;//接收一個碼標(biāo)志位
        static u8 Remote_Scan();
        /*************************************************************
        名稱: Remote_Key()
        功能:遙控碼值轉(zhuǎn)換
        輸出參數(shù):返回鍵值 重新編碼
        作者:v
        ******************************************************************/
        u8 Remote_Key()
        {
        u16 keyvalue=0;
        u8 ret=0;
        //Remote_Scan();
        if(REM_FLG==1)
        {
        REM_FLG=0;
        keyvalue=user_code[1]*256+user_code[2];
        switch(keyvalue)
        {
        case IR_1:
        ret = 1;
        break;

        case IR_2:
        ret = 2;
        break;

        case IR_3:
        ret = 3;
        break;

        case IR_4:
        ret = 4;
        break;

        case IR_5:
        ret = 5;
        break;

        case IR_6:
        ret = 6;
        break;

        case IR_7:
        ret = 7;
        break;

        case IR_8:
        ret = 8;
        break;

        case IR_9:
        ret = 9;
        break;

        case IR_10:
        ret = 10;
        break;

        case IR_11:
        ret = 11;
        break;

        case IR_12:
        ret = 12;
        break;

        case IR_13:
        ret = 13;
        break;

        case IR_14:
        ret = 14;
        break;

        case IR_15:
        ret = 15;
        break;

        case IR_16:
        ret = 16;
        break;

        case IR_17:
        ret = 17;
        break;


        case IR_18:
        ret = 18;
        break;

        case IR_19:
        ret = 19;
        break;

        case IR_20:
        ret = 20;
        break;

        case IR_21:
        ret = 21;
        break;

        case IR_22:
        ret = 22;
        break;

        case IR_23:
        ret = 23;
        break;

        case IR_24:
        ret = 24;
        break;

        case IR_25:
        ret = 25;
        break;

        case IR_26:
        ret = 26;
        break;

        case IR_27:
        ret = 27;
        break;

        case IR_28:
        ret = 28;
        break;

        case IR_29:
        ret = 29;
        break;

        case IR_30:
        ret = 30;
        break;

        case IR_31:
        ret = 31;
        break;

        case IR_32:
        ret = 32;
        break;

        case IR_33:
        ret = 33;
        break;


        case IR_34:
        ret = 34;
        break;

        case IR_35:
        ret = 35;
        break;

        case IR_36:
        ret = 36;
        break;

        case IR_37:
        ret = 37;
        break;
        default:
        ret=0;
        break;
        }
        return ret;
        }
        return ret;
        }


        上一頁 1 2 下一頁

        評論


        技術(shù)專區(qū)

        關(guān)閉
        主站蜘蛛池模板: 交口县| 石屏县| 朝阳区| 平湖市| 陵水| 陇西县| 石家庄市| 枝江市| 雅安市| 习水县| 出国| 兴隆县| 闵行区| 萨嘎县| 泽普县| 喀什市| 新津县| 雅江县| 阳西县| 浦城县| 科技| 平昌县| 邵武市| 佛教| 卫辉市| 高平市| 马关县| 江永县| 竹北市| 武汉市| 汉中市| 金坛市| 麻城市| 镇原县| 库伦旗| 开鲁县| 松江区| 大庆市| 武宁县| 浦东新区| 池州市|