• AVR Freaks

Hot!Wake USB Host micro when thumb drive connected

Author
AndrewKED
New Member
  • Total Posts : 12
  • Reward points : 0
  • Joined: 2010/09/10 14:48:57
  • Location: 0
  • Status: offline
2020/07/21 14:21:46 (permalink)
0

Wake USB Host micro when thumb drive connected

I have a battery-powered data logger which spends most of its time asleep. It wakes every second to briefly sample data.
 
It has a 4-pin USB interface for a thumb/flash drive. The micro can enable a low quiescent current 5V supply for VBUS (which is also connected to microcontroller VBUS pin)
 
What would be the best method, for lowest power consumption, to detect the insertion of a USB thumb drive. The microcontroller would wake up and perform a data dump and then sleep again.
 
Can one use on something like a port state change in D+ or D-?
#1

3 Replies Related Threads

    AndrewKED
    New Member
    • Total Posts : 12
    • Reward points : 0
    • Joined: 2010/09/10 14:48:57
    • Location: 0
    • Status: offline
    Re: Wake USB Host micro when thumb drive connected 2020/07/21 14:52:32 (permalink)
    0
    Further info:
    The data logger uses a PIC24FJ256GB406 and MLA USB library. The USBTasks() macro is being called by the code once per main loop. The main loop normally only executes once, and then sleeps until woken (at 1Hz). When external power is applied to the logger (or when the logger needs to), it does not sleep, but remains awake in the main loop, executing all the various system handler functions.
    I would like to be able to detect and respond to the insertion of a flash drive in both the low-current periodic sleeping mode as well as the "fully on" mode.
    #2
    ric
    Super Member
    • Total Posts : 28024
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: Wake USB Host micro when thumb drive connected 2020/07/21 15:25:07 (permalink)
    5 (1)
    The USB device will raise D+ or D- to 3.3V when it tries to "enumerate", so yes you could detect that.
    I don't know if your USB library needs to see the transition itself though...
     

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #3
    AndrewKED
    New Member
    • Total Posts : 12
    • Reward points : 0
    • Joined: 2010/09/10 14:48:57
    • Location: 0
    • Status: offline
    Re: Wake USB Host micro when thumb drive connected 2020/07/21 16:32:13 (permalink)
    5 (1)
    Thanks for the advice ric!
     
    I've tried the first stages of this method. I'm using the Interrupt-on-Change mechanisms on the D+ and/or D- ports. If during my 1Hz wakeup, a rising edge has been detected on D+ and/or D-, the micro stays awake, and runs the USBTasks(). This gets everything working quickly, and it seems to all be correct.
     
    I now just need to add some debounce control and extraction detection.
     
    (I had noted this comment against USBHostTasks() : "This routine should be called on a regular basis, but there is no specific time requirement.  Devices will still be able to attach, enumerate, and detach, but the operations will occur more slowly as the calling interval increases." Since I had only been calling it once per waking cycle, I saw that it was going to take ages to make an attachment.)
     
    #4
    Jump to:
    © 2020 APG vNext Commercial Version 4.5