2025-06-17 5:39 PM
Hi all!
I am developing a midi pedal using the USB functionalities of the STM32F411. I want to use a software toggle to switch between Host and Device.
I am having this issue: I can't use OTJ Dual mode because it uses pin PA10, which I use for the UART (I actually only use sending for this UART, but for some reason, both pins are reserved anyway). I can toggle between Device_Only and Host_Only within STM32CubeIDE. How can I achieve that on the go in software? I don't mind if the device needs restarting in between. Any help will be greatly appreciated!
2025-06-17 5:44 PM
If you don't use PA10 otherwise, it would be easier to use USB OTG and set USART1 to single wire transmit mode.
2025-06-17 6:17 PM
Thank you very much for your reply!
It did manage to free up Pin PA10. For the record, in order to free up the unused USART pin, you need to set the mode to single wire on top of changing the data direction to Transmit Only.
Now that I can use OTG/ Dual role, could you tell me how to switch between the two in software? As far as I understand from the doc, Pin A10 is usually used to detect whether to set up as a host or device, but I would like to do it in software instead.
Thanks in advance!