Electronic – Is printf debugging over USB with STM32 possible

cstm32stm32f10x

I've been doing a lot of searching to try find some examples for printf debugging over USB for the STM32 (specifically stm32f1x). I have found a few examples for UART/USART however I can't find any for USB. Can anyone tell me if this is indeed possible and if it is point me to some examples?

Thanks.

Best Answer

printf debugging over USB for the STM32

There is CDC example code that one could use for printf().

But I would not recommend using this, because USB is rather brittle in case of programming errors: The USB interrupt must be working correctly, the host won't accept the device otherwise.

Printf over UART/USART is far simpler, and you may need this connection for the bootloader anyway. Unless you have a JTAG/SWD debugger - but then there is no need for printf debugging in the first place.