A P0340 on an OBD-II E36 six is the camshaft position sensor circuit, and the first thing to know is that you can't ohm this sensor the way you would the crank one.
The M52/S52 cam sensor is a Hall-effect unit with three wires (feed, ground, switched signal), so there's no winding resistance to measure — testing it means confirming it has power and a good ground and that the signal switches as the engine turns
…