Hi. I'm brand new here, and a brand new Subaru owner as of Oct. 2018. I realize this is an old post, but hopefully my reply will get noticed.
Anyway, thanks for the post jmcgliss. It helps me a lot to confirm my suspicions.
I also have a '05 Legacy GT MT Sedan and it's running very rough and stalling and gives code P0340 (cam position sensor A circuit). The funny part is, this problem didn't really appear until the weather changed in November. When it's cold outside it runs fine at first. Then as it warms up, there's a "sweet spot" (or sour spot, in this case) where it will run rough and stall and is very difficult to keep running and restart, etc. Then once the engine is nice and warm, it runs great again. And as I said, it gives the P0340 code. Also, once it's warm, I can clear the code and it doesn't come back until the engine has had time to cool below the "sour spot". Rinse. Repeat.
My question is, how did you know which sensor to replace? I looked on other forums and youtube and such and it seemed easy to get at. So I bought a sensor with the intention or replacing it myself. Unfortunately real life proved dramatically different. I tried getting at the driver side one yesterday and it was impossible for someone with my limited space, tools, ability and courage. And it was freezing in my garage, so that didn't help.
Anyway, just wondering if it's worthwhile trying to get at the passenger side sensor. It looks a little more accessible, but I don't know which sensor is the defective one anyway. Or is it worth buying a second sensor and just replacing both? Fortunately I have a good mechanic who will let me bring in my own part and I'll just pay him for the install.
Anyway, hope someone can offer some insight.
Thanks,
$$$