What could cause a ticking that doesnt go away? on 2000 Mazda Protege

Just recently bought a Mazda Protege with 158000kms on it. I noticed that there was a ticking sound coming from the engine and my check engine light had come on. The speed of the ticking increases as I accelerate but remains even after the car is back in idle. I figured it may just need oil/oil change, but was wondering if there are any other possible causes.

Asked by for the 2000 Mazda Protege
sounds like cam issues or valve adj. this needs to be looked at to determine damage. scan codes and post them