Your problem sounds like it is a crankshaft sensor / cam position sensor correlation error. In other words the sensor in your distributor that reports the position of the cam shaft and the crankshaft position sensor behind the harmonic balancer are not in sync. The most common cause is a distributor being removed and replaced a bit off.
Second would be wear of the distributor gear and third would be excessive slack/wear of the timing chain and gears. Or a bad sensor or wires from the sensor.
If you have had the distributor removed for any reason check it to see if it is at top dead center in relationship of #1 spark terminal and #1 cylinder..
If that is not the problem, check the distributor gear for wear.
You can test for wear by turning the distributor counter clockwise a degree or two and see if the code goes away. If this test is successful replace the gear soon as it also drives your oil pump!!