Separate the microcontroller DC supply from the motor supply, with a schottkey diode and a large capacitor on the microcontroller side. This should allow it to ride out short voltage dips on the main supply.
Bonus points if you canYou should do this before the 5V regulator, then the microcontroller will have a completely stable DC supply.