A Variable Cam Timing problem will return a code of P1380 or P1381.
P0340 Camshaft Position Sensor circuit fault
If the sensor has been replaced, the problem has to be in the wiring from the CPS to the DIS module (Distributorless Ignition System), or in the DIS itself (although this would be extremely unlikely). The Camshaft Position Sensor sends a signal called the CID (Cylinder IDentification)To the DIS and EEC at startup. This signal establishes firing order. The crankshaft position sensor (VRS) sends the DIS the PIP (Profile Ignition Pickup) signal to establish base crankshaft timing (usually 10 degrees).The DIS module should be in the case with the ECU (engine control unit)inside the car.
You really need to inspect the connector on the cam sensor for corrosion on the contacts and the wiring for abrasion, cracked insulation, and shorts to ground.
The cam sensor output is monitored but not really needed once the engine is running. When the engine is acting up you can try unplugging it and see if the bucking stops.
Any Dealership worth a plug nickle should have the equipment to scope the CID, PIP, and SAW signals and tell if that were the problem. Perhaps if you need to you can find an independent garage capable of doing such from someone in the Canadian forums.