Hi! :D
First: EMI = ElectroMagnetic Interference
I've recently wrote a small application to handle a PWM signal for a DC motor (generic, so maybe the PWM frequency could be not the optimal).
My board is an Arduino 2009 (for electrical knowledge) and I wrote the program in C unsing Atmel Studio 6.
It receive by UART a letter (a or b), space, number (0-255) and \n and manage this string to set the direction (a or b) and PWM DC (0-255) generated by the Timer 0. Optionally, I can use 2 buttons by interrupt (PCINT23 and PCINT0) and a potentiometer disabling the last data received by USAR allowing control to a user, in a joystick fashion control.
I've done this connecting my motor with a L293DNE driver, usign 2 channels per signal allowing to drive up to 1A.
Powering it with an external (or USB, is the same result) power, ONLY with PWM frequency >3,9Khz (prescaler less than 8, with 16Mhz -> see Duemilanove board) if I lock the motor, at higher DC (almost 100%) the program "crash". If would be an energy supply problem, the MCU should reset or not executing anymore instructions. BUT in my case, is not rsponding to UART commands neither variations to ADC value. When I meet this bug, motor is stucked at the last DC. But even the other pin (the one that should be a PWM with DC=0%=GND), now, is generating a different PWM, with total result PWM different from the one in output at the first pin.
Surprisingly, my MCU still receive button commands and reverse the rotation while proper button is pressed. But don't change the PWM, don't respond to serial, don't stop the motor if I open the button, it just reverse the rotation. It's like my MCU is in coma, and work weird.
You can read my code, here attached.
NOTE: when this AVR "coma" comes up, is when the motor driver send back more than 10V of overshoots from the motor (with a motor locked, case when mcu will start acting weird, but still dependent on its inductance) to the digital outputs. I saw that on oscilloscope.