P0340 is the intake cam position sensor. This sensor is located at the forward end of the head, behind the oil filter canister lid and tucked under the VANOS solenoid. It is not a difficult part to replace, although the connector location is a royal pain to get to.
Remove the air filter box and the lid from the oil filter canister. You should be able to get the sensor out from there. It has a single screw holding it in, and I remember it as a 5mm or 5.5mm allen.
Last edited by jdstrickland; 03-19-2012 at 07:31 PM.