What is CAN?
CAN (Controller Area Network) is a standard protocol used for communication between electronic devices in vehicles. CAN filters are used to filter the messages received on the CAN bus, ensuring that only specific data frames are processed. In CAN communication, the configuration of filters is crucial for both performance and accurate message handling.
What is the Single Filter Mode in CAN?
Before using the ECAN-E02 module in Single Filter Mode, it’s important to understand what Single Filter Mode means. This mode refers to a filter configuration where only one filtering condition is set. In this mode, the CAN controller will filter incoming messages based on this single condition. Messages that meet the filter criteria will be accepted and passed to the application layer, while those that do not match will be discarded.
Key Features:
-
Simplicity: Single filter mode is typically simple and is suitable for scenarios where only one type of message is of interest.
-
Simple Filtering Rule: It only involves one filtering rule, which matches a specific identifier (ID), reducing the complexity for the application.
-
Moderate Performance Impact: Since only one filtering condition is applied, the performance impact is minimal, making this mode ideal for low-latency applications.
ECAN-E02 Single Filter Mode
Let’s first look at the ECAN-E02's Single Filter Mode UI interface.
-
CodeHigh represents bits 16-31, and CodeLow represents bits 0-15 of the identifier.
-
Similarly, MaskHigh represents bits 16-31, and MaskLow represents bits 0-15 of the identifier.
-
In the ECAN-E02 filter configuration interface, you can click directly on Code and Mask to configure the data. For example:
-
In the ST (Standard Frame) row, RTR represents Remote Transmission Request, and ID00-ID10 represents the 11-bit Standard Frame ID. DB1[0-7] and DB2[0-7] correspond to the first and second bytes of the data frame (from high to low, left to right, with "XX" indicating no configuration is required).
-
In the ET (Extended Frame) row, RTR represents Remote Transmission Request, and ID00-ID28 represents the 29-bit Extended Frame ID ("XX" means no configuration is needed).
After understanding the basic configuration, let's analyze the settings based on a test case.
Test Configuration:
To achieve the effect where the CodeHigh (Hex) is configured as 0x0020, CodeLow (Hex) as 0x0008, MaskHigh (Hex) as 0xFFCF, and MaskLow (Hex) as 0xFFF3, follow these steps:
-
Set the Code and Mask values accordingly, then save the parameters and restart the device.
-
Use a Network Debugging Assistant to connect to Channel 1 Server and a CAN Analyzer to connect to the Channel 1 CAN interface.
-
The Network Debugging Assistant will only receive Standard Data Frames with an odd ID and where the fourth bit of the second data byte is high (for example, data frame 00 08 00 00 00 00 00 00 can be received), and Extended Data Frames where the 17th bit of the ID is 0, and the 18th bit is 1 (for example, ID 50001 can be received).
Step-by-Step Analysis:
-
Standard Data Frame Filtering:
-
The ST DB2[3] corresponds to Code = 1 and Mask = 0, meaning that this bit must be high. The Mask forces this bit to match the Code value.
-
Therefore, only Standard Frames with odd IDs, where the fourth bit of the second data byte is high, will be accepted (for example, data 00 08 00 00 00 00 00 00 can be received).
-
Looking at the ST Code Mask rows, we can observe that the frame ID’s specific bits can be set to 1, meaning that any number with an odd ID will be accepted. So, only Standard Frames with odd IDs will be received.
-
Next, observe the DB (Data Byte) part:
-
Extended Data Frame Filtering:
-
The ET Code Mask rows show the 29-bit Extended Frame ID.
-
For the ID, the 00th bit must be 1, and for the 17th and 18th bits, the Mask must match: the 17th bit should be 0, and the 18th bit should be 1.
-
This configuration means only Extended Frames with odd IDs where the 17th bit is 0 and the 18th bit is 1 will be accepted (for example, ID 50001 can be received).
-
Now, look at the filtering for Extended Data Frames:
The ECAN-E02 Single Filter Mode allows precise filtering of CAN messages by configuring Code and Mask values. This functionality ensures that only relevant messages are passed to the application layer while irrelevant ones are discarded. By configuring the filter appropriately, you can ensure efficient message handling in systems that only need to process specific CAN frames. The ability to filter both Standard and Extended Frames based on ID and data byte values provides great flexibility for various automotive and industrial communication applications.