CAN bus controller system capable of dynamically managing filter SRAM
The CAN bus controller system that dynamically manages the filter SRAM solves the problems of resource waste and application inconvenience in the existing technology, realizes resource sharing and flexible allocation of multiple CAN bus controllers, and reduces the system area and power consumption. .
Patent Information
- Application Number
- CN202410868351.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-01
- Publication Date
- 2024-09-06
Smart Images

Figure CN118612010A
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of CAN bus, and in particular to a CAN bus controller system capable of dynamically managing a filter SRAM. Background Art
[0002] CAN (Controller Area Network) is currently an ISO internationally standardized serial communication protocol and one of the most widely used open fieldbuses in the world. It was originally designed by Bosch of Germany and used for automobile monitoring and control. Later, as a variety of serial communication buses, CAN bus has played an increasingly important role in the fields of computers, communication networks, intelligent sensor technology, and industrial control due to its advantages such as low cost, high reliability, and remote request. At present, the development is mainly aimed at the CAN2.0 protocol, but with the demand for the communication rate of the CAN bus, the development of FDCAN has also received more and more attention. FDCAN (CAN with Flexible Data rate) is an upgraded version of the CAN bus. It inherits the main characteristics of CAN and makes up for the limitations of CAN data length and bandwidth.
[0003] There are many existing technologies involving CAN bus, such as "Dual Redundant CAN Bus Controller and Message Processing Method Thereof" with Patent No. 20081010106353.4, "CAN Bus HUB Board" with Patent No. 201620798479.2, and "CAN Bus Network Control Method and CAN Bus Network" with Patent No. 201710586911.0. These have studied two or more CAN bus controllers, but these controllers are all CAN2.0 bus controllers, not FDCAN bus controllers, and the acceptance filters are all default built-in registers, and do not involve improvements to the shared acceptance filter SRAM.
[0004] like Figure 1 As shown in the figure, the acceptance filters of conventional CAN bus controllers are all default built-in registers. The ID and mask are configured externally through the configuration registers. Only limited specific messages can be filtered and received each time. When you want to receive other messages, you need to reconfigure. In a redundant CAN bus controller system, each CAN bus controller uses its own acceptance filter to implement message filtering. Figure 8 The conventional CAN bus controller system communication process is shown. Its filter initialization includes configuring the ID filter mode register and writing a set of ID reference values and masks into the corresponding register. During the communication process, only this set of IDs and masks and their corresponding modes can be used for filtering.
[0005] In the actual application scenario of redundant CAN bus controllers, several CAN bus controllers may expect to filter the same messages. In this case, sharing the filter SRAM can save more resources than using the filter registers exclusively for the CAN bus controllers. It is also possible that different CAN bus controllers expect different numbers of IDs to be filtered, or some CANs do not work, so there is no need to configure filters. If each CAN bus controller is allocated a fixed capacity, it will cause problems such as waste of resources and inconvenience in application. Summary of the invention
[0006] Based on the above problems, the purpose of the present invention is to realize dynamic management of acceptance filter SRAM and allocate it to multiple CAN bus controllers. SRAM space can be allocated according to demand, thereby fully utilizing the SRAM space, reducing system area and power consumption, and avoiding resource waste.
[0007] The technical solution adopted by the present invention to achieve its invention object is a CAN bus controller system capable of dynamically managing filter SRAM, comprising an interface management module, an acceptance filter control module, an acceptance filter SRAM, a bus controller initialization module and n CAN bus controllers, wherein:
[0008] The interface management module is used to initialize the CAN bus controller through the CAN bus controller initialization module, and to initialize the acceptance filter through the acceptance filter control module, and to configure the internal register according to the corresponding address, data, and control signal by controlling the external input signal;
[0009] The acceptance filter control module is used to control the allocation of the acceptance filter SRAM according to the external configuration, and compare the data of the acceptance filter SRAM with the received ID and the contents of IDE, RTR, EDL, and FDF to determine whether to receive the message; the acceptance filter control module is also connected to the CAN bus controller;
[0010] The acceptance filter SRAM is used to store the externally configured ID for filtering, i.e., the filtering reference value and the filtering mask;
[0011] The CAN bus controller initialization module is connected to the CAN bus controller and is used to complete the initialization of the CAN bus controller according to the external configuration;
[0012] The CAN bus controller is a standard CAN bus controller or an FDCAN bus controller, and the maximum value of n is 32.
[0013] Further, the CAN bus controller includes a transmit buffer, a receive FIFO, a bit stream processor, and a bit timing logic, wherein:
[0014] The sending buffer is used to store externally written frame messages to be sent;
[0015] The receiving FIFO is used to store messages received from the CAN bus and passed the acceptance filter;
[0016] The bit stream processor is used to control the data flow between the sending buffer, the receiving FIFO and the CAN bus; when the CAN bus controller is in the sending mode, when the sending request is set, the sending buffer frame message is sent according to the frame format of the CAN standard; when the CAN bus controller is in the receiving mode, the message is received from the CAN bus, and the frame ID is sent to the acceptance filter controller, and when the acceptance filter indicates that the filter has passed, the received message is sent to the receiving FIFO for storage;
[0017] The bit timing logic is used for monitoring the CAN bus and processing the bit timing related to the CAN bus.
[0018] Furthermore, the acceptance filter control module includes a filter start group register, a filter mode register, and a filter processing unit, wherein:
[0019] The filter start group register is used to realize the allocation of the acceptance filter SRAM according to the start filter group of each CAN bus controller configured externally;
[0020] The filter mode register is 32 bits, and each bit controls the filter mode of each group of filters, which is divided into ID complete match filter mode or ID mask filter mode according to the external configuration mode;
[0021] The filtering processing unit is used to compare the data in the acceptance filter SRAM with the received ID and the contents of IDE, RTR, EDL and FDF to determine whether to receive the message.
[0022] As a further preferred solution, the filter start group register can be configured externally to have the same value or different values for the start addresses of different CAN bus controllers according to requirements;
[0023] If different CAN bus controllers expect to filter the same message, they are configured with the same value to achieve SRAM data sharing;
[0024] If different CAN bus controllers are expected to filter different messages, they are configured with different values to achieve dynamic allocation of SRAM.
[0025] As another preferred solution, when the filtering processing unit works in the ID complete match filtering mode, after receiving the received message ID transmitted by the bit stream processor, if the message is a standard frame, the 11-bit ID and the contents of IDE, RTR, EDL, and FDF of the received message are compared with the filtering reference value read out of the SRAM; if the message is an extended frame, the 29-bit ID and the contents of IDE, RTR, EDL, and FDF of the received message need to be compared with the filtering reference value read out of the SRAM; if it is a complete match, the filtering is passed, and the match flag is pulled high and transmitted to the CAN bus controller, indicating that the message is stored in the receive FIFO; otherwise, the message does not pass the filtering, and the match flag remains low, indicating that the message does not need to be stored in the receive FIFO;
[0026] When the filtering processing unit works in the ID mask filtering mode, after receiving the received message ID transmitted by the bit stream processor, the filtering reference value and filtering mask of the SRAM are read out; the filtering mask indicates whether the ID and IDE, RTR, EDL, and FDF of the received message need to be matched with the filtering reference value; a filtering mask of 1 indicates that the bit must be consistent with the content in the filtering reference value to pass the filtering, and a filtering mask of 0 indicates that the bit is not compared; if the message is a standard frame, even if the corresponding bits of the EXID of the filtering mask and the filtering reference value are both 1, since the standard frame ID does not have an EXID, the filtering mask and the EXID of the filtering reference value do not participate in the filtering. In this mode, the mask control is used to select whether to pay attention to the IDE, RTR, EDL, and FDF of the received message; if the filtering is passed, the matching flag is pulled high and transmitted to the CAN bus controller, indicating that the message is stored in the receiving FIFO; otherwise, the message does not pass the filtering, and the matching flag remains low, indicating that the message does not need to be stored in the receiving FIFO.
[0027] Furthermore, the acceptance filter SRAM is divided into SRAM0 and SRAM1. The two SRAMs have the same size of 32x32bit, totaling 128Byte. The filter data of the same depth are grouped together, totaling 32 groups. In the ID mask filtering mode, SRAM0 and SRAM1 store 32-bit filtering reference values and 32-bit filtering masks respectively. In the ID complete match filtering mode, SRAM0 and SRAM1 both store 32-bit filtering reference values.
[0028] The beneficial effects of the present invention are:
[0029] A dynamically managed acceptance filter SRAM shared by multiple CAN or FDCAN bus controllers is provided. When in use, the starting address of the filter SRAM space of each CAN or FDCAN bus controller is used for division, so that the acceptance filter SRAM filter data can be shared and dynamically allocated, so as to make full use of SRAM resources, reduce system area and power consumption, and avoid resource waste. BRIEF DESCRIPTION OF THE DRAWINGS
[0030] Figure 1 It is a schematic diagram of a conventional CAN bus controller system;
[0031] Figure 2 This is a schematic diagram of a CAN bus controller system according to an embodiment of the present invention;
[0032] Figure 3 This is a schematic diagram of a CAN bus controller according to an embodiment of the present invention;
[0033] Figure 4 This is a schematic diagram of an acceptance filter control module according to an embodiment of the present invention;
[0034] Figure 5 A schematic diagram of SRAM sharing and dynamic allocation of an acceptance filter according to an embodiment of the present invention;
[0035] Figure 6 This is a data mapping diagram of the SRAM complete matching filter mode of the acceptance filter according to the embodiment of the present invention;
[0036] Figure 7 It is a data mapping diagram of the SRAM mask filtering mode of the acceptance filter according to the embodiment of the present invention;
[0037] Figure 8 It is a schematic diagram of the communication flow of a conventional CAN bus controller system;
[0038] Fig. 9 The figure is a schematic diagram of the communication flow of the CAN bus controller system according to an embodiment of the present invention. DETAILED DESCRIPTION
[0039] In order to more clearly understand the above-mentioned objects, features and advantages of the present invention, the present invention is further described in detail below with reference to the accompanying drawings and specific embodiments.
[0040] Figures 2 to 7 and Fig. 9 A specific implementation of the CAN bus controller system capable of dynamically managing the filter SRAM of the present invention is shown: it includes an interface management module, an acceptance filter control module, an acceptance filter SRAM, a bus controller initialization module and n CAN bus controllers, wherein:
[0041] The interface management module is used to initialize the CAN bus controller through the CAN bus controller initialization module, and to initialize the acceptance filter through the acceptance filter control module, and to configure the internal register according to the corresponding address, data, and control signal by controlling the external input signal;
[0042] The acceptance filter control module is used to control the allocation of the acceptance filter SRAM according to the external configuration, and compare the data of the acceptance filter SRAM with the received ID and the contents of IDE, RTR, EDL, and FDF to determine whether to receive the message;
[0043] The acceptance filter SRAM is used to store the externally configured ID for filtering, i.e., the filtering reference value and the filtering mask;
[0044] The CAN bus controller initialization module is connected to the CAN bus controller and is used to complete the initialization of the CAN bus controller according to the external configuration;
[0045] The CAN bus controller is a standard CAN bus controller or an FDCAN bus controller, and n is 32.
[0046] In this embodiment, the CAN bus controller includes a sending buffer, a receiving FIFO, a bit stream processor, and a bit timing logic, wherein:
[0047] The sending buffer is used to store externally written frame messages to be sent;
[0048] The receiving FIFO is used to store messages received from the CAN bus and passed the acceptance filter;
[0049] The bit stream processor is used to control the data flow between the sending buffer, the receiving FIFO and the CAN bus; when the CAN bus controller is in the sending mode, when the sending request is set, the sending buffer frame message is sent according to the frame format of the CAN standard; when the CAN bus controller is in the receiving mode, the message is received from the CAN bus, and the frame ID is sent to the acceptance filter controller, and when the acceptance filter indicates that the filter has passed, the received message is sent to the receiving FIFO for storage;
[0050] The bit timing logic is used for monitoring the CAN bus and processing the bit timing related to the CAN bus.
[0051] In this embodiment, the acceptance filter control module includes a filter starting group register, a filter mode register, and a filter processing unit, wherein:
[0052] The filter start group register is used to realize the allocation of the acceptance filter SRAM according to the start filter group of each CAN bus controller configured externally;
[0053] The filter start group register can be configured externally to have the same value or different values for the start addresses of different CAN bus controllers according to requirements;
[0054] If different CAN bus controllers expect to filter the same message, they are configured with the same value to achieve SRAM data sharing;
[0055] If different CAN bus controllers are expected to filter different messages, they are configured with different values to achieve dynamic allocation of SRAM.
[0056] like Figure 5 As shown, CAN2 and CAN3 controllers share SRAM data, and other controllers exclusively use SRAM data to implement dynamic SRAM allocation. Other shared data and dynamically allocated SRAM data can be implemented by configuring the corresponding filter start group registers to appropriate values according to requirements.
[0057] The filter mode register is 32 bits, and each bit controls the filter mode of each group of filters, which is divided into ID complete match filter mode or ID mask filter mode according to the external configuration mode;
[0058] The filter processing unit is used to compare the data in the acceptance filter SRAM with the received ID and the contents of IDE, RTR, EDL and FDF to determine whether to receive the message. The filter processing unit is connected to the bit stream processor in the CAN bus controller.
[0059] When the filtering processing unit works in the ID complete match filtering mode, after receiving the received message ID transmitted by the bit stream processor, if the message is a standard frame, the 11-bit ID and the contents of IDE, RTR, EDL, and FDF of the received message are compared with the filtering reference value read out of the SRAM; if the message is an extended frame, the 29-bit ID and the contents of IDE, RTR, EDL, and FDF of the received message need to be compared with the filtering reference value read out of the SRAM; if it is completely matched, it passes the filtering, pulls up the match flag and transmits it to the CAN bus controller, indicating that the message is stored in the receiving FIFO; otherwise, the message does not pass the filtering, and the match flag remains low, indicating that the message does not need to be stored in the receiving FIFO;
[0060] When the filtering processing unit works in the ID mask filtering mode, after receiving the received message ID transmitted by the bit stream processor, the filtering reference value and filtering mask of the SRAM are read out; the filtering mask indicates whether the ID and IDE, RTR, EDL, and FDF of the received message need to be matched with the filtering reference value; the filtering mask is 1, indicating that the bit must be consistent with the content in the filtering reference value to pass the filtering, and the filtering mask is 0, indicating that the bit is not compared; if the message is a standard frame, even if the corresponding bits of the EXID of the filtering mask and the filtering reference value are both 1, since the standard frame ID does not have EXID, the filtering mask and the EXID of the filtering reference value do not participate in the filtering. In this mode, the mask control is used to select whether to pay attention to the IDE, RTR, EDL, and FDF of the received message; if the filtering is passed, the matching flag is pulled high and transmitted to the CAN bus controller, indicating that the message is stored in the receiving FIFO; otherwise, the message does not pass the filtering, and the matching flag remains low, indicating that the message does not need to be stored in the receiving FIFO.
[0061] In this embodiment, the acceptance filter SRAM is divided into SRAM0 and SRAM1. The two SRAMs have the same size of 32x32bit, totaling 128Byte. The filter data of the same depth are grouped together, totaling 32 groups. In the ID mask filtering mode, SRAM0 and SRAM1 store 32-bit filtering reference values and 32-bit filtering masks respectively. In the ID complete match filtering mode, SRAM0 and SRAM1 both store 32-bit filtering reference values.
[0062] Fig. 9 The CAN bus controller communication process of this embodiment is shown, wherein the main process of filter initialization is as follows:
[0063] 1) Configure the current CAN bus controller system filter start group register;
[0064] 2) Configure the filter mode register, each bit controls the data filtering mode of each group of filters, which is divided into ID complete match filtering mode or ID mask filtering mode;
[0065] 3) Initialize SRAM0 and SRAM1.
[0066] The above embodiments of the present invention are merely examples for illustrating the present invention, and are not intended to limit the embodiments of the present invention. For those skilled in the art, other different forms of changes and modifications can be made based on the above description. It is impossible to list all the embodiments here. Any obvious changes or modifications derived from the technical solution of the present invention are still within the scope of protection of the present invention.
Claims
1. A CAN bus controller system capable of dynamically managing filter SRAM, characterized in that: It includes an interface management module, an acceptance filter control module, an acceptance filter SRAM, a bus controller initialization module and n CAN bus controllers, wherein: The interface management module is used to initialize the CAN bus controller through the CAN bus controller initialization module, and to initialize the acceptance filter through the acceptance filter control module, and to configure the internal register according to the corresponding address, data, and control signal by controlling the external input signal; The acceptance filter control module is used to control the allocation of the acceptance filter SRAM according to the external configuration, and compare the data of the acceptance filter SRAM with the received ID and the contents of IDE, RTR, EDL, and FDF to determine whether to receive the message; The acceptance filter SRAM is used to store the externally configured ID for filtering, i.e., the filtering reference value and the filtering mask; The CAN bus controller initialization module is connected to the CAN bus controller and is used to complete the initialization of the CAN bus controller according to the external configuration; The CAN bus controller is a standard CAN bus controller or an FDCAN bus controller, and the maximum value of n is 32.
2. A CAN bus controller system capable of dynamically managing filter SRAM according to claim 1, characterized in that: The CAN bus controller includes a sending buffer, a receiving FIFO, a bit stream processor, and a bit timing logic, wherein: The sending buffer is used to store externally written frame messages to be sent; The receiving FIFO is used to store messages received from the CAN bus and passed the acceptance filter; The bit stream processor is used to control the data flow between the sending buffer, the receiving FIFO and the CAN bus; when the CAN bus controller is in the sending mode, when the sending request is set, the sending buffer frame message is sent according to the frame format of the CAN standard; when the CAN bus controller is in the receiving mode, the message is received from the CAN bus, and the frame ID is sent to the acceptance filter controller, and when the acceptance filter indicates that the filter has passed, the received message is sent to the receiving FIFO for storage; The bit timing logic is used for monitoring the CAN bus and processing the bit timing related to the CAN bus.
3. A CAN bus controller system capable of dynamically managing filter SRAM according to claim 2, characterized in that: The acceptance filter control module includes a filter start group register, a filter mode register, and a filter processing unit, wherein: The filter start group register is used to realize the allocation of the acceptance filter SRAM according to the start filter group of each CAN bus controller configured externally; The filter mode register is 32 bits, and each bit controls the filter mode of each group of filters, which is divided into ID complete match filter mode or ID mask filter mode according to the external configuration mode; The filtering processing unit is used to compare the data in the acceptance filter SRAM with the received ID and the contents of IDE, RTR, EDL and FDF to determine whether to receive the message.
4. A CAN bus controller system capable of dynamically managing filter SRAM according to claim 3, characterized in that: The filter start group register can be configured by external device to have the same value or different values for the start addresses of different CAN bus controllers according to requirements; If different CAN bus controllers expect to filter the same message, they are configured with the same value to achieve SRAM data sharing; If different CAN bus controllers are expected to filter different messages, they are configured with different values to achieve dynamic allocation of SRAM.
5. A CAN bus controller system capable of dynamically managing filter SRAM according to claim 3, characterized in that: When the filtering processing unit works in the ID complete match filtering mode, after receiving the received message ID transmitted by the bit stream processor, if the message is a standard frame, the 11-bit ID and the contents of IDE, RTR, EDL, and FDF of the received message are compared with the filtering reference value read out of the SRAM; if the message is an extended frame, the 29-bit ID and the contents of IDE, RTR, EDL, and FDF of the received message need to be compared with the filtering reference value read out of the SRAM; if it is completely matched, it passes the filtering, pulls up the matching flag and transmits it to the CAN bus controller, indicating that the message is stored in the receiving FIFO; otherwise, the message does not pass the filtering, and the matching flag remains low, indicating that the message does not need to be stored in the receiving FIFO; When the filtering processing unit works in the ID mask filtering mode, after receiving the received message ID transmitted by the bit stream processor, the filtering reference value and the filtering mask of the SRAM are read out; The filter mask indicates whether the ID and IDE, RTR, EDL, and FDF of the received message need to be matched with the filter reference value; a filter mask of 1 indicates that the bit must be consistent with the content in the filter reference value to pass the filter, and a filter mask of 0 indicates that the bit is not compared; if the message is a standard frame, even if the corresponding bits of the filter mask and the filter reference value EXID are both 1, since the standard frame ID does not have an EXID, the filter mask and the filter reference value EXID do not participate in the filtering. In this mode, the mask control is used to select whether to pay attention to the IDE, RTR, EDL, and FDF of the received message; if the filter passes, the match flag is pulled high and transmitted to the CAN bus controller, indicating that the message is stored in the receive FIFO; otherwise, the message does not pass the filter, and the match flag remains low, indicating that the message does not need to be stored in the receive FIFO.
6. A CAN bus controller system capable of dynamically managing filter SRAM according to claim 1, characterized in that: The acceptance filter SRAM is divided into SRAM0 and SRAM1. The two SRAMs have the same size of 32x32bit, totaling 128Byte. Filter data of the same depth are grouped together, totaling 32 groups. In the ID mask filtering mode, SRAM0 and SRAM1 store 32-bit filter reference values and 32-bit filter masks respectively. In the ID complete match filtering mode, SRAM0 and SRAM1 both store 32-bit filter reference values.
