• AVR Freaks

USB_CDC console generated code misuse of USB_DEVICE_ATTACH function ??

Author
Fadi Hammoud
Starting Member
  • Total Posts : 47
  • Reward points : 0
  • Joined: 2015/02/03 03:59:45
  • Location: 0
  • Status: offline
2018/10/01 01:49:19 (permalink)
0

USB_CDC console generated code misuse of USB_DEVICE_ATTACH function ??

Hi
From MPLAB Harmony Framework Reference, the USB_DEVICE_Attach Function description:
"This function will attach the device to the USB. It does this by enabling the pull up resistors on the D+ or D- lines. This function should be called
after the USB device layer has generated the USB_DEVICE_EVENT_POWER_DETECTED event."
When using the console system service and configuring it to use the USB_CDC peripheral, the generated code calls the USB_DEVICE_Attach Function (inside Console_USB_Tasks function) without waiting for the USB_DEVICE_EVENT_POWER_DETECTED event. On top of that, no USB_DEVICE_Detach function is called when a USB_DEVICE_EVENT_POWER_REMOVED event occurs.
 
What are the consequences of calling USB_DEVICE_Attach before detecting a physical connection to the host? and what are the consequences of not calling the USB_DEVICE_Detach when the host is disconnected?
#1

2 Replies Related Threads

    Fadi Hammoud
    Starting Member
    • Total Posts : 47
    • Reward points : 0
    • Joined: 2015/02/03 03:59:45
    • Location: 0
    • Status: offline
    Re: USB_CDC console generated code misuse of USB_DEVICE_ATTACH function ?? 2018/10/27 06:56:13 (permalink)
    0
     I requested support from microchip and they said that indeed there's something fishy and that the issue will be forwarded to the Harmony development team.
    post edited by Fadi Hammoud - 2018/10/27 11:02:12
    #2
    Fadi Hammoud
    Starting Member
    • Total Posts : 47
    • Reward points : 0
    • Joined: 2015/02/03 03:59:45
    • Location: 0
    • Status: offline
    Re: USB_CDC console generated code misuse of USB_DEVICE_ATTACH function ?? 2018/11/02 07:48:31 (permalink)
    0
    This is microchip's reply on the case:
     
    The USB specifications require that USB peripherals not source current on D+ or D- when the host/hub is not actively powering the Vbus line. A self powered USB Device firmware should make sure that it does not turn on D+or D- pull up resistor unless Vbus is actively powered. Harmony USB Device stack generates the event USB_DEVICE_EVENT_POWER_DETECTED when VBUS is active. 

    What are the consequences of calling USB_DEVICE_Attach before detecting a physical connection to the host? and what are the consequences of not calling the USB_DEVICE_Detach when the host is disconnected? 

    The answer to both the questions above are same. This is USB spec violation and the Device would fail USB compliance tests.
    #3
    Jump to:
    © 2019 APG vNext Commercial Version 4.5