I have a 2005 nissan pathfinder with 200,000+ miles. It's been throwing P0340 for years and I replaced both camshaft position sensors, twice. Recently, I also removed camshafts and cleaned up the hydraulic lifters, replaced timing chains, all spark plugs, all ignition coils, water pump, and all timing tensioners. All the timing chain tensioners were worn and the large one on the bottom left side was loose (looked like the threads of the bolt holding it on were crunched and the bolt didnt screw back in, had to re-thread it).
After all that, still getting P0340. I'm screwed... help!
Other symptoms:
Runs rough at idle.
Takes a little too long to start.
VDC slip light is on (probably unrelated?)
Any misfire codes?
No misfire codes, no
See below for other causes and troubleshooting:
https://repairpal.com/obd-ii-code-p0340
https://obd2pros.com/dtc-codes/p0340/
I would check the pin fit in the cam sensor connector and making sure there is no oil within the connector. That code is for bank 1 which is the passenger side on that vehicle. From there it would come down to checking continuity between the sensor and the ecm as well as making sure grounds are clean. Also I would make sure your using oem sensors. Aftermarket are prone to not working correctly or even at all