PWM kills RTC oscillator

I have a custom MCF52258 board design. It has an oscillator circuit with a 32.768 KHz crystal that drives the internal RTC. The oscillator and the RTC work normally until I turn on a particular PWM output. When the PWM output is enabled the oscillator circuit stops oscillating and therefore the RTC stops counting seconds. The PWM is operating in the range of 5 - 50 KHz with a 50% duty cycle. This problem occurs with PWM2 and does not occur with PWM4 or PWM6. The microcontroller is the 144 pin LQFP. On this package PWM2 (pin 12) is right next to the RTC_EXTAL pin (13).

Do you have any suggestions for how to fix this problem? Right now my best idea is to revise the board to use a different PWM channel.

There are three parts to any electrical interference problem - generation, coupling and sensitivity. There's also measurement.

Generation. Change PDSR[17]. This changes PWM2 between High and Low Drive Strength. What is that pin driving" Is it something that draws a large current? Is it a long track with a high capacitance? You probably should have a resistor in series with this track very close to the CPU to limit the current spikes.

Coupling. How close (and over what distance) is the PWM2 track running to the RTC track? What is the grounding of the RTC components like?

Sensitivity.Your oscillator is sensitive to interference. It may be unduly sensitive. Is the crystal case grounded? Are there any "ground shield planes" under the crystal, capacitors and tracks? RTC_EXTAL is the input to the oscillator from the RTC. This is a higher impedance than the RTC_XTAL output signal, so it is expected to be a bit sensitive. The amount of signal coupled to it from PWM2 depends on the mutual inductance and capacitance of these two traces together with the impedance of the RTC_EXTAL signal. The main influences on that are the crystal impedance and the parallel capacitance.See (from your crystal specifications) if you can increase the capacitance on this pin at all.

Play with the KHZEN, REFS and LPEN bits in the RTCCR in case they are set to the wrong values for your crystal.

Measurement: Can you see the interfering signal with an oscilloscope? It is likely the oscilloscope probe will either stop the clock on its own, or might even make the problem go away.

Finally, if the RTC oscillator is so sensitive to that signal it may suffer interference from other signals as well. It might be sensitive to induced noise and even temperature changes.

I had tried LPEN in RTCCR but have not tried the drive strength, PDSR[17]. The hardware designer is considering cutting back some ground plane to reduce board capacitance. And I'm going to pass along your other comments to him for consideration.