How to implement a real working USB 2.0 CDC without crystal in MK64FN1M0VLL12?

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

How to implement a real working USB 2.0 CDC without crystal in MK64FN1M0VLL12?

1,099 Views
marcoantoniodeo
Contributor II

Dear sr.

I am a hardware/software designer here in Brazil working for the Post (ECT). We are developing a protocol translator (Siemens/USS over RS485) using MK64FN1M0VLL12 (I got some free samples from NXP. Thank you very much). The UART part has been accomplished, but there is this demand to send some data to a USB host. In my hand-made board everything works like a charm through debug console (I put a 16 MHz crystal to pins 50-51 LQFP 100 pins package) but I got a “unknown device” in Windows when I try IRC48 MHz configuration.

I´ve searched the forum and I´ve read these posts so far:

IRC48M Clock Synchronisation with USB Mark Butcher  18 de Fevereiro de 2016 05:55:22

Crystal-less USB operation on Kinetis FRDM64F platform with IRC48M. qingjun wang 24 de Setembro de 2014 04:15:28

And AN4905.

Unfortunately, I cannot help myself till now.

So the question, this specific micro-controller really works USB crystal-less?

We are in the proceedings of manufacturing some boards for testing in site. It works fine for the job it is required. And I know I can put an FTDI converting or so on the USB/UART side, but it will be nice to use on-chip USB feature that I brag about to my boss. Of course I can put a 16 MHz crystal into the board too, but a company has already been contracted to build it and I have not time to redesign the PCB.

 

Thanks in advance.

 

Marco

Labels (2)
5 Replies

826 Views
marcoantoniodeo
Contributor II

20190220_143119[1].jpg

Hi all,

 

Boards arrived. As I suspect I have a bogus MCU on my prototype kit. USB now is working like a charm (IRC48 or external clock).

Thank you Mark for all your help.

 

Marco

826 Views
mjbcswitzerland
Specialist V

Hello Marco

The K64 can be used in crystal-less mode as a USB device (it can't as a host, but I understand you are a device).

See the section about IRC48M (including workaround) at http://www.utasker.com/kinetis/MCG.html

All code, which has been verified in industrial products for a number of years, is available in the free open source project on GitHub, which includes automatic workarounds for older K64 parts that have an errata in the operation (that is, you don't need to worry about which revision of silicon you actually receive during the manufacturing lifetime).

At the links below there are various binaries that can be loaded to standard boards to see it in operation, including USB-to-5 UARTs (it supports end to end flow control on all USB<->UARTs bridges [and a switchable console on the first], plus the mode can be used in parallel with USB-RNDIS and supports MODBUS over USB too).

If you are working on a professional development you can also license the project, including person support to ensure mission critical needs. The modes have been proven in real industrial products operating reliably for a number of years (including in crystal-less mode).

Regards

Mark


Kinetis: http://www.utasker.com/kinetis.html
Kinetis K64:
- http://www.utasker.com/kinetis/FRDM-K64F.html
- http://www.utasker.com/kinetis/TWR-K64F120M.html
- http://www.utasker.com/kinetis/TEENSY_3.5.html
- http://www.utasker.com/kinetis/Hexiwear-K64F.html

0 Kudos

826 Views
marcoantoniodeo
Contributor II

Hello Mark,

 

First of all, thank you for your readiness in helping me.

As I can see this is still an interesting topic as many has read this thread till now.

I`ve uploaded the bin file into my board but it didn´t work (the USB, I mean). As I mentioned above this is a hand-made PCB, so there must be a hardware fault after all.

I took the liberty to attach a link to the schematic for further help:

https://easyeda.com/editor#id=2b73a1a614f04f84b376c955610659c1

See, in the datasheet VREGIN goes up to 5.5V and works as an input but VOUT33 works as an output. So they are in different circuitry inside the MCU, right?

Although in page 75 of the same datasheet one can read “Connect VREGIN and VOUT33 together and tie to ground through a 10 kΩ resistor. Do not tie directly to ground, as this causes a latch-up risk.”

This is a bit of confusing. I my case it works only when I tie them to 3.3 VCC directly, as you can see in the page 1 of my schematic. I tested the 10 K Ohm resistor too with no avail. Well, in that page it is written “Unused analog interfaces” but USB is not analog, right?

Am I doing it right? I am not an expert in this issue, so in the final board I´ve put 0402 pads arranged in a way that I can choose what to do with soldering iron, for I am hoping that in a machine-made PCB with all neat tracks, length tuning etc. it will work.

For the software part, I forgot to mention that I am using KDS 3.2.0 and KSDK 1.3.0

In AN4905 I cannot find USB_CLK_RECOVER_CTRL[CLOCK_RECOVER_EN anywhere. So, could you direct me to where in the code is that MACRO? I´ve searched system_MK64F12.c, fsl_clock_MK64F12.c and headers alike.

Perhaps you could send me a PE project so I can open clockMan1:fsl_clock_manager and see what is actually happening. The examples in KSDK give me the “no rule to make target” error…

We are not going to commercialize this board, it is for our plant environment only and yes, it will work as a device. In this system there´s a lot of serial trafficking and 24 VCC I/O and they must be synchronized so triggers and timers go to a USB console to feed a log. I will have a chat with my boss about licensing it, anyway, thanks for your advice.

I know I´ve made a lot of “asks” on many different issues, just in the end of the year… sorry for the inconvenience for I am from 8 bit era and I put this as a personal goal.

So, then again, thanks in advance and Happy Holidays.

Marco

0 Kudos

826 Views
mjbcswitzerland
Specialist V

Hi Marco

I don't know whether you loaded a binary file that is suitable for your board - it may expect the 50MHz oscillator on the FRDM-K64F board and so not be starting correctly.

Therefore I have built a version that runs entirely from the IRC48MHz (as main clock and for USB device) - I also blink your HB LED at 2.5Hz so that it can be seen that it is running.

The USB should appear as USB-CDC.

It is however very likely that you have a HW problem because the USB PHS is an analogue circuit and needs to be powered. VREGIN and VOUT33 are only tied together when not used - it is best to use the standard circuit which is to connect VREGIN to the USB 5V (so that it is only powered when USB is connected) and add a 2.2uF capacitor (low ESD) to VOUT33 (without this the circuit is not stable and USB may not operate).

Regards

Mark

P.S. I also see that you have a 16MHz crystal, which can also be used with USB (together with the PLL), so crystal-less operation wouldn't be absolutely necessary.

0 Kudos

826 Views
marcoantoniodeo
Contributor II

Hi Mark

 

Yes, I noticed the 50 MHz crystal, I replaced it before updating my prototype board with your last bin file.

Now with this new one, I´ve followed the FRDM-K64F reference design on page two. I´ve put VREGIN to USB 5V, put the cap, uploaded the bin file, but the HB LED goes always on, forever, and nothing happens on Windows Device Manager, not even an error message appears.

As I´ve told you in the previous message, I don´t know why, but in my prototype board USB only works when I tie VREGIN to VOUT33 to 3.3V directly. May it be a MCU fault then? I don´t have another one hanging around.

In the final board there will not be a 16 MHz crystal, for I was expecting it to work, perhaps I was not clear, my fault.

About two weeks ago I received authorization to produce the board, so I removed the 16 MHz on my prototype board and then begin to test it without external crystal (Yes I know, just now?) and only with IRC48M, and for my surprise, it doesn´t work. 

I´ve updated the prototype schematics so you can see what I did:

https://easyeda.com/editor#id=2b73a1a614f04f84b376c955610659c1

Deadline is 02/01/2019

This is not a critical problem anyway, I can put the external crystal by hand when the boards arrive.

Thank you for your help and spending time.

Marco

P.S. That uTasker thing it´s an amazing, awsome job. Congratulations.

  

0 Kudos