Skip to main content
Visitor II
December 9, 2022
Question

STM32F769i-disco - is there a way to tell if the board is connected to USB like by using vbus or another facility?

  • December 9, 2022
  • 4 replies
  • 882 views

I'm really trying to tell if the board is connected to an external comm port to turn off usart sends so they don't potentially backup and slow things down. I know other products expose thinks like vbus sensing? Don't know much about it. I tried to find it in the board support code but unless there is another include file, I haven't had any luck.

Thanks

    This topic has been closed for replies.

    4 replies

    Super User
    December 9, 2022

    You can route VBUS to a GPIO pin (typically with a resistor bridge) and monitor that. If it disappears, de-initialize the USB. The schematic would show if this is done on that board.

    jhanc.11Author
    Visitor II
    December 9, 2022

    I saw some things about that yesterday and that 's pretty easy to implement. The real issue, and I don't know if so on the stm boards, but on an arduino, if you send data that isn't received, further sends will start backing up and slowing down the processor mainline. Now that I think about it more, I think what I'm really looking for is something to tell if nobody is listening on the virtual comm port. I looked at the usart registers as I brought up and down a serial monitor and they didn't seem to change. Maybe I need to implement some kind of flow control.

    jerry

    Super User
    December 9, 2022

    If you're talking about the VCP provided on ST-boards, there's no way for the chip to know if the other end is connected. The signals get converted to UART signals.

    If the other side isn't connected, the signal will still be sent.

    jhanc.11Author
    Visitor II
    December 9, 2022

    I can test this, but what about the transmit timeouts? Do they expire if the device on the other end of the vcom port don't receive them? Short of the other device sending an ack of some type, can you think of another way using the vcp to accomplish this?

    Super User
    December 9, 2022
    Data is still sent if the other side isn’t listening. It will not time out. You have no way of knowing if the other side is listening barring an ack system or external flow control.