Did you erase the P0340 and it came back? It is a fault with the cam sensor and could be the electrical circuit instead of the sensor itself. This code would prevent the fuel injectors from firing.
P1145 - Solenoid Valve Running Losses Control Circuit Electrical. Diagnostic information not available from manufacturter. There are no reference to what this solenoid is. Seems only the BMW dealer scan tool works on this problem.
P1509 - Idle-Speed control valve opening solenoid control circuit signal electrical. Maybe this is the solenoid P1145 is refering to?
BMW are not friendly with non dealers therefore information are lacking in most aspects.
Images (Click to make bigger)
Tuesday, September 4th, 2012 AT 12:34 PM