The 2 codes are for different sensors
P0340 is an erratic Cam position sensor(CPS/CMP), part that was changed.
P1336 is an erratic Crank Position(CKP) sensor
CKP sensor is on the lower front of the engine, on 3.0l it is behind main crank pulley at about 10:00 position.
It reads a "tone wheel" on the crankshaft, looks like teeth on a gear.
Make sure tone wheel is clean, no mud or ???
And that CKP sensor is tight.
Disconnect its wire connector and make sure it is clean and dry, then reconnect.
CKP sensor is the main timing sensor for spark and fuel, engine won't run without it.
Engine does run so sensor is OK but wiring or being loose would cause issues.
CPS fine tunes fuel injection.
Problem could still be just the CPS because computer compares the two "timing" signals, and if there is a discrepancy, only the CKP signal will be used but computer may set both codes because they don't both match.
Letting driver/mechanic know to check both signals