The description of all fault codes contain three basic and inescapable reasons, the component, the wiring and the conètica.
It is not a question of changing the component without first controlling the connections and the status of the cables.
You say that you tried the continuity of the cables and okay, but have you controlled the resistance?
If a cable had more than 1 ohms between tips, this makes you vary the signal that circulates by it, remember that if you are talking about a sensor, it generates a variable voltage signal to indicate to the ECU in which the load is the engine is the engine and with the signal received to manage the progress of the time of injection and the opening time of the injectors, therefore if the cable would be resistive signal generating erratic functioning.
Check the resistance wiring, you should mark up to 0.4 ohms if it is normal.