Transistor based relay driver for DC motor is not working with 12V-8A DC motor?
You are very probably getting inductive coupling from the motor into the processor - possibly via the power supply but can be via drive circuit and possibly even radiated.
You may also be getting power supply "dropout" due to motor startup loading.

Power supply voltage should not drop uC rail voltage under Voperate_min ever - easy to check. Then ...

In approximate order, try (additively):
Diode across motor, reverse polarity.
Diode across relay coil, reverse polarity.
Larger capacitor at uC on psu rail to ground..
Large capacitor at motor psu feed.
Small series resistor in series with motor. (Drop say &lt; 5% at full load)

Semi orthogonally to the above:
Caps on signal line - too large will hurt operation.
Opto isolator signal drive.



Optical isolation:

An opto isolator breaks the noise conduction path 

This shows what is often done to achieve optical drive isolation for relays. 

This image shows a typical circuit wit more overkill than needed.
U1 provides the actual isolation.

R2, DA &amp; D2 are not essential to operation, but are nice to have.
U1 is driven by a low signal at "IN" but could equally have "IN" grounded and be driven with a high at P1-VCC.
VCC and JDVCC are usually connected by a jumper and fed with 5V (for 5V coil relays.) This partially bypasses the noise isolation and destroys any electrical isolation. A common ground also prevents true isolation. Still useful. 



From this web page and looks like this commercially: