1 Several important concepts
- Fault confinement
CAN nodes shall be able to distinguish short disturbances from permanent failures. Defective transmitting nodes shall be switched off. Switched off means a node is logically disconnected from the bus, so that it can neither send nor receive any frames.
CAN nodes can distinguish between normal errors and permanent faults. A faulty transmitting node will switch to the offline state. Offline means logically disconnected from the bus and can neither send nor receive.
- Error-active
An error-active node shall normally take part in bus communication and send an active error flag when an error has been detected. The active error flag shall consist of six (6) consecutive dominant bits and shall violate the rule of bit stuffing and all fixed formats appearing in a regular frame.
A node in the active error state can participate in the transmission and reception of bus communications normally and will send an error flag when an error is detected. The error flag consists of 6 consecutive display bits (these 6 consecutive display bits are different from the conventional fill bits and other frame fixed formats. Because of this, the hardware can easily distinguish them).
- Error-passive
An error-passive node shall not send an active error flag. It takes part in bus communication, but when an error has been detected a passive error flag shall be sent. The passive error flag shall consist of six (6) consecutive recessive bits. After transmission, an error-passive node shall wait some additional time before initiating a further transmission.
A node in the passive error state cannot send an active error flag. It can participate in normal communication, but when an error is detected, it sends a passive error flag. The passive error flag consists of 6 consecutive recessive bits. After the transmission is completed, the node in the passive error state needs to wait some extra time before sending again next time.
- Bus-off
A node shall be in the bus-off state when it is switched off from the bus due to a request of FCE. In the bus-off state, a node shall neither send nor receive any frames. A node shall start the recovery from bus -off state only upon a user request.
Due to the error boundary rules, a node may be offline, when in this state, the node neither sends nor receives. When to recover from offline depends on when the user requests it.
2 Incorrectly defined rules in ISO 11898
2.1 Description
When it comes to error demarcation, a node must be in one of the following three error states, depending on the node's error count value:
- Error-active
- Error-passive
- Bus-off
2.2 Error Count
The error counter will update the error count value when detecting the following events:
- When a receiving node detects an error, the error counter will be increased by 1. There is one exception, that is, when a single-bit error is detected when sending an active error flag or an overload flag.
- When a receiving node sends an error flag, the error counter is incremented by 8 when the first bit is detected as a dominant bit.
- When an error flag is sent after a transmission, the error counter is incremented by 8, except for two cases: 1: When the sending node is in an active error state and detects an ACK error caused by the absence of a dominant bit in the ACK field, but no passive error flag is detected during transmission; 2: When the sending node sends an error flag, a padding bit error is detected during arbitration (these padding bits should originally be recessive, but the detection result is dominant). The above two abnormal error count values remain unchanged.
- When the sending node sends an active error flag or an overload flag, the error counter is incremented by 8 when a bit error is detected.
- When the receiving node sends an active error flag or an overload flag, the error counter is incremented by 8 when a bit error is detected.
- Any node shall tolerate 7 consecutive display bits when sending an active error flag, a passive error flag, or an overload flag. When 14 display bits are detected, or a passive error flag is followed by 8 display bits, or 8 consecutive dominant bits are detected followed by a passive error flag, all sending nodes increase their send error counter by 8, and all receiving nodes increase their receive error counter by 8.
- After successfully sending a frame of message, the sending counter should be reduced by 1, unless it is currently 0.
- After successfully receiving a frame of message, if the current receive counter value is greater than 1 and less than 127, the receive counter is reduced by 1; if the receive counter value is 0, it remains at 0; if it is greater than 127, the receive counter value should be set to a value between 119 and 127.
2.3 Transitions between active error state and passive error state
When the value of the send error counter or the receive error counter is greater than 127, the node changes to the passive error state.
When a node changes from an active error state to a passive error state, the node will send an active error flag.
When the values of the send error counter and the receive error counter of the passive error node are both less than and equal to 127, it will change to the active error state again.
2.4 Offline Management
If the value of a node's send error counter exceeds 255, the node will be in offline state. A node in offline state will not have any impact on the bus. It will not send message frames, ACK, error frames, overload frames, etc. As for whether it will receive data on the bus, the implementation of this node is cancelled.
When a node in the offline state receives 128 connections with 11 recessive bits, it will become an active error state and set the send error counter and receive error counter to 0 at the same time.
Note: The specific implementation may not be exactly the same as described above. For example, in offline recovery, there is a switch in STM32 to set whether to automatically recover. If this function is disabled, then when the node in the offline state receives 128 connections and 11 consecutive recessive bits, it will not recover to the active error state.
Figure 1[page]
3 bxCAN implementation of STM32
3.1 bxCAN error status diagram
3.2 Error Management
The error management described in the CAN protocol is completely implemented by hardware through the send error counter (TEC field in the CAN_ESR register) and the receive error counter (REC field in the CAN_ESR register), and its value increases or decreases according to the error situation. The software can read their values to determine the stability of the CAN network. In addition, the CAN_ESR register provides detailed information on the current error status. By setting the CAN_IER register (such as the ERRIE bit), the software can flexibly control the generation of interrupts-when an error is detected.
3.3 Offline recovery
When TEC is equal to 255, bxCAN enters the offline state, and the BOFF bit of the CAN_ESR register is set to '1'. In the offline state, bxCAN cannot receive or send messages.
Depending on the setting of the ABOM bit in the CAN_MCR register, bxCAN can recover from the offline state (become an error-active state) automatically or at the request of the software. In both cases, bxCAN must wait for a recovery process described by the CAN standard (128 times 11 consecutive recessive bits are detected on the CAN RX pin).
If the ABOM bit is '1', the bxCAN will automatically start the recovery process after entering the offline state.
If the ABOM bit is '0', the software must first request the bxCAN to enter and then exit the initialization mode before the recovery process is started.
Note: In initialization mode, bxCAN does not monitor the state of the CAN RX pin, so the recovery process cannot be completed. In order to complete the recovery process, bxCAN must operate in normal mode.
4 CAN Error Status Register (CAN_ESR)
Address offset: 0x18
Reset value: 0x0000 0000
Position 31:24 | REC[7:0]: Receive Error Counter This is the implementation of the receive part of the fault definition mechanism of the CAN protocol. According to the CAN standard, when a reception error occurs, the counter is incremented by 1 or 8 depending on the error situation; and after each successful reception, the counter is decremented by 1, or its value is reduced to 120 - when the value of the counter is greater than 127. When the value of the counter exceeds 127, CAN enters the error passive state. |
Position 23:16 | TEC[7:0]: Transmit Error Counter Similar to the above, this is the implementation of the send part of the fault definition mechanism of the CAN protocol. |
Position 15:7 | Reserved bit, forced to 0 by hardware. |
Position 6:4 | LEC[2:0]: Last error code When an error is detected on the CAN bus, the hardware sets it to a value of 1 to 6 according to the error condition. When the message is correctly sent or received, the hardware clears it to '0'. The hardware does not use error code 7, and the software can set this value so that the code update can be detected. 000: No error; 001: Bit fill error; 010: Format error; 011: Acknowledgement error; 100: Hidden bit error; 101: Explicit bit error; 110: CRC error; 111: Set by software. |
Bit 3 | Reserved bit, forced to 0 by hardware. |
Bit 2 | BOFF: Bus Off Flag When entering the offline state, the hardware sets this position to 1. When the send error counter TEC overflows, that is, greater than 255, CAN enters the offline state. |
Bit 1 | EPVF: Error Passive Flag When the number of errors reaches the error passive threshold, the hardware sets this position to 1. (The value of the receive error counter or the transmit error counter is > 127). |
Bit 0 | EWGF: Error warning flag When the number of errors reaches the warning threshold, the hardware sets this position to 1. (The value of the receive error counter or the send error counter is ≥ 96). |
Previous article:CAN error interrupt 1 in STM32
Next article:Detailed explanation of the use of STM32 CAN module
Recommended ReadingLatest update time:2024-11-16 19:45
- Popular Resources
- Popular amplifiers
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- How to measure BLE power consumption (one of the most viewed app reports)
- 1. [Learning LPC1768 library functions] LED experiment
- [Synopsys IP Resources] How many steps are required for a successful RDC sign-off?
- Use Burn in software to test and vibration test the hard disk and a temperature alarm appears
- [Bing Dwen Dwen Award List] 2022 Digi-Key Innovation Design Competition
- Have you ever done this kind of impedance marking that makes people collapse and go to the hospital?
- Transimpedance amplifier circuit, question about the maximum optical power that a photodiode can receive
- Why has the GaN charger that Lei Jun recommends in various ways become a charging magic tool?
- Sell some IC chips
- stm32cubemx always fails to install the packages of various mcu