CAN bus: Difference between revisions

Line 47: Line 47:
* A dominant reserved bit
* A dominant reserved bit
* 4-bit DLC. Data Length Code, specifying a number of data bytes 0--8.
* 4-bit DLC. Data Length Code, specifying a number of data bytes 0--8.
** For Data Frames, this is the length of the subsequent Data Field
** For Remote Frames, this is the length of the expected response's Data Field
** Larger values (9--15) can appear, but are not used in ISO CAN.
** Larger values (9--15) can appear, but are not used in ISO CAN.
* 0--8 byte Data Field (Data Frames only)
* 0--8 byte Data Field (Data Frames only)
* 15-bit CRC
* 15-bit CRC
* A recessive reserved bit (CRC delimiter)
* A recessive reserved bit (CRC delimiter)
* 1-bit ACK slot
* 1-bit ACK slot. recessive for transmitter, dominant for receivers (who become transmitters for one clock)
* A recessive reserved bit (ACK delimiter)
* A recessive reserved bit (ACK delimiter)
* 7 recessive reserved bits (Frame delimiter)
* 7 recessive reserved bits (Frame delimiter)
Three error frames are defined:
* Active error: 6 dominant bits followed by 8 recessive bits
** Will typically destroy any ongoing message
** Provokes secondary error frames when sent due to a local problem
* Passive error: 6 recessive bits
* Overload frame: 6 dominant bits followed by 8 recessive bits, during the interframe space
===Error States===
Each ECU maintains an RX Error counter and TX Error Counter (REC/TEC), initialized to 0. Successful operations reduce the appropriate counter by 1, though never below 0. Errors increase the counters (usually TEC by 8, REc by 1). Depending on the values of these counters, each ECU is in one of three error states:
* Error-Active: Both counters are less than 128. The ECU will respond to errors with an Active Error Frame.
* Error-Passive: One or both counters are greater than 127. The ECU will respond to errors with (network-transparent) Passive Error Frames.
** The ECU must honor an 8-clock (as opposed to the standard 3) interframe space, the punitive Suspend Transmission Field
** An error causing the ECU to move into the Error-Passive state triggers an Active (not a Passive) Error Frame
** An Error-Passive ECU becomes Error-Active as soon as both counters fall below 128.
* Bus-Off: If the TEC exceeds 255, transmission is disallowed until the host renegotiates with the CAN controller.
** Even following renegotiation, a substantial delay is mandated (128 instances of 11 consecutive recessive bits).
===Errors===
* Bit monitoring -- if transmitting following victory in arbitration, the value read from the bus ought match what we transmit
* Bit stuffing -- five repeated transmitted bits must be followed by the opposite signal for one bit, which is removed from the data stream. if six consecutive bits of the same level are seen, it's an RX error
* Frame check -- invalid value of a specified frame bit
* ACK failure -- transmitter did not see a dominant signal in the ACK slot
* CRC failure -- received CRC did not match computed CRC