Baud rate matching detection system of high-speed CAN transceiver for local network
Technical Field
The invention belongs to the technical field of digital integrated circuit design, and particularly relates to a baud rate matching detection system applied to a high-speed CAN transceiver of a local network.
Background
The CAN bus is a serial data communication bus developed by Bosch company in Germany in the early 80 th 20 th century for solving data exchange among a plurality of control and test instruments in modern automobiles, and is widely applied to the fields of automobiles and industrial control at present due to good performance and unique design. In recent years, the heat of new energy automobiles is increasing continuously, the energy saving problem of automobiles is receiving attention, and especially in the new energy automobiles with 'cun-jin', the method is very effective for reducing the power consumption of the automobiles and reducing unnecessary energy loss. The push-out of a local network in the CAN bus means a significant reduction in power consumption, cost, wiring, and carbon dioxide emissions throughout the vehicle.
The local network in the CAN bus is the ability to allow some nodes to actively communicate, while the rest is in an inactive state or in a low power mode, and CAN monitor the bus "wakeup frame" (WUF). Upon proper reception of the WUF, the transceiver may activate the entire node. The WUF is sent by active nodes in the network to "wake up" other inactive nodes to enable certain functions in the CAN network. Such WUFs may address nodes individually or in groups. This allows the transceiver of the unaddressed node that receives the wake-up frame to ignore it and maintain the entire ECU in a low power state. This function is called "selective wake-up" and is standardized in the industry standard ISO 11898-6.
The wakeup frame is according to ISO 11898-1: the CAN frame of 2015, consisting of an identifier field (ID), a Data Length Code (DLC), a data field and a Cyclic Redundancy Check (CRC) code and delimiters thereof. Compared with the traditional transceiver, the high-speed CAN transceiver applied to the local network needs to decode the received CAN message, identify the frame structure of the CAN message, compare the frame structure with the ID, DATA and CRC check codes in the wake-up frame configuration register, if the frame structure is matched and no message error occurs, the corresponding node is awakened, and if the frame structure is not matched or no message error occurs, the high-speed CAN transceiver continues to sleep. One prerequisite for decoding is to ensure that the rate of the received message is consistent with the rate of the internal sampling module, so that the frame structure of the CAN message CAN be identified.
Disclosure of Invention
The invention aims to provide a baud rate matching detection system of a high-speed CAN transceiver for a local network, which aims to solve the problem that whether the baud rate is matched or not is difficult to detect in the prior art.
The purpose of the invention can be realized by the following technical scheme
The system for matching and detecting the baud rate of the high-speed CAN transceiver for the local network comprises a sampling baud rate configuration register, a baud rate frequency divider, bit time sequence logic, a bit data stream processor, a shift register module, message error management logic and an interrupt configuration register;
the design of the bit sequential logic comprises three parts of bit timing, sampling points and synchronous design;
bit timing, namely dividing frequency according to the CAN standard baud rate configured in the baud rate configuration register to generate the minimum time unit Tq;
the configuration of the sampling points needs to meet the requirements of a local network on the sampling points of the transceiver;
hard synchronization and resynchronization specified in a CAN protocol adopted by the synchronization design;
the high-speed CAN transceiver applied to the local network CAN be applied to a network mixed with CAN and CAN FD nodes, so that the bit data stream processor is additionally provided with CAN FD detection on the basis of a traditional CAN protocol decoder, and a CAN FD state branch is inserted into a bit stream state, so that the decoding requirement of the high-speed CAN transceiver applied to the local network is met, and the CAN FD detection logic is additionally arranged on the traditional CAN protocol decoder;
all selectable CAN standard baud rates are listed in a sampling baud rate configuration register, and the setting of the conventional baud rate CAN be conveniently and quickly carried out outside;
the interrupt configuration register CAN freely configure the interrupt outside, CAN enable and disable the baud rate matching detection interrupt function, CAN clear the interrupt mark through external software, and sets primary interrupt and secondary interrupt for a high-speed CAN transceiver applied to a local network, thereby enhancing the flexibility of the high-speed CAN transceiver;
the message error management logic CAN identify bit filling errors, format errors and CRC (cyclic redundancy check) errors in the CAN message, count the errors, generate an error mark signal when a message error occurs, and an external microcontroller CAN monitor whether the message error exists or not in real time by accessing an error mark state register;
if the number of times of occurrence of the message errors exceeds a certain threshold, an interrupt signal with unmatched baud rate CAN be generated, and the method has certain tolerance to the situation that the message errors occur on the CAN bus due to EMC and other unknown errors;
meanwhile, when the CAN bus enters idle and the bus has no data for a long time, the message error counter is cleared, so that dynamic power consumption is saved, and meanwhile, a gated clock is adopted at an RTL level, so that the power consumption is reduced;
the CAN protocol decoder in the digital module of the high-speed CAN transceiver applied to the local network is a core module, resource sharing is adopted at an RTL level, an additional logic function is added on the basis of CAN protocol decoding to achieve the realization of a baud rate matching detection function, and the area of the transceiver is saved;
compared with the prior art, the invention has the beneficial effects that:
1. the invention CAN realize the detection whether the transmitting-receiving baud rate is matched, and avoid the condition that the node CAN not be awakened for a long time due to the problem of unmatched rate when the CAN network enables the local network function;
2. the method can avoid the situation that the active node wakes up the sleeping node on the bus, continuously sends error frames and always occupies the bus;
3. the invention CAN detect the conditions that abnormal errors occur on the CAN bus system and message errors occur.
Drawings
In order to facilitate understanding for those skilled in the art, the present invention will be further described with reference to the accompanying drawings.
FIG. 1 is a schematic structural diagram of a baud rate matching detection system of a high-speed CAN transceiver for a local network according to the present invention;
FIG. 2 is a flowchart of the operation of the high speed CAN transceiver baud rate match detection system for local networks in accordance with the present invention;
fig. 3 is an RTL simulation waveform diagram of the operation of the baud rate matching detection system of the high-speed CAN transceiver for the local network according to the present invention.
Detailed Description
The technical solutions of the present invention will be described clearly and completely with reference to the following embodiments, and it should be understood that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
A baud rate matching detection system for a high-speed CAN transceiver for a local network, as shown in fig. 1, includes a sampling baud rate configuration register, a baud rate frequency divider, bit timing logic, a bit data stream processor, a shift register module, message error management logic, and an interrupt configuration register;
the shift register module comprises a plurality of shift registers and is used for temporarily storing each section of data decoded by the CAN protocol decoder;
a sample baud rate configuration register is configured externally,
the baud rate frequency divider divides the frequency of a system clock into the minimum time Tq corresponding to the CAN standard baud rate according to the value of the configuration register and then sends the minimum time Tq to bit sequential logic;
the bit sequential logic samples the received data according to the corresponding baud rate, and sends sampling points and sampling bits to the bit data stream processor, and meanwhile, the bit data stream processor feeds back a synchronous mode to the bit sequential logic so as to determine which synchronous mode is adopted;
the bit data stream processor skips the state according to the frame structure of the CAN message and transfers the sampled data of different sections of the frame structure to the corresponding shift register for temporary storage;
when the bit data stream processor carries out state jump, the message error management logic can carry out message error check on the value in the shift register, if a message error occurs, the error counter is self-added with '1' and generates a message error state mark, under the condition that the interrupt configuration register enables interrupt, the error counter exceeds a certain threshold value, a baud rate unmatched interrupt signal is generated, and when a frame is at the end and no message occurs, the error counter is self-reduced by '1';
the external part can enable or disable the interrupt signal with the non-matching baud rate through an interrupt configuration register, and clear the interrupt through writing '1' by software;
as shown in fig. 2, the work flow of the high-speed CAN transceiver baud rate matching detection system for the local network is as follows:
s1, setting a sampling baud rate in a sampling baud rate configuration register before the local network and the selective awakening are opened;
s2, opening a local network and a selective awakening function, monitoring the CAN bus, detecting a low level, considering the low level as a start bit, and generating a message on the CAN bus;
s3, decoding all data on the CAN bus, wherein the data comprises an ID field, a data field, a CRC field and a frame end, and the sampled data is temporarily stored in a shift register;
s4, in the analysis process, as long as a message error occurs, the error counter performs self-increment by 1, and sets a flag bit in the message error state register until no message error occurs in the next frame of message, and the message error flag bit is cleared;
the message errors comprise bit filling errors, format errors and CRC errors;
if the counter value exceeds the set threshold, generating unmatched interrupt of the baud rate of the transceiver, reminding an external microcontroller that the baud rate is unmatched and the counter value does not exceed the set threshold, and continuously detecting whether the CAN message has errors or not until the bus enters idle;
s5, in the analysis process, if the whole frame of message has no message error, the error counter is reduced by 1, and when the next frame of message has no message error, the counter is reduced by 1 until the value is 0;
s6, if the CAN bus is not idle, decoding the CAN message all the time, judging whether the message has a message error, if the bus is idle, performing low level detection, and judging whether the bus has the CAN message;
when the bus enters idle state, the flag bit of the message error state register is cleared, and if no data exists on the bus for a long time, the error counter is cleared.
As shown in fig. 3, a 500K CAN message is received by RX, the CAN sampling baud rate externally configured by a CDR register is 1M, because the baud rates are not matched, an internal bit timing module samples error data, it CAN be known from the waveform that CAN message errors (CRC errors, bit filling errors, format errors) occur, and each time such an error occurs, an error counter automatically adds "1", when the counter exceeds a threshold value of 31, PNFDE _ flag is set to a high level, an error interrupt that the baud rates are not matched is generated, an external microcontroller is prompted to adjust the baud rate of the sent message or adjust the sampling frequency of the internal bit timing through the CDR, and a state signal COSC _ flag monitored by the message error is still in a low level state after sending a frame of message, which indicates that there is an error condition in the internal message.
Through the analysis, the implementation method for baud rate matching detection in the high-speed CAN transceiver applied to the local network CAN meet the functional requirements, is flexible in configuration, and has certain tolerance to the condition that the message error occurs due to EMC and other unknown errors on the CAN bus.
The preferred embodiments of the invention disclosed above are intended to be illustrative only. The preferred embodiments are not intended to be exhaustive or to limit the invention to the precise forms disclosed. Many modifications and variations are possible in light of the above teaching. The embodiments were chosen and described in order to best explain the principles of the invention and the practical application, to thereby enable others skilled in the art to best utilize the invention. The invention is limited only by the claims and their full scope and equivalents.