When my 1998 528i CPS failed, it was a "soft failure" at 16y/150K time frame.
SYMPTOMS:
- Check engine light and code P0340 as mentioned.
- Occasional bogging under acceleration, not stalling issues (yet). Time to replace the CPS to avoid stalling.
Here is more info...
BMW 528i 1998 Replace camshaft position sensor - DIY
https://www.bimmerfest.com/threads/b....514578/page-2