microcontroller is "hanging" when it is feeding PWM to a DC motor controller
If your sketch is to be trusted, you haven't included a decoupling capacitor for the ATmega328P.  

That's most likely the cause of your problems - especially since you mention it working correctly if you power the ATmega328P and the motor driver from seperate power supplies.

There are tons of questions and answers on this site about what decoupling capacitors are and how to use them.

You probably need at least a 100nF capacitor from ground to each Vcc pin on the ATmega328P.  

Since you show two Vcc pins, you will need two capacitors.  Place each capacitor as close as possible to the Vcc pin it serves.

You may also need a single, larger capacitor on the board with the ATmega328P.  Say, like, 1 to 10uF.

Try that out, and read up on decoupling capacitors.  You will encounter them often in pretty much all kinds of circuits.