Few things are more alarming than having your 2021 Mercedes-Benz E-Class stall while sitting at a traffic light. The engine simply dies without warning, dash lights illuminate, and you scramble to restart before the light turns green. A P0340 code—Camshaft Position Sensor Circuit Malfunction—reveals the likely source of this dangerous behavior.
What the Camshaft Position Sensor Does
The camshaft position sensor monitors the rotation of your engine's camshaft, providing critical timing information to the engine computer. This data determines when to fire the spark plugs and when to pulse the fuel injectors. Without accurate camshaft position information, the engine can't maintain proper combustion timing—or may not run at all.
How Sensor Problems Cause Stalling
When the camshaft position sensor fails or sends erratic signals, the engine computer loses track of valve timing. At idle, where timing must be precise and there's no momentum to carry the engine through irregularities, this signal loss can cause immediate stalling. The engine might restart fine when cooled down, only to stall again once heat affects the failing sensor.
Common Causes of P0340
Several issues can trigger this code:
- Camshaft sensor failure - Internal electronics fail from heat or age
- Wiring damage - Connector corrosion, chafed wires, or broken connections
- Timing chain stretch - Affects the relationship between cam and crank sensors
- Tone ring damage - The reluctor wheel the sensor reads can be damaged
- ECU software issues - Rare, but software glitches can misinterpret sensor data
Why Stalling Often Occurs at Idle
At higher RPM, engine momentum and the crankshaft position sensor can partially compensate for camshaft sensor issues. At idle, where rotational speed is low and timing margins are tighter, sensor irregularities immediately affect stability. This explains why your E-Class might drive fine but die at every stoplight.
Diagnostic Approach
Proper diagnosis involves:
- Retrieve all stored codes and freeze frame data
- Monitor camshaft sensor signal quality with an oscilloscope
- Check wiring continuity and connector condition
- Compare camshaft and crankshaft sensor correlation
- Inspect for timing chain wear if mileage warrants
Repair Costs for 2021 E-Class
- Camshaft position sensor replacement: $200-$400
- Wiring repair: $150-$350
- Timing chain inspection/replacement: $1,500-$3,500 (if needed)
- Software update: $100-$200 (if applicable)