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?
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?
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.