USB Host Mode Hack for the Freedom KL25Z Board


On the FRDM-KL25Z Board the target processor supports both USB host and device mode. However, the Freedom board has no jumper or other means to power the USB bus (which is required in the USB host mode). So if I want to get access to a memory stick from the KL25Z, then I’m stuck because the board does not offer that option. Luckily there is an easy hack to work around this.
Looking at the FRDM-KL25Z board schematics, there is 5V available on Pin 10 of J9:

5V on J9 Pin 10 on FRDM-KL25Z Board

5V on J9 Pin 10 on FRDM-KL25Z Board

The idea is to power the USB bus with 5V DC from the board itself. Normally I would use an ADML869L or similar device to have stable voltage and over-current protection. But attaching a memory stick or similar should be safe and would be protected through the other circuits and through the protection on my host.

So all what I need is to connect the power supply line on the USB host side of the cable. I cut the cable to prevent the current to flow back, just in case.

Usually in a USB cable the red wire is the VBUS/5V one, which connects to pin 1 of the USB plug. Cutting that cable and connected it with a probe tip:

Probe Tip to VBUS

Probe Tip to VBUS

That probe tip then connects to pin 10 on J9:

Power from Pin 10 on J9

Power from Pin 10 on J9

With this I can power devices on the USB bus, and I was able to enumerate a USB memory stick in USB MSD host mode on the KL25Z:

USB Host powered Memory Stick with the KL25Z Freedom Board

USB Host powered Memory Stick with the KL25Z Freedom Board

Happy Hosting :-)

About these ads

20 thoughts on “USB Host Mode Hack for the Freedom KL25Z Board

    • That applies to current used by that node on any shields as well.
      I’m surprised they have not added Polyfuses to the various supplies on that board. That aspect (power distribution) is not well thought out IMHO.

      Like

  1. Hi Erich,
    I will be very interested in a tutorial in using the KL25 in host mode.
    I mean how to read/write to devices like Memory sticks(MSD), USB Keyboard, Mouse (HID) etc, which .are the most common requirements
    This presents such exciting possibilities …. unfortunately, I do not know where to start, and I don’t want to read the entire USB 2.0 specs handbook to implement this :-).
    There are no examples at all for the KL25. in host mode (MSD & HID modes)
    Would you kindly do a tutorial (using processor expert, preferably) on how to use these devices with the FRDM board, or at the least point me to some starting point for the same ?
    Thanks!

    Like

  2. Thanks, Erich,

    I really want to move on from ‘Blinking an LED’ type projects to more serious, real world applications. (of course, the LED/Hello World projects are excellent starting points).
    Something that uses all the resources meaningfully … like read a couple of temperatures from the ADC inputs, display the same on an LCD, log the same with time-stamp to a memory stick, accept settings from a USB keyboard, control a couple of relays….. etc.
    Iv’e already done this (except USB) on 8 bit AVR MPUs…. just need to become good with the KL25Z (mainly understand the architecture/registers & the APIs involved) :-)

    Thank You.

    Like

      • Oh I agree, and understand … you are doing a great service to the FRDM-K25Z user community. Hats off to you!
        Freescale should give you a substantial raise, and put you on this free time work ,full time officially! You are doing a much better job at familiarising users with their new board.
        Many users jumped at the FRDM board because of low cost, excellent peripherals, and better CPU, but now (official) documentation / examples are poor.
        I hope this will change in the days to come !

        Like

  3. I’m really new with FRDM-KL25Z. (approx. 1 day) And was looking for some example code for using the device as a HID keyboard (I’d read some data and “type it in” for easy and fairly compatible use – much like a barcode reader does.) when I found this post.

    While reading your post I wonder why aren’t you using two Y cables and a female-female connector. That would make better use, i guess. (Of course a USB HUB is the easiest way in my reading, but it involves a spare power source, lowers speed etc….)
    Then you could use the same power source that powers your device thru the OpenSDA Port.

    My layout would be:
    plugging the USB drive in a Y cable (i found this example: http://www.goldcomp.hu/components/com_virtuemart/shop_image/product/93353.jpg)
    Plugging one Y cable in the OpenSDA port (e.g.: http://www.goldcomp.hu/components/com_virtuemart/shop_image/product/93587.jpg)
    And connecting the two spare power ports with a female-female adapter (e.g.: http://www.amazon.com/USB-Type-Female-Adapter/dp/B000GHXTA0)

    No cable ruining/cutting, and if you are changing to a power source from the OpenSDA connection you can still use the same Y cable with a double USB psu (or then for the production environment you can make a fixed USB plug with the “red wire” fixed to the PSU)

    Like

    • Yes, you could do it that way. All what you need is a way to provide 5V to the KL25Z USB Vdd pin. I did not had such adapters available, so cutting an existing cable is a low-cost and fast solution in any case.
      As to use the FRDM as HID keyboard device (not host!), you even do not need such a power cable construct: here the PC/host is poviding power, so you can simply plug in the FRDM board as-is to your computer.

      Like

  4. Pingback: USB MSD Host for the Freedom Board | MCU on Eclipse

  5. Pingback: A new Freedom Board: FRDM-K20D50M with ARM Cortex M4 | MCU on Eclipse

  6. Pingback: FRDM-KL25Z RevE Board arrived | MCU on Eclipse

  7. Pingback: USB MSD Host for the FRDM-K20D50M Board | MCU on Eclipse

What do you think?

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s