Kinetis K20 "A request for the USB device descriptor failed."

cancel
Showing results for 
Search instead for 
Did you mean: 

Kinetis K20 "A request for the USB device descriptor failed."

Jump to solution
387 Views
haakonl
Contributor II

Hi,

I am trying to set up USB on a custom board with an MK20DX256VLL7. I am using the MCUOnEclipse HID-USB component and used his tutorial for the Teensy 3.1 USB to set it up, which uses the 87-pin version of the same microcontroller. The problem is that when I connect it to any Windows PC I get "Unknown USB Device" with the error "A request for the USB device descriptor failed.". I have googled a lot and most results suggest a hardware failure by connecting VOUT33 or VREGIN incorrectly which is something I originally did, however I think I have fixed that problem. Here's the schematic for the USB:

pastedImage_1.png

On VOUT33 I have placed a 2.2uF capacitor which goes to ground at R12, so I think the hardware is fine now.

Therefore I think it's a software problem, I just can't see why, as I have followed the MCUOnEclipse tutorial down to the last detail (except setting the crystal to 32Mhz, as that's what I am using) and double checked many times. 

Thanks for the help!

1 Solution
177 Views
mjbcswitzerland
Specialist V

Hi

An incorrect USB clock frequency is a typical problem - USB will not work even if the clock is off slightly.

Use the free open source uTasker project to test your HW. If will work on a Teensy 3.1 or any other HW without needing different libraries etc. It allows you to simulate the USB in Visual Studio and tells you of anything that is not suitable for USB operation.

Regards

Mark

Complete Kinetis solutions for professional needs, training and support: http://www.utasker.com/kinetis.html
i.MX RT project compatibility: http://www.utasker.com/iMX.html

Kinetis K20:
- http://www.utasker.com/kinetis/FRDM-K20D50M.html
- http://www.utasker.com/kinetis/TWR-K20D50M.html
- http://www.utasker.com/kinetis/TWR-K20D72M.html
- http://www.utasker.com/kinetis/TEENSY_3.1.html
- http://www.utasker.com/kinetis/tinyK20.html
USB: http://www.utasker.com/docs/uTasker/USB_User_Guide.PDF
USB composites: http://www.utasker.com/kinetis/USB_Device.html
USB-CDC host<->device video: https://www.youtube.com/watch?v=XhISV1czIo4&list=PLWKlVb_MqDQFZAulrUywU30v869JBYi9Q&index=16

uTasker: supporting >1'000 registered Kinetis users get products faster and cheaper to market

Request Free emergency remote desk-top consulting at http://www.utasker.com/services.html

Open Source version at https://github.com/uTasker/uTasker-Kinetis

https://community.nxp.com/thread/512558
https://community.nxp.com/thread/352862
https://community.nxp.com/thread/498809

View solution in original post

6 Replies
178 Views
mjbcswitzerland
Specialist V

Hi

An incorrect USB clock frequency is a typical problem - USB will not work even if the clock is off slightly.

Use the free open source uTasker project to test your HW. If will work on a Teensy 3.1 or any other HW without needing different libraries etc. It allows you to simulate the USB in Visual Studio and tells you of anything that is not suitable for USB operation.

Regards

Mark

Complete Kinetis solutions for professional needs, training and support: http://www.utasker.com/kinetis.html
i.MX RT project compatibility: http://www.utasker.com/iMX.html

Kinetis K20:
- http://www.utasker.com/kinetis/FRDM-K20D50M.html
- http://www.utasker.com/kinetis/TWR-K20D50M.html
- http://www.utasker.com/kinetis/TWR-K20D72M.html
- http://www.utasker.com/kinetis/TEENSY_3.1.html
- http://www.utasker.com/kinetis/tinyK20.html
USB: http://www.utasker.com/docs/uTasker/USB_User_Guide.PDF
USB composites: http://www.utasker.com/kinetis/USB_Device.html
USB-CDC host<->device video: https://www.youtube.com/watch?v=XhISV1czIo4&list=PLWKlVb_MqDQFZAulrUywU30v869JBYi9Q&index=16

uTasker: supporting >1'000 registered Kinetis users get products faster and cheaper to market

Request Free emergency remote desk-top consulting at http://www.utasker.com/services.html

Open Source version at https://github.com/uTasker/uTasker-Kinetis

https://community.nxp.com/thread/512558
https://community.nxp.com/thread/352862
https://community.nxp.com/thread/498809

View solution in original post

177 Views
haakonl
Contributor II

Hi Mark,

Thanks for the answer, and sorry for the late reply, though I figured it out just now.

You were correct regarding the problem being the clock frequency. I was using a 32Mhz crystal, which it says is compatible in the datasheet. When I tested with uTasker like you suggested, I noticed that 32Mhz crystals were not supported. I then replaced the crystal with a 16Mhz one and now it works! Luckily this project is not dependent on having a such fast crystal, so it's fine using a slower one. I'm however still not sure if the problem was that the Processor expert components didn't support 32Mhz or if it is the microcontroller itself.

Anyway, thanks a lot for the help and getting me in the right direction!

Regards,

Håkon

0 Kudos
177 Views
mjbcswitzerland
Specialist V

Hi Håkon

Your K20 can be run from a 32MHz crystal (this is its max. specified input frequency).

With a 16MHz crystal the setup for Teensy 3.1 is:

#define OSC_LOW_GAIN_MODE
#define CRYSTAL_FREQUENCY    16000000                                // 16 MHz crystal
#define _EXTERNAL_CLOCK      CRYSTAL_FREQUENCY
#define CLOCK_DIV            8                                       // input must be divided to 2MHz..4MHz range (/1 to /25 possible)
#define CLOCK_MUL            36                                      // the PLL multiplication factor to achieve operating frequency of 48MHz (x24 to x55 possible)
#define USB_CLOCK_GENERATED_INTERNALLY                               // use USB clock from internal source rather than external pin

Notice that the input must be divided to the 2..4MHz range and so an input divider of 8 is used.

In case a 32MHz crystal is used instead the only changes needed are

#define CRYSTAL_FREQUENCY    32000000                                // 32 MHz crystal

and

#define CLOCK_DIV            16                                      // input must be divided to 2MHz..4MHz range (/1 to /25 possible)

By dividing by 16 instead the input frequency is the same as when a 16MHz crystal in used; the rest remains identical.

Regards

Mark

177 Views
haakonl
Contributor II

Hi Mark,

That is what i originally tried, however when I do so I get the compilation error "..\..\..\Hardware\Kinetis\kinetis.c(2031): error:  #35: #error directive: crystal speed support needs to be added!". I tried adding the crystal support manually in the MCG settings, which made it compile, but the crystal didn't activate.

Regards,

Håkon

0 Kudos
177 Views
mjbcswitzerland
Specialist V

Hi

I see - the Open Source version uses an old method that requires each crystal used to have a suitable divider value. This is however not critical when using the PLL and a simple modification is to change

        #elif CRYSTAL_FREQUENCY == 24000000
    MCG_C1 = (MCG_C1_CLKS_EXTERN_CLK | MCG_C1_FRDIV_1024);               // switch to external source (the FLL input clock is set to as close to its input range as possible, although this is not absolutely necessary if the FLL will not be used)

to

        #elif CRYSTAL_FREQUENCY >= 24000000
    MCG_C1 = (MCG_C1_CLKS_EXTERN_CLK | MCG_C1_FRDIV_1024);               // switch to external source (the FLL input clock is set to as close to its input range as possible, although this is not absolutely necessary if the FLL will not be used)

If the crystal doesn't start it is possible that you have some additional loading in the HW (such as capacitors or feedback resistor) The TEENSY 3.1 has no loading and so uses the setting

#define OSC_LOW_GAIN_MODE

This must however suit the HW and so this may need to be un-commented (to use high gain mode instead) in order to allow a 32MHz crystal to start.

Regards

Mark

177 Views
haakonl
Contributor II

Hi Mark,

That probably explains it. I'll try that if I go back to the 32Mhz crystal again. Thank you so much for the help!


Regards,

Håkon

0 Kudos