I was driving my 2006 Hyundai sonata (3.3L) yesterday during heavy rain. Suddenly check engine light started flashing. When I stopped at a red light, it started shaking badly. I noticed that when I hit the break in drive mode, rpm drops from 1000 to around 900. But in neutral or in parking mode, it goes back to 1000. My primary guess is either spark plug(s) or coil pack(s) or both gone bad due to some kind of water leakage. I don't think it's timing chain because I don't drive often (it has 105k miles).
I visited a nearby mechanic and he told me that I got P0018 along with P0300,P0302 and P0304. He needs time to check if the P0018 caused by a stretched timing chain or a bad sensor. I hope it is crankshaft position sensor or Camshaft position sensor. Becuase Timing chain can be expensive (around 1000 dollars I guess).
UPDATE There was a problem with the BANK 2 VARIABLE SOLENOID (part number: TS1109). Replacing that solved the problem.