corrected mag initialisation

the inner while loop should test for the exit condition at the end.
one out of two boards didn't complete the mag init phase.