Partial resets?

I'm using a Pro Mini in a project dealing with high current, high frequency PWM, and as expected I'm having issues with EMI.

I'm using the PwmFrequency function to set the PWM frequency on pin 9 to 31.250Khz.

When I'm at almost full PWM value, the Arduino seems to reset .. however when (or sometimes if) it recovers, the PWM frequency seems to reset back to 490hz. The function to change PWM frequency is called in the setup(), so this would imply that it's actually skipping the setup() routine, and somehow going straight back into the loop.

Is there any explanation for this? I know EMI can cause electronics to do completely wacky stuff, but resetting mid-loop and not running the setup() routine again seems a bit odd?

It is far more likely that your "seems to reset" is not actually a reset...

Something is obviously being reset to default the timers back to the stock PWM frequency .. whether it's the entire uC or not is what I'm wondering. Maybe it's just somehow resetting the individual timer registers?

Maybe your code is corrupting the stack causing init to rerun.

Not the code, but could EMI do this too?

Things:
Not the code...

I'm curious to know how you arrive at that conclusion.

Everything works fine until I actually apply power to the load. The code is also extremely simple, I've done it many times before.

I'm driving about 15A worth of fans via PWM and some LC filters, and at ~32Khz I can only imagine some insane EMI from this setup.

There is a minimum pulse time for RESET so it is possible to have a "partial reset". The symptom I've seen is the processor locks-up. A power toggle is required to get it running. But the only time I've seen it is when uploading via ISP.

Add a low value resistor (or jumper) between RESET and +5V. Do not try to upload with the resistor (wire) in place.