K20 USB malfunction

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

K20 USB malfunction

Jump to solution
1,670 Views
kai_liu
Senior Contributor I

I designed a board based upon MK20. In order to test the hardware, I reuse mbed bootloader for MK20 as testing firmware.

In Keil MDK4, I can easily detect the chip, erase, and download the code, which is checked out from github, built by Python and MDK4. So we can conclude that at least power supply, SWD/JTAG interface is correct, and reset works as well.

The current issue is USB malfunction reports by Windows. Sometimes, the device can bring system into driver installation procedure, but usually it will stop since the communication is not stable.

My circuit is different from other board, which is powered by USB 3.3V regular, which offers 120mA at 3.3V. But I think it is enough for a self-powered application, since it has not connected to any peripheral yet, just be used to power K20 itself.

Additionally, because the 8MHz crystal in FRDM board is quite expensive, I used a local 8MHz crystal, with 20pf internal capacitor, slightly different from 18pf version used in FRDM board. However the external C1/C2 I use the same value, 22pf. Should I change it, which value is the correct? Is there any formula/table available?

At last, I removed 1M Ohm resistor close the crystal, since it is DNP in FRDM-K20D50M as well as debugger micro which use QFN32 K20 as well.

Tags (2)
0 Kudos
1 Solution
952 Views
santiago_gonzal
NXP Employee
NXP Employee

Hello Kai Liu,

I have seen several USB designs where the problem was the line terminator resistors.

You could try reducing those values.

Regards,

Santiago

View solution in original post

0 Kudos
13 Replies
952 Views
Kan_Li
NXP TechSupport
NXP TechSupport

Hi Kai Liu,


If you suspected the crystal's circuit or itself introduce more jitter which causes the signal issue, you may change the crystal back to what on FRDM board, just for test, if the application code well after such change, we will focus on hardware then.BTW, I think the crystal vendor should provide ref design or recommendation for the product, you may also ask for suggestion from the vendor.

Hope that helps,


Have a great day,
Kan

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
952 Views
kai_liu
Senior Contributor I

Hi, Kan,

I don't think a commodity product (like MOSFET or crystal) supplier should offer reference design for an application system, especially when the oscillator is inside the micro.

FSL should offer some AN on it based upon major sources. What I am trying to find is some document to tell me how to caculate the matching capacitors.

However, arguing on this topic doesn't help. I will try to find a 18pF crystal, anyway.

I also connect the micro via my debugger, maybe I can find something wrong from the code. So far, I find the bootloader will jump to user application unless the reset pin is held, lack of checking the availablity of user application. After jumping into user application, it falls into main idle loop.

So. the external crystal is working, otherwise it will stop on crystal init while loop before running into main. (although I haven't measured its accuracy). The code is working as expected.

0 Kudos
952 Views
Kan_Li
NXP TechSupport
NXP TechSupport

Hi Kai Liu,

Sorry for the misunderstanding! What I mean is the data sheet provided by the vendor, it is something like the following:

1.png

2.png

You may find recommendation and ref schematics from that. Actaully if the crystal circuit introduces more jitter than USB spec, that would cause signal issue, so that the communication would be unstable.


Have a great day,
Kan

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

950 Views
kai_liu
Senior Contributor I

Yes, Kyocera, EPSON, TDK, they are good and professional.

But usually we can only find some low-end cystals like YXC...:smileyhappy: in China. I agree, maybe saving money on crystal is stupid.

0 Kudos
952 Views
DavidS
NXP Employee
NXP Employee

Hi Kai,

Might I suggest using the K22?  It is one of the newest Kinetis devices that does not require external clocking for USB operation.

http://www.freescale.com/webapp/sps/site/prod_summary.jsp?code=K22_100&nodeId=01624698C9DE2DDDA7

The Kinetis K22 MCU family expands the Kinetis K series with new, low-power ARM® Cortex®-M4-based MCUs while keeping full software, hardware and development tool compatibility. These MCUs are further optimized for cost-sensitive applications requiring excellent processing efficiency with floating point unit, USB connectivity with crystal-less USB functionality, and industry-leading low-power. The Kinetis K22 100 MHz family offers 128 KB of embedded flash memory, and package options include LQFP and MAPBGA.


There is also a Freedom board for it:

FRDM-K22F|Freedom Development Board|Kinetis|Freescale 

Regards,

David

0 Kudos
952 Views
kai_liu
Senior Contributor I

Thanks, David,

For long term plan, definitely I will switch to K22. I have to close this case first, anyway.

0 Kudos
953 Views
santiago_gonzal
NXP Employee
NXP Employee

Hello Kai Liu,

I have seen several USB designs where the problem was the line terminator resistors.

You could try reducing those values.

Regards,

Santiago

0 Kudos
952 Views
kai_liu
Senior Contributor I

Hi, Santiago,

You are right. After changing terminator resistor from 33R to 22R. It works. I have verified by dozens of times.

Thanks for pulling me out of this issue.

For crystal, I summarized although MCG in FSL is complex, it does not sensitive to crystal by load capacitor at all.

Yours sincerely

Allan K Liu

0 Kudos
952 Views
santiago_gonzal
NXP Employee
NXP Employee

Hi Kai Liu,

My apologies for not answering the last few days...a lot of work in my task list :smileyhappy:.

I'm glad that you've resolved your issue. I'm not an expert in PCB design for USB, but I've seen several customers with a similar issue, and apparently USB is quite demanding in the final design of the D+ and D- line termination resistance. :smileyhappy:

Regards,

Santiago

0 Kudos
952 Views
kai_liu
Senior Contributor I

Thanks, I will refer to basic USB hardware design guide line to revise my PCB design.

952 Views
kai_liu
Senior Contributor I

Hi, Do you suggest a smaller terminator resistor to improve eye-diagram of USB?

0 Kudos
952 Views
kai_liu
Senior Contributor I

Hi, Santiago,

After reading a lot of documents regarding OSC/MCG and pierce oscillator, I found your point maybe the right direction. Would you please tell me which value is better than 33R?

I have tested more code in Keil and IAR. I found pll_init() can not prove that is a crystal related issue. In fact, it more and more strongly hints my crystal works well. Please check my another thread: K20 pll_init() failed after reset in IAR EWW debugger

No matter which code is running.

In EWW, MCG_S = 0x6E shows LOCK0 =1 , LOLS0 = 0

In Keil, MCG_S = 0x6E after SystemInit for MCG setup, which demonstrates the PEE works well.

I tried to enable MCG_C2::LOCRE0 and MCG_C6:CME0, and setup a point after reset. It never runs into reset. So the crystal is good.

0 Kudos
952 Views
kai_liu
Senior Contributor I

Thanks Santiago.

I have used 33R for line terminator resistors, as same as other projects. Maybe it is not your case, since the PLL clock is not stable in debug session .

So.. I have switched to IAR platform with original source from FSL (usb_device.eww from kinetis_50MHz_sc\k20d50m_sc_baremetal) to find out its issue.

At first run, it stops at usb_main.c::main(), when I step into CDC_Engine(), OS prompts Unrecognized USB device. Then I pressed reset, it stops at

mcg_clk_hz = pll_init();

if (mcg_clk_hz < 0x100) while(1);          sysinit.c::sysinit()

The code runs in the following procedure:

MCU POR

     |->start.c::start()

          |->sysinit.c::sysinit()

               |->mcg.c::pll_init()

                    MCG_S = 0x0A (OSCINIT0=1, CLKST=2), so it returns error as 1, fall back while loop in sysinit()

          |->usb_main.c::main()

I tried more times. In most cases, it stops in sysinit(). Therefore, I conclude

  1. The oscillator sometimes works, so it can run into usb_main.
  2. In most cases, it doesn't work well, so it falls into while loop.

I have checked the init code of mbed bootloader and interface firmware, it uses RTOS, I am not good at debugging a RTOS application. However, it is really strange for me, since the code always jumps into main idle task.

Kan I will try to apply some samples from Abracon. Does FSL has any other recommendations? I have checked my PCB design for crystal. There is a reset line below crystal. I will cut off the trace and use fly-wire for that net.

0 Kudos