engine light coming on when accelerating on 2010 Dodge Ram 1500

When I am accelerating the check engine light comes on and stays on for approx 2-3 seconds. During that time the performance of the truck is not right, almost like I am not getting any fuel. After that 2-3 seconds the truck runs fine. This has mostly occurred while accelerating on the highway, but has occasionally happened in town.

Asked by for the 2010 Dodge Ram 1500