HEXFET PWM motor driver does not work
You need to ensure that the PWM source &amp; the FET are referenced to the same potential.

FET's turn on when the Voltage between their GATE &amp; their SOURCE is greater than their threshold (actual characteristics are then determined by the driving characteristics.

If the 0V of the PSU powering the electrical machine is say... 5V higher than the 0V that is powering your controller ( STM32F4 ) then you will not be able to turn on the FET. 

how are the the two 0V connected ? what is the potential difference between the two 0V (the laptop/USB 0V and the PSU 0V)