How to get rid of high frequency noise from crystal?

I'm getting excessive noise directly related to the 16MHz crystal on my 328P. The tone() outputs from the MCU are sent through a 5W amplifier (siren) and of course this artifact is getting amped as well. I went to an internal 8MHz setup for a while which gets rid of it completely however I ran into timing issues so I'm back with the external.

Any idea on what this is and how to get rid of it.? It's possible the bread board has something to do with it. The artifact shows up at around 33 MHz on my scope which I don't understand but pull the crystal out and it's gone instantly.

I'm considering a feed through capacitor.

I can't see how it is possible for this to be happening as this is a digital system. Show us the rest of your circuit!

Mark

My thought exactly. Standby I'll post up the schematic.

Here’s the schematic. It’s, without question related to the crystal. Pull it out and it’s gone, switch to the internal 8MHz and it’s gone.

I see zero bypass capacitors for the processor. There should be two.

Oh, the schematic doesn’t have it but the board does. I have .1uf on pin 7 and on Pin 20.

A 1 MHz low pass filter should be fine.

Coding Badly - Just to be sure I'm not missing something, which bypass caps are you talking about?

0.1µF across (A)VCC and (A)GND as close to the processor as possible.

I have .1uF on pin 20 AVCC to GND and .1uF on pin 7 VCC to GND. Correct?

Correct.

Ok updated schematic showing the caps. Thanks Much for that.

CopperDog:
I'm getting excessive noise directly related to the 16MHz crystal on my 328P. The tone() outputs from the MCU are sent through a 5W amplifier (siren) and of course this artifact is getting amped as well.
...
The artifact shows up at around 33 MHz on my scope...

Does it matter? That is obviously well outside the audible range. Even for bats.

Is the amplifier even capable of reproducing a 33 MHz signal?

I agree you would think it wouldn't matter. The caps were necessary, thanks I was indeed missing one however it doesn't fix the noise. It seems associated with the crystal (I've tried several and tried replacing the 22pF caps). When I pull the crystal it kill the noise and it's very obvious on the scope that the artifact is gone.

What does get rid of it is a 15KHz HPF on the amplifier input but that doesn't explain what the crystal has to do with it. First thing I tried was a low pass but it's in the audible range so of course that's not going to work.

I just held a pitch detector up to the speaker and it indicates bang on 858.3 Hz if I disable the high pass filter.

I'm confused :confused:

"Noise"? Are you saying "audible noise"? Or "electrical noise"?

It's audible. Sorry if that wasn't clear. I'm getting an audible whine out of the speaker hooked to digital pin 5 (MCU pin 11). I'm trying to isolate it on the scope but it's buried in there. The 15KHz high pass kills it dead. If I pull the crystal it's gone as well.

The quiescent output signal on the MCU pin through the filter has a 4 mv ripple, with out the filter the ripple is 20 mv. Whatever that is it's getting amped by the 5W amplifier while it's sitting idle.

Is the noise present with digital pin 5 set to an INPUT? (Upload an empty sketch.)

Standby I'll give that a try

Ahh, very interesting. That removes it. A code issue you think?

tone works with an interrupt. The timer 0 / millis / micros interrupt interferes (all other interrupts will interfere). The usual symptom is a ticking noise. The symptom varies depending on the generated frequency.

A simple easy test is to stop timer 0 after starting a tone. You can use _delay_ms instead of delay.