中文字幕 另类精品,亚洲欧美一区二区蜜桃,日本在线精品视频免费,孩交精品乱子片免费

<sup id="3hn2b"></sup>

    1. <sub id="3hn2b"><ol id="3hn2b"></ol></sub><legend id="3hn2b"></legend>

      1. <xmp id="3hn2b"></xmp>

      2. 新聞中心

        EEPW首頁 > 嵌入式系統(tǒng) > 設(shè)計應(yīng)用 > 非同于MCU的獨(dú)立按鍵消抖動

        非同于MCU的獨(dú)立按鍵消抖動

        作者: 時間:2012-03-08 來源:網(wǎng)絡(luò) 收藏

        module key_scan

        #(

        parameter KEY_WIDTH = 2

        )

        (

        input clk, //50MHz

        input rst_n,

        input [KEY_WIDTH-1:0] key_data,

        output key_flag,

        output reg [KEY_WIDTH-1:0] key_value

        );

        //---------------------------------

        //escape the jitters

        reg [19:0] key_cnt; //scan counter

        reg [KEY_WIDTH-1:0] key_data_r;

        always @(posedge clk or negedge rst_n)

        begin

        if(!rst_n)

        begin

        key_data_r = {KEY_WIDTH{1'b1}};

        key_cnt = 0;

        end

        else

        begin

        key_data_r = key_data; //lock the key value

        if((key_data == key_data_r) (key_data != {KEY_WIDTH{1'b1}})) //20ms escape jitter

        begin

        if(key_cnt 20'hfffff)

        key_cnt = key_cnt + 1'b1;

        end

        else key_cnt = 0;

        end

        end

        wire cnt_flag = (key_cnt == 20'hffffe) ? 1'b1 : 1'b0;//!!

        //-----------------------------------

        //sure the key is pressed

        reg key_flag_r;

        always@(posedge clk or negedge rst_n)

        begin

        if(!rst_n)

        begin

        key_flag_r = 0;

        key_value = 0;

        end

        else if(cnt_flag)

        begin

        key_flag_r = 1;

        key_value = key_data; //locked the data

        end

        else //let go your hand

        key_flag_r = 0; //lock the key_value

        end

        //---------------------------------------

        //Capture the rising endge of the key_flag

        reg key_flag_r0,key_flag_r1;

        always@(posedge clk or negedge rst_n)

        begin

        if(!rst_n)

        begin

        key_flag_r0 = 0;

        key_flag_r1 = 0;

        end

        else

        begin

        key_flag_r0 = key_flag_r;

        key_flag_r1 = key_flag_r0;

        end

        end

        assign key_flag = ~key_flag_r1 key_flag_r0;

        endmodule


        上一頁 1 2 3 下一頁

        關(guān)鍵詞: 抖動 按鍵 獨(dú)立 MCU 同于

        評論


        相關(guān)推薦

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

        關(guān)閉