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

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

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

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

      2. 新聞中心

        STM32中CAN錯誤中斷1

        作者: 時間:2016-11-24 來源:網(wǎng)絡(luò) 收藏
        void can_signal(void)
        {
        unsigned char data can_irq;
        unsigned char data temp;
        x_wdgtime();
        can_irq = InterruptReg;
        if(can_irq&ALI_Bit)
        { // 仲裁丟失位
        ++al_counter;
        temp=ArbLostCapReg; // 讀仲裁丟失寄存器
        alc_current=temp&0x1F; // 獲得當(dāng)前仲裁丟失的位置
        }
        if(can_irq & BEI_Bit)
        { // 總線錯誤中斷
        temp=ErrCodeCapReg;
        buse_current=temp&0x3F;
        temp=temp&0xD0; // 獲得總線錯誤的類型
        switch (temp)
        {
        case 0x00: ++bite_counter;
        case 0x40: ++forme_counter;
        case 0x80: ++stuffe_counter;
        case 0xd0: ++othere_counter;
        }
        }
        if(can_irq & EPI_Bit)
        { // 消極錯誤中斷,
        // 接收或發(fā)送錯誤計數(shù)超過127時,錯誤狀態(tài)變?yōu)楸粍渝e誤
        if((RxErrCountReg>127)||(TxErrCountReg>127)) errstatus_current=ERR_PASSIVE;
        // 接收或發(fā)送錯誤計數(shù)回到小于127時,錯誤狀態(tài)變?yōu)橹鲃渝e誤
        if((RxErrCountReg<127)&&(TxErrCountReg<127)) errstatus_current=ERR_ACTIVE;
        }
        if(can_irq & DOI_Bit)
        { // data overflow
        CommandReg = (CDO_Bit|RRB_Bit);
        return;
        }
        if(can_irq&EI_Bit)
        { // 錯誤報警中斷, 這里只對總線關(guān)閉錯誤做處理
        if(StatusReg&BS_Bit)
        { // 檢測狀態(tài)寄存器的總線狀態(tài)位
        ++busoff_counter;
        ModeControlReg = 0x00;
        return;
        }
        }
        if(can_irq & RI_Bit)
        { // 接收數(shù)據(jù)中斷
        if(StatusReg & DOS_Bit)
        {
        CommandReg = (CDO_Bit|RRB_Bit);
        return;
        }
        can_readmsg();
        return;
        }
        return;
        }



        關(guān)鍵詞: STM32CAN錯誤中

        評論


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

        關(guān)閉