You first have to work out if the spikes are real or not. Connect the yellow trace scope probe to circuit 0V and see if the spikes are still there. Also remove the blue trace probe completely and see if the spikes go away.
Richard.
Ok i have connected the yellow channel to GND while blue channel was measuring the PWM. Still same result.
I have disconnected the blue channel(even from the scope). and Spikes changed their behavior like in a delayed manner. I am posting the Pictures and also zoomed version of single spike.
So what you are seeing on the scope is probably nothing to do with the A/D pin, but it does look like there is a problem. It does look like the falling edge of the PWM, and sometimes the rising edge, is triggering a ringing or an oscillation, that is getting into the scope probably through the earth connections.
Are the scope earth leads connecting to a 0V close to the micro?
For the zoomed in image, it looks like you just expanded a slow capture as the triangular waveform looks like you need far more samples per cycle. You want to trigger off the spike, and turn the sweep speed up so you can get a good look at that sine-looking wave. Is it a constant amplitude for the whole period of the spike, or is it slowly falling off in amplitude through the spike?
The PWM output alone with nothing connected to the PWM pin would be unlikely to generate this noise.
If the amplitude is constant for the width of the spike, then something to do with the PWM, or something in sync with the PWM is oscillating. That is something worth tracking down. If the spike consists of a slowly decaying sine wave, then you probably have ringing associated with some inductance somewhere that can do with some damping.
What else is connected to the PWM pin?
Also start off with the oscilloscope connected and all the supplies off. You should be able to get some waveforms with less then 3mV noise, particularly if the scope probe is connected to the same point of the circuit as the probe's ground clip.
Richard