CDC on K60

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

CDC on K60

1,990 Views
michaelmccarric
Contributor I

Hello,

I am using the Freescale USB Stack version 4.1.1 in a K60 based system.  The CDC code is operating as long as the USB cable is not connected when the system is started.  If I start the system then connect the USB cable I can open the associated COM port and communicate.  If the cable is connected when the system first starts or after a reset I am not able to connect (open the associated COM) port.  I must unplug and replug the USB cable while the K60 is running before I can open the associated COM port.

Any suggestions on how I can get this to work such that the USB cable can be connected while the K60 is powered up?

Thanks,

Mike

Labels (2)
0 Kudos
17 Replies

1,278 Views
BlackNight
NXP Employee
NXP Employee

Hi Mike,

I don't have that problem on my side (Windows). I can start the board with the USB cable connected. The only important thing is that the COM port shall not be open.

So this is how it works for me:

- COM port not open

- power the board with the USB cable

- Open the COM port and communicate

Having the COM port open while the board stops responding to USB messages, or having the COM port open from a previous board/removed board will fail the communication. I have been told that this is a Windows driver problem with USB CDC.

I hope this helps,

Erich

0 Kudos

1,278 Views
michaelmccarric
Contributor I

I used the CDC example as a basis for my code. Running as a Device.

I am using my own software running on the Windows platform for communication with the K60/CDC enabled device.

With no com port open (my Windows software is not even running).  If I power up my board with the USB cable connected, the Windows Device Manager (Windows 7 x64) lists the connection as "Unknown Device".  If I disconnect the USB cable (with the instrument still powered) and reconnect the cable it shows up as an available COM port.

Erich, what hardware are you using?  Is it K60 based?  Is it only running the CDC example?

0 Kudos

1,278 Views
BlackNight
NXP Employee
NXP Employee

Hi Michael,

I'm using several different hardware (KL25Z,KL46Z, ... and as well K60 (see USB with the TWR-K60F120M and TWR-K70F120M | MCU on Eclipse).

They are running the CDC device class, but not only doing USB, of course.

Erich

0 Kudos

1,278 Views
BlackNight
NXP Employee
NXP Employee

Hi Michael,

Just in case, I have attached my project which is explained in USB with the TWR-K60F120M and TWR-K70F120M | MCU on Eclipse).

That project is on GitHub too: mcuoneclipse/Examples/TWR-K60F120M/TWR-K60F120M_USB_CDC at master · ErichStyger/mcuoneclipse · GitHu...

It is a CodeWarrior for MCU10.6 project, but you can download the .elf in the zip file with any tool you want, and try it out on your side.

Erich

0 Kudos

1,278 Views
michaelmccarric
Contributor I

Hello,

I am developing with the Keil tools.  I built up the CDC example for Keil project for the K60 which is included with the USB Stack version 4.1.1.  With this project (running nothing other than the CDC example) I can connect the USB while the K60 is powered off.  Then power on the K60 and it is recognized by the PC.  However if the K60 resets (without cycling power) I can not open the virtual port.  This is the process

1. Start with the USB cable disconnected and the K60 powered off.

2. Connect the USB cable.

3. Power on the K60.  The Freescale CDC Device (COM15) is displayed in the Windows Device Manager.

4. Open COM15 and exchange characters with the K60 (works as expected, echos back what ever is sent to it).

5. Close COM15 (exiting the application that was communicating with the K60).

6. Reset the K60 (without powering down).

7. Open application that was previously communicating with the K60 via the virtual com port.

8. Try to open COM15.  It fails, unable to open port.

At least now I can cycle power with the USB connected.  Maybe my code is taking too long to initialize the USB after powering up.

But if the K60 resets (without powering down) the virtual COM port is hosed.

I noticed that the K60 is not supported in version 5.0 of the USB stack.  Why is this?

Thank you for spending the time to help me,

Mike

0 Kudos

1,278 Views
Kan_Li
NXP TechSupport
NXP TechSupport

Hi Mike,

I tried to reproduce your issue based on TWR-K60N512 and TWR-SER, but failed . The following is my test process:

I powered the whole system via TWR-ELEV, and use another USB cable to connect PC Host with this CDC device, the Device Manager detected this device and set it as COM22, I could connect with this port via HyperTerminal, and this CDCdemo worked just as expected. Then I closed HyperTerminal and pressed the Reset button on TWR-K60N512, I saw COM22 dispeared while I kept pressing the Reset button, and Host recognized it as COM22 again right after I released that button, and this port worked well with HyperTerminal.

so I am wondering if you modified the CDC demo in USB stack ver 4.1.1, or did you test it based on a custom board? Please kindly help to clarify. Thanks for your patience!

BTW, BM USB stack ver 5.0 is the last stand alone BM stack version, the further version will be released with KSDK, and K60D100M will be supported in the next release. you will have it in Dec.2014 or so.


Have a great day,
Kan

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

0 Kudos

1,278 Views
michaelmccarric
Contributor I

I am using the unmodified CDC example.  I am running it on our own custom hardware.  I am resetting it using the debug adapter and not a reset button.  Maybe the reset of the debug adapter is not a proper reset.  It would however be similar to the reset of a watch dog timer.  Maybe?

0 Kudos

1,278 Views
Kan_Li
NXP TechSupport
NXP TechSupport

Hi Michael,

It depends on your hardware design, if based on TWR-K60N512, the reset of debug adapter is connected with MCU's reset pin, so issuing a reset command via jlink commander is same as pressing the Reset  button, but jllink would pend the MCU after reset till you issue the "go" command, actually I am not sure if you are using a jlink or something else, but with my test, the CDC demo works well even with a debug adapter attached , please kindly refer to the following for details.

Untitled.png

would you please help to clarify how you reset the board via the debug adapter? Thanks for your patience!


Have a great day,
Kan

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

0 Kudos

1,278 Views
michaelmccarric
Contributor I

Note that when I reset the K60 with the debug adapter the CDC is still listed in the Device manager.  It is when I try to open the port that it fails.

0 Kudos

1,278 Views
Kan_Li
NXP TechSupport
NXP TechSupport

Hi Michael,

You may refer to TWR-SER for reference: http://cache.freescale.com/files/microcontrollers/hardware_tools/schematics/TWR-SER-SCH.pdf?fpsp=1

To reset USB_OTG module in code, you may set USBx_USBTRC0[USBRESET].

After you reset the micro using the RST toolbar button, have you press F5 to kick off the application? I am wondering if the issue is due to the delay between these two steps so that Host treat it as a timeout event and notified it as a unknown device.


Have a great day,
Kan

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

0 Kudos

1,278 Views
michaelmccarric
Contributor I

Hello,

Thank you for the link.  My design does not have the MAX3353E.  Maybe this is the significant issue.  Do you know if it would be?

What are USB_DM_PDOWN and USB_DP_PDOWN used for?

Mike

0 Kudos

1,278 Views
Kan_Li
NXP TechSupport
NXP TechSupport

Hi Michael,

MAX3353E is used for OTG application, as well as USB_DM_PDOWN and USB_DP_PDOWN, so if you dont use it for OTG, you may skip these parts. For a USB device application, what you should pay attention is the serial resistors between D+/- and USB0_DP/DM, you know, the USB spec requires a 90 OHms differential impedence so the single trace impedence to ground should be 45Ohms, so please calculate the trace impedence and get the correct serial resistor value, otherwise there would be communication issue during data transaction.

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

1,278 Views
michaelmccarric
Contributor I

I found the root of my problem.  We have a 1.5k pull-up on the D+ line as per the USB design specification.  It appears that maybe the K60 has an internal one, does it?  I removed the external pull-up and it all works properly now.  This was a long and arduous road.

Thank you for your help,

Mike

0 Kudos

1,278 Views
Kan_Li
NXP TechSupport
NXP TechSupport

Hi Mike,

It's great to know the problem was solved on your side, and yes, K60's OTG module has internal pull-ups on USB0_DP/DM, so if there is an external pull-up on D+, only reset MCU can not lead to another enumeration by the Host as Host would  think that device is still attached since pull-up is always on D+ line.

Have a great day!

Kan

-----------------------------------------------------------------------------------------------------------------------

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

-----------------------------------------------------------------------------------------------------------------------

0 Kudos

1,278 Views
michaelmccarric
Contributor I

Hello,

I am using the Keil MDK development tools with the ULINK Pro debug adapter.  I reset the micro using the RST toolbar button when running in the debugger.

Is there a way to reset the USB interface in code?

Thanks,

Mike

0 Kudos

1,278 Views
michaelmccarric
Contributor I

Also can you direct me to a reference design on how the USB should be wired?  So I can verify my design.

Thanks,

Mike

0 Kudos

1,278 Views
adriancano
NXP Employee
NXP Employee

Hi,

Which example of the stack you are running? is as device or as a host?

If you are using it as device check how the Virtual Com Port appears in the device manager when the cable is connected and the system starts and also when the system starts and the cable is connected before. which terminal are you using to open communication with the CDC device?

Thank you for the information.

Best regards,

Adrian

0 Kudos