5V to 400V boost converter problem
The voltage you get across the inductor is directly related to how fast you can stop the current flowing through it:
$$V = L \frac{di}{dt}$$
If you're hoping to get 400 V with a current of 32 mA, that means that dt must be no more than:
$$dt = \frac{L}{V}di = \frac{1.5 mH}{400 V} 32 mA = 0.12 \mu s$$
In other words, the current must drop to zero within 120 ns, which is not an easy thing to achieve. First of all, you're only driving the gate with an MCU pin (low voltage, limited drive current), which makes it difficult to change the gate voltage quickly. Second, the MOSFET itself takes some time to respond to a change in gate voltage. And finally, the distributed capacitance of the circuit, including the parasitic capacitance of the MOSFET, the diode and the coil itself, must be charged before the current will drop to zero.
As a first-order check, look at the self-resonant frequency of the coil itself. You will never be able to stop the current in the coil in less than a half-cycle of this frequency. This will put a limit on the maximum voltage that this circuit can achieve even if everything else is ideal.
Also, this is not a logic-level MOSFET. In order to get the switching characteristics shown in the datasheet, you need a 10 V gate signal. With only 5 V drive, you're probably not getting the full 32 mA you're expecting at the end of the &quot;on&quot; period. The rising voltage during the low portion of the drain voltage waveform is evidence of this.