I have an 02 Dodge Ram 1500 with 74000 miles on it. It’s begun doing a number of things that my mechanic has not been able to diagnose or fix. When at idle, it surges from around 700 RPM up to 1500 RPM. Also, on occasion when I start the engine the fuel gauge fails to “come on”, stays down at empty and the out of fuel indicator comes on. Finally, also when I start the engine, put it into reverse, it slams into gear and dies. Upon restart, it runs and shifts just fine. My mechanic checked for codes, found one that indicated the gas cap isn’t sealing well and cleared the code. He then cleaned the throttle body which was very dirty but none of the problems went away.
I had a similar surge problem with my 02 Ram 1500 at about 80,000 miles which a couple of mechanics could not diagnose. Turned out to be a bad Throttle Position Sensor (TPS) but it did not show an error code. My mechanic thought this might be the problem but wasn’t sure. I replaced the TPS myself and that fixed the surge problem. You may also have a cracked vacuum hose somewhere, you might have your mechanic check for that. Good luck.
I had a surge problem as you described, and noticed it only happened when a electrical load engaged such as the A/C compressor. It turned out to be a bad electrical connection from the battery cables. The ECM will notice a voltage drop caused by a bad connection, and in a effort to bring the voltage up will raise engine idle whenever a electrical load is energized.
Check the battery cables and connection on both ends.