USB driver on K65F/K66F

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

USB driver on K65F/K66F

1,454 Views
a8Chcx
Contributor V

Hi,

I am testing USB stack on TWR-K65F180M and FRDM-K66F180M, and have the following questions:

1) I want to implement USB FS, I have to USB0? Or I can use USB1 as well because I think USB1 is for high speed. Can I use USB1 as FS that is same as USB0?

2) I tried to load generic HID and looks like my PC recognize HID, when I modified sample application and start testing application. I can't find the device. How to fix it? Do you have any other application?

3) If I use generic HID driver, what is maximum data exchange between PC and K65F/K66F?

4) What is the difference between generic HID and lite version?

5) My application exchanges data between PC and device. The maximum length is around 256 bytes, do you think HID should be good to go? I do not have to have the customized driver for it, right? no need to install driver?

Thanks,

Christie

Labels (1)
0 Kudos
8 Replies

750 Views
a8Chcx
Contributor V

Hi Jorge,

Thank you for your answers. I found the problem foe TWR-K65F180M HID sample project. It is because the default setting is for USB0, not USB1. After I change ECHI, it works as default hardware setting.

I have more questions below...

1) Based on the document and demo project, USB1 can work for HS, FS. The demo HID sets USB1 to FS. Could you confirm it?

2) In demo project, I can see USB1 is configured for self-powered. So, I need to provide 5VDC on VBUS? The VBUS from USB connector(PC) should not be used?

3) When I use USB1 HID for FS, with on control endpoint, one  IN endpoint, one OUT endpoint, can I send/receive 64 bytes on IN and OUT endpoints? What is the maximum data length allowed, 128 bytes? The interval to exchange data on IN and OUT endpoints should be >= 0.5s?

4) I can see maximum data used in Kinetis Boot-loader is 32 bytes. Is it any reason?

5) If I want to change the maximum length to 64 or 128 bytes in sample project, where do I need to change because when I change the above definition from 8 to 64, it causes problem?

Thanks,

Christie

0 Kudos

750 Views
jorge_a_vazquez
NXP Employee
NXP Employee

Hi Christie Su

About your questions:

1) Based on the document and demo project, USB1 can work for HS, FS. The demo HID sets USB1 to FS. Could you confirm it?

No, If you select KHCI drivers, demo will load the FS drivers with USB0, and if you select the EHCI demo will load the HS drivers with USB1. I mentioned that in case that the host doesn't support HS, device could work with FS, but this is a host characteristic.

2) In demo project, I can see USB1 is configured for self-powered. So, I need to provide 5VDC on VBUS? The VBUS from USB connector(PC) should not be used?

This "self-powered" specification is for the host driver, it is used in case that it need to know current consumption, it doesn't relate with hardware design. If you are using HS, USBHSDCD instantiation of this module for a High-Speed capable port has the additional requirement that the voltage on the USB1_VBUS pin be > 4.5V.

3) When I use USB1 HID for FS, with on control endpoint, one  IN endpoint, one OUT endpoint, can I send/receive 64 bytes on IN and OUT endpoints? What is the maximum data length allowed, 128 bytes? The interval to exchange data on IN and OUT endpoints should be >= 0.5s?

The packet length of control transfers in full speed devices allow a packet size of 8, 16, 32 or 64 bytes. For Interrupt transfers, FS allows a max package size of 64 bytes (the example defined it with a max package size of 8 bytes).

The speed specification that I mentioned in my previous comment is about the interrupt transfer.  FS in interrupt transfer Maximum data payload size for full-speed devices is 64 bytes every interval. An Interrupt request is queued by the device until the host polls the USB device asking for data (in the example Host polls for data every 1 ms ).

4) I can see maximum data used in Kinetis Boot-loader is 32 bytes. Is it any reason?

No, it is just a KBOOT characteristic.

5) If I want to change the maximum length to 64 or 128 bytes in sample project, where do I need to change because when I change the above definition from 8 to 64, it causes problem?

As I mentioned, The host will periodically poll the interrupt endpoint. This rate of polling is specified in the endpoint descriptor, that is the definition in

#define HS_HID_GENERIC_INTERRUPT_IN_PACKET_SIZE (8U)
#define FS_HID_GENERIC_INTERRUPT_IN_PACKET_SIZE (8U)
#define HS_HID_GENERIC_INTERRUPT_IN_INTERVAL (0x04U) /* 2^(4-1) = 1ms */
#define FS_HID_GENERIC_INTERRUPT_IN_INTERVAL (0x01U)

But FS host controllers schedule transactions in periods of 1, 2, 4, 8, 16, or 32 ms. For FS devices that request a latency of 9 to 15 ms, host will attempt a transaction every 8 ms and a device that request a latency of 32 to 255 will cause a transaction attempt every 32 ms.

This are USB caracteristics, so I recommend you to check the following link:

USB in a NutShell - Chapter 4 - Endpoint Types 

Maybe It could give you a overview of USB specifications.

Hope this could helps

Regards

Jorge Alcala

0 Kudos

750 Views
a8Chcx
Contributor V

Hi Jorge,

Thank you for your answers.

Do you have any sample project that it can send/receive 64 bytes between PC and K66F USB1? Any PC window based application?

Thanks,

Christie

0 Kudos

750 Views
jorge_a_vazquez
NXP Employee
NXP Employee

Hi Christie Su

About the a sample project that send/receive 64 bytes, maybe it's better if you check the vcom example project, it use bulk endpoint types, and the application code is a loopback, you could change it to your specific application (send/receive 64 bytes).

About the PC window based application I couldn't tell you an example, because it depends in what you are trying to implement, an HID device?, a virtual communication?, you want to send 64 bytes every interval interrupt? or every specific event?

Hope this could helps

Best Regards

Jorge Alcala

0 Kudos

750 Views
a8Chcx
Contributor V

Hi Jorge,

Yes. I can send/receive 64 bytes data over sample HID demo. Now I have the following problem:

 

I am testing USB HID Generic demo(BM version) and works fine..

Then, I am using Wizard 2.x in KDS 3.2.0 to generate my own project by choosing "include all driver", no RTOS option.

After that, I copied required USB stack and files from demo project, compile it, link it to generate *.elf fine. All work fine.

But, when I download it to my FRDM-K66F and run it, I got the error code==0x01(USB Busy) when I call USB_DeviceClassInit(CONTROLLER_ID, &g_UsbDeviceHidConfigList, &g_UsbDeviceHidGeneric.deviceHandle)). I check CONTROLLER_ID is 2.

Looks like it can't allocate memory for my USB handle...

Can you tell me where the problem can be, related to environment setting(KDS 3.2.0) because I use the same files in demo?

 

Thanks,

 

Christie

0 Kudos

750 Views
a8Chcx
Contributor V

Hi Jorge,

I tried KSDK 2.0 that I built 2 months ago there is USB 1.0.0 stack inside KSDK.

I tried demo project, then I built my own new project by using KDS 3.2.0 Wizard 2.x(just copied USB 1.0.0 and required files under demo). It works the same as demo project.

If I use the latest KSDK with USB 1.4.0, I have the following problems so far:

1) I can't use printf function to display message, but it is OK with demo.

2) If I run my project, it will get the above error. Only time, my project can run properly is when demo project run first, then I load my project and works fine. It will fail if I re-boot or power OFF/ON, or even re-load. Looks like some settings are not right...

3) I tried RTOS version and had the same issue on USB 1.4.0. Could you tell me what the difference between two USB version is? And how to fix the problem?

Thanks,

Christie

0 Kudos

750 Views
jorge_a_vazquez
NXP Employee
NXP Employee

Hi Christie Su

These issues were resolved in your other thread: https://community.nxp.com/thread/438640   isn't it? so, can we conclude this thread?.

Regards

Jorge Alcala

0 Kudos

750 Views
jorge_a_vazquez
NXP Employee
NXP Employee

Hi Christie Su

Sorry for the late reply, Answering your questions;

1) USB1 is High speed dedicated, it is a general recommendation to use USB0 with Full speed and USB1 for High Speed, But if you have your USB as device and the host can't support high speed, only FS, your device can work as FS.
2) How are you modifying the sample application? what version? or OS?. I going to need to consult to our development team but I need more information of how you tried the example.
3) HID example code is configured to run with maximum packet size of 8 Bytes every interrupt interval of 1ms.

#define HS_HID_GENERIC_INTERRUPT_OUT_PACKET_SIZE (8U)
#define FS_HID_GENERIC_INTERRUPT_OUT_PACKET_SIZE (8U)
#define HS_HID_GENERIC_INTERRUPT_OUT_INTERVAL (0x04U) /* 2^(4-1) = 1ms */
#define FS_HID_GENERIC_INTERRUPT_OUT_INTERVAL (0x01U)

#define HS_HID_GENERIC_INTERRUPT_IN_PACKET_SIZE (8U)
#define FS_HID_GENERIC_INTERRUPT_IN_PACKET_SIZE (8U)
#define HS_HID_GENERIC_INTERRUPT_IN_INTERVAL (0x04U) /* 2^(4-1) = 1ms */
#define FS_HID_GENERIC_INTERRUPT_IN_INTERVAL (0x01U)
‍‍‍‍‍‍‍‍‍

maximum data exchange between PC and MCU depends in setup used (class, endpoints, protocol)
4) There is not difference between them in functionality, but for the lite version application, the code size is smaller than the non-lite version, this due to the call functions to initialize the USB
5) 256 bytes, How often? your maximum package size depends, as I mentioned, in class, endpoints, interval interrupt, etc. Generic HID uses interrupt endpoint type, so, for the USB specification you probably going to need High Speed with a maximum package size bigger than 256, because FS with interrupt endpoint max package size is 64 every frame, But this also depends in your interval interrupt, so what time will you need?.

No, no need to install your own drivers if you are using generic specifications.

Hope this information helps, please let me know if you have any other question
Have a great day,
Jorge Alcala

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

0 Kudos