新聞中心

        EEPW首頁 > 嵌入式系統 > 設計應用 > STM32 CAN濾波器設置 Identifier filter

        STM32 CAN濾波器設置 Identifier filter

        作者: 時間:2016-11-13 來源:網絡 收藏
        stm32的屏蔽濾波功能對ID是有要求的,mpc2515你可以直接寫ID,但在STM32 這里ID必須進行移位處理.

        對照下表:

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

        Extended Id濾波器設置(已驗證,只接受Receive_ID節點的數據):

        /* CAN filter init */ //設置成只能接受主節點 Extended Id:01 的數據 reference manual p557
        CAN_FilterInitStructure.CAN_FilterNumber=0;
        CAN_FilterInitStructure.CAN_FilterMode=CAN_FilterMode_IdMask;
        //CAN_FilterInitStructure.CAN_FilterMode=CAN_FilterMode_IdList;//###########################################
        CAN_FilterInitStructure.CAN_FilterScale=CAN_FilterScale_32bit;
        CAN_FilterInitStructure.CAN_FilterIdHigh=(((u32)Receive_ID<<3)&0xFFFF0000)>>16;
        CAN_FilterInitStructure.CAN_FilterIdLow=(((u32)Receive_ID<<3)|CAN_ID_EXT|CAN_RTR_DATA)&0xFFFF;
        CAN_FilterInitStructure.CAN_FilterMaskIdHigh=0xFFFF;
        CAN_FilterInitStructure.CAN_FilterMaskIdLow=0xFFFF; // 1 :must match” or 0: as “don’t care
        CAN_FilterInitStructure.CAN_FilterFIFOAssignment=0;
        CAN_FilterInitStructure.CAN_FilterActivation=ENABLE;
        CAN_FilterInit(&CAN_FilterInitStructure);

        Standard Id濾波器設置:

        CAN_FilterMaskId 位的含義是

        Mask
        Each bit of the register specifies whether the bit of the associated identifier register must
        match with the corresponding bit of the expected identifier or not.
        0: Don’t care, the bit is not used for the comparison
        1: Must match, the bit of the incoming identifier must have the same level has specified in
        the corresponding identifier register of the filter.

        我們這里全部設置成1 ,也就是只接受CAN_Filter中設置的節點的數據



        關鍵詞: STM32CAN濾波器設

        評論


        技術專區

        關閉
        主站蜘蛛池模板: 安丘市| 启东市| 多伦县| 汝城县| 肇东市| 梅河口市| 湘潭县| 金昌市| 化隆| 中卫市| 思南县| 乳源| 盱眙县| 龙里县| 镇原县| 咸阳市| 贺州市| 民乐县| 纳雍县| 余庆县| 泗水县| 江西省| 商水县| 泗洪县| 张掖市| 民勤县| 通江县| 铁岭市| 靖宇县| 宜兰县| 大荔县| 金湖县| 清新县| 岢岚县| 连州市| 定日县| 东乡| 中西区| 抚顺市| 宜昌市| 柘城县|