Something identical to this happened to me. What happened is that the crank angle sensor in the distributor caused mine to do the same thing when it got broke. The little screw that holds the rotor on bounced around in the distributor cap and crank angle sensor got broken. So double check the ECU codes, that's how I fixed my situation.
Just a suggestion.