# CAN: Bit stuffing error detected at bit position 47, frame ID 0x123

- **ID:** `embedded/can-bus-bit-stuffing-error`
- **Domain:** embedded
- **Category:** protocol_error
- **Error Code:** `CAN_STUFF_ERR`
- **Verification:** ai_generated
- **Fix Rate:** 78%

## Root Cause

The CAN bus frame contained more than five consecutive bits of the same polarity, violating the bit stuffing rule, likely due to baud rate mismatch or electrical noise.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| STM32Cube_FW_F1 v1.8.0 | active | — | — |
| CANopenNode v4.0.0 | active | — | — |
| MCP2515 v1.0.0 | active | — | — |

## Workarounds

1. **Verify CAN bus baud rate using an oscilloscope to measure bit time, then configure all nodes to the same rate (e.g., 500 kbps with sample point at 87.5%).** (85% success)
   ```
   Verify CAN bus baud rate using an oscilloscope to measure bit time, then configure all nodes to the same rate (e.g., 500 kbps with sample point at 87.5%).
   ```
2. **Add a CAN bus error counter check and reset the CAN controller if error count exceeds 96, using HAL_CAN_ResetError() and reinitialization.** (75% success)
   ```
   Add a CAN bus error counter check and reset the CAN controller if error count exceeds 96, using HAL_CAN_ResetError() and reinitialization.
   ```

## Dead Ends

- **Increase the CAN bus termination resistor value to 150 ohms** — Termination resistors should be 120 ohms for standard CAN; changing the value can cause signal reflections and worsen bit errors. (90% fail)
- **Reduce the CAN baud rate arbitrarily without checking the bus configuration** — Reducing baud rate may not match other nodes on the bus, causing synchronization errors and more stuffing violations. (85% fail)
