How do I fix a P0340 code on a Ford F150?

I have a frustrating problem. I’m getting a P0340 code, which is for the bank 1 (passenger side?) camshaft position sensor (CPT). I replaced it, but my car still idles roughly and sometimes stalls at lights.

Am I missing something? It’s the only code that shows up, and I’ve also replaced the Variable Camshaft Timing (VCT) parts, the throttle body, and the Throttle Position Sensor (TPS).

Is there a way to check the camshaft position sensor with a Digital Volt-Ohm Meter (DVOM) to make sure it’s working? If it is working, what should I check next?