Use of STM32-CAN bus filter

Publisher:乐呵的挑Latest update time:2015-10-09 Source: eefocusKeywords:STM32 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
The shielding filter function of stm32 has requirements for ID. In STM32, ID must be shifted.
Compare the following table:
We set all to 1 here, that is, only accept the data of the node set in CAN_Filter
. STM32 has a total of 14 groups of filters to filter the received frames. Each group of filters includes 2 configurable 32-bit registers: CAN_FxR0 and CAN_FxR1. For the filter group, it can be configured as a shielding bit mode, so that CAN_FxR0 stores the identifier matching value, and CAN_FxR1 stores the shielding code, that is, if a bit in CAN_FxR1 is 1, the corresponding bit in CAN_FxR0 must match the corresponding bit in the identifier of the received frame to pass the filter; the bit in CAN_FxR1 is 0, which means that the corresponding bit in CAN_FxR0 does not need to match the received frame. The filter group can also be configured in the identifier list mode, in which case both CAN_FxR0 and CAN_FxR1 are the identifiers to be matched, and the identifier of the received frame must match one of them to pass the filter.
        Note: CAN_FilterIdHigh refers to the high 16 bits, and CAN_FilterIdLow is the low 16 bits. The frame to be obtained should be aligned with the filter setting value.
        For example:
        
CAN_FilterInitStructure.CAN_FilterNumber=0;                                                                             //First set of filters
CAN_FilterInitStructure.CAN_FilterMode=CAN_FilterMode_IdMask;                                        //Mask bit mode
CAN_FilterInitStructure.CAN_FilterScale=CAN_FilterScale_32bit;                                           //32-bit
CAN_FilterInitStructure.CAN_FilterIdHigh=(0x0635<<5);                                                           //Receive message with ID 635, 11-bit frame ID, standard frame is therefore shifted left by 5
CAN_FilterInitStructure.CAN_FilterIdLow=0x0000;
CAN_FilterInitStructure.CAN_FilterMaskIdHigh=0xffff;                                                                //
CAN_FilterInitStructure.CAN_FilterMaskIdLow=0xffff;
CAN_FilterInitStructure.CAN_FilterFIFOAssignment=CAN_FIFO0;                                         //First set of filters points to FIFO0
CAN_FilterInitStructure.CAN_FilterActivation=ENABLE;
CAN_FilterInit(&CAN_FilterInitStructure);
CAN_FilterInitStructure.CAN_FilterNumber=1;                                                                           //The second set of filters
CAN_FilterInitStructure.CAN_FilterIdHigh=(0x06DB<<5);                                                       //Receive messages with ID bit 6db
CAN_FilterInitStructure.CAN_FilterIdLow=0x0000;
CAN_FilterInitStructure.CAN_FilterMaskIdHigh=0xffff;
CAN_FilterInitStructure.CAN_FilterMaskIdLow=0xffff;
CAN_FilterInitStructure.CAN_FilterFIFOAssignment=CAN_FIFO1;                                     //The second set of filters points to FIFO1
CAN_FilterInit(&CAN_FilterInitStructure);
CAN_ITConfig(CAN_IT_FMP0,ENABLE);
CAN_ITConfig(CAN_IT_FMP1,ENABLE);
Keywords:STM32 Reference address:Use of STM32-CAN bus filter

Previous article:STM32 CAN filter settings
Next article:STM32 GPIO Application Notes

Recommended ReadingLatest update time:2024-11-16 21:20

STM32 IIC Difficulties and Errors
Let's go off topic first~ It's said on the Internet that the IIC of STM32F103 has defects! Just treat it as some shortcomings. Personally, I think it's definitely fine to use, but it's just not easy to use. People say that ST company considered patent issues and did not follow Philips' standards. As a result, the IIC
[Microcontroller]
STM32 IIC Difficulties and Errors
DMA configuration of STM32
DMA can be considered as connecting two "address" data channels. DMA shares the system bus and does not occupy the CPU, so it can achieve fast data transfer. Here we take DMA connection between memory (array) and serial port (USART1- DR) as an example.  1 void DMA_init(void)  2 {  4 RCC- AHBENR|=1 0; //Enable DMA1 c
[Microcontroller]
SMS short message sending and receiving system based on STM32
As a basic digital service provided by GSM network to users, Short Message Service (SMS) has become a communication means for remote monitoring in many fields. In many applications, the short message transceiver module is directly controlled by PC to complete the system data collection or remote information transmis
[Microcontroller]
SMS short message sending and receiving system based on STM32
STM32 USART serial port DMA receive and send mode
Serial port DMA sending: The process of sending data: If there is data to be sent in the foreground program, you need to do the following things 1. Place the data to be sent in the data sending buffer. Note: The first address of this data buffer must be written into the DMA configuration when the DMA is initialized. 2
[Microcontroller]
STM32 USART serial port DMA receive and send mode
STM32 learning serial port DMA data transmission and reception-Lincoln
    Preface: From the time I came into contact with microcontrollers to now, from PIC to STM32, I have never written any technical diary. Suddenly I feel very empty. Since I have learned technology, I should leave something behind. This is my first technical article in the technology industry. The purpose is to commun
[Microcontroller]
STM32 learning serial port DMA data transmission and reception-Lincoln
STM32 general timer input capture mode
#include "stm32f10x.h" /*RCC clock configuration*/ void RCC_config() {   ErrorStatus HSEStartUpStatus;  /* RCC registers are set to default configuration */  RCC_DeInit();  /* Turn on external high speed clock */  RCC_HSEConfig(RCC_HSE_ON);  /* Wait for the external high-speed clock to stabilize*/  HSEStartUpStatu
[Microcontroller]
STM32 - SystemInit trap during simulation debugging
STM32 - SystemInit trap during simulation debugging When I started the simulation debugging of STM32, I encountered a problem. During debugging, the program kept stopping in the waiting crystal oscillator in SystemInit() and could not get out. The code in the first part of SystemInit() can be executed, but the pr
[Microcontroller]
STM32 - SystemInit trap during simulation debugging
STM32 first demo and software settings
The software version used is: Keil MDK4.12 MCU model: STM32F103C8T6 STM32 first demo 1. Create a folder GPIO_TEST stores the entire project, and creates subfolders under the project folder to store files of different categories. Obj: Stores project files Out: stores compiled output files Sorce: Store source co
[Microcontroller]
STM32 first demo and software settings
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号