stapelberg
Member
Hey,
I recently had the need to use my Teensy 3.6’s USB High Speed port in device mode.
As most development efforts seem to be focused on getting this port to work in host mode, I looked elsewhere.
I’d like to share what I learnt to provide others with a workaround until teensyduino libraries grow USBHS device mode support, and/or to help development of such a library.
I used the http://www.utasker.com/ operating system, which works on a number of kinetis micro controllers.
Hardware:
Step 1: cut the “USB Power” soldering bridge, which defaults to “Host”
Step 2: solder the “USB Power” soldering bridge to set it to “Device”
Step 3: solder a male pin header onto the “USB Host Port”
Step 4: solder a USB-A cable to a female pin header and connect it to the device (or use a breakout board like https://www.sparkfun.com/products/12035)
Software:
Step 1: clone the git repository. I used revision 656fbd42175125090484bf8426aa158487ac5130
Step 2: apply https://github.com/uTasker/uTasker-Kinetis/pull/3 if you’re building on Linux
Step 3: configure uTasker to build for the Teensy 3.6, run in high speed mode, enumerate a USB keyboard:
Step 4: compile uTasker:
Step 5: flash the resulting .hex file on your Teensy:
It seems like you need to power the Teensy via the microb port, i.e. merely connecting the USBHS port will not suffice — at least in my tests.
Hope this helps,
I recently had the need to use my Teensy 3.6’s USB High Speed port in device mode.
As most development efforts seem to be focused on getting this port to work in host mode, I looked elsewhere.
I’d like to share what I learnt to provide others with a workaround until teensyduino libraries grow USBHS device mode support, and/or to help development of such a library.
I used the http://www.utasker.com/ operating system, which works on a number of kinetis micro controllers.
Hardware:
Step 1: cut the “USB Power” soldering bridge, which defaults to “Host”
Step 2: solder the “USB Power” soldering bridge to set it to “Device”
Step 3: solder a male pin header onto the “USB Host Port”
Step 4: solder a USB-A cable to a female pin header and connect it to the device (or use a breakout board like https://www.sparkfun.com/products/12035)
Software:
Step 1: clone the git repository. I used revision 656fbd42175125090484bf8426aa158487ac5130
Step 2: apply https://github.com/uTasker/uTasker-Kinetis/pull/3 if you’re building on Linux
Step 3: configure uTasker to build for the Teensy 3.6, run in high speed mode, enumerate a USB keyboard:
Code:
diff --git i/Applications/uTaskerV1.4/app_hw_kinetis.h w/Applications/uTaskerV1.4/app_hw_kinetis.h
index 1f700fd..8aa9254 100644
--- i/Applications/uTaskerV1.4/app_hw_kinetis.h
+++ w/Applications/uTaskerV1.4/app_hw_kinetis.h
@@ -206,7 +206,7 @@
#endif
#define OSC_LOW_GAIN_MODE
#define _EXTERNAL_CLOCK CRYSTAL_FREQUENCY
- //#define USE_HIGH_SPEED_RUN_MODE
+ #define USE_HIGH_SPEED_RUN_MODE
#if defined USE_HIGH_SPEED_RUN_MODE // high speed run mode allow faster operation but can't program/erase flash
#if defined FRDM_KL82Z
#define CLOCK_MUL 16 // the PLL multiplication factor to achieve operating frequency of 96MHz (x16 to x47 possible) [PLL output range 90..180MHz - VCO is PLL * 2]
diff --git i/Applications/uTaskerV1.4/config.h w/Applications/uTaskerV1.4/config.h
index d306a79..e4b629e 100644
--- i/Applications/uTaskerV1.4/config.h
+++ w/Applications/uTaskerV1.4/config.h
@@ -127,13 +127,13 @@
//#define EMCRAFT_K61F150M // K processors Cortex M4 with Ethernet, USB, encryption, tamper, key storage protection area
-#define FRDM_K64F // next generation K processors Cortex M4 with Ethernet, USB, encryption, tamper, key storage protection area - freedom board http://www.utasker.com/kinetis/FRDM-K64F.html
+//#define FRDM_K64F // next generation K processors Cortex M4 with Ethernet, USB, encryption, tamper, key storage protection area - freedom board http://www.utasker.com/kinetis/FRDM-K64F.html
//#define TWR_K64F120M // tower board http://www.utasker.com/kinetis/TWR-K64F120M.html
//#define TEENSY_3_5 // USB development board with K64FX512 - http://www.utasker.com/kinetis/TEENSY_3.5.html
//#define FreeLON // K64 based with integrated LON
//#define TWR_K65F180M // tower board http://www.utasker.com/kinetis/TWR-K65F180M.html
//#define FRDM_K66F // freedom board http://www.utasker.com/kinetis/FRDM-K66F.html
-//#define TEENSY_3_6 // USB development board with K66FX1M0 - http://www.utasker.com/kinetis/TEENSY_3.6.html
+#define TEENSY_3_6 // USB development board with K66FX1M0 - http://www.utasker.com/kinetis/TEENSY_3.6.html
//#define TWR_K70F120M // K processors Cortex M4 with graphical LCD, Ethernet, USB, encryption, tamper
//#define EMCRAFT_K70F120M
@@ -946,10 +946,10 @@
#if defined USB_HOST_SUPPORT
#define NUMBER_USB (5 + 1) // physical queues (control plus 5 endpoints)
#else // define one or more device classes (multiple classes creates a composite device)
- #define USE_USB_CDC // USB-CDC (use also for Modbus over USB)
+ //#define USE_USB_CDC // USB-CDC (use also for Modbus over USB)
//#define USE_USB_MSD // needs SD card to compile (or alternatives FLASH_FAT / SPI_FLASH_FAT / FAT_EMULATION)
//#define USE_USB_HID_MOUSE // human interface device (mouse)
- //#define USE_USB_HID_KEYBOARD // human interface device (keyboard)
+ #define USE_USB_HID_KEYBOARD // human interface device (keyboard)
//#define USE_USB_HID_RAW // human interface device (raw)
//#define USE_USB_AUDIO // audio endpoints
#define AUDIO_BUFFER_COUNT (32) // this many isochronous packets can fit into the buffer (the buffer size is AUDIO_BUFFER_COUNT * isochronous endpoint size)
Step 4: compile uTasker:
Code:
% cd Applications/uTaskerV1.4/GNU_Kinetis
% make -f make_uTaskerV1.4_GNU_Kinetis
Step 5: flash the resulting .hex file on your Teensy:
Code:
% teensy_loader_cli -w -v --mcu=TEENSY36 uTaskerV1.4.hex
It seems like you need to power the Teensy via the microb port, i.e. merely connecting the USBHS port will not suffice — at least in my tests.
Hope this helps,