STM32F427ZG Custom Board Runtime Error reset does not turn off pins

Another way is to use the SWO (Serial Wire Output), available on pin PB_3 of the STM32 targets, as described at
https://forums.mbed.com/t/hitchhikers-guide-to-printf-in-mbed-6/12492/38