# CAN: 在位位置47检测到位填充错误，帧ID 0x123

- **ID:** `embedded/can-bus-bit-stuffing-error`
- **领域:** embedded
- **类别:** protocol_error
- **错误码:** `CAN_STUFF_ERR`
- **验证级别:** ai_generated
- **修复率:** 78%

## 根因

CAN总线帧包含超过五个连续相同极性的位，违反了位填充规则，可能是由于波特率不匹配或电气噪声。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| STM32Cube_FW_F1 v1.8.0 | active | — | — |
| CANopenNode v4.0.0 | active | — | — |
| MCP2515 v1.0.0 | active | — | — |

## 解决方案

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%).
   ```
2. ```
   Add a CAN bus error counter check and reset the CAN controller if error count exceeds 96, using HAL_CAN_ResetError() and reinitialization.
   ```

## 无效尝试

- **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% 失败率)
- **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% 失败率)
