Kinetis K22 USB Latency Test

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

Kinetis K22 USB Latency Test

577 Views
nbgatgi
Contributor IV

I am brand new to USB in embedded systems.  I have the TWR-K22F120M tower board and have been able to run example code from the SDK within MCUXpresso for HID and CDC VCOM, but I'd like some pointers to take these examples into my own code base.

My current task is to connect my tower board to a PC via USB, transmit n-bytes of ASCII data from the PC to the tower board and back in order to measure net latency and determine repeatability over m-iterations.  We intend to vary the number of bytes as well as add some processing of the transmitted data on the tower board to determine impact, but for now I just need to control transmitting and receiving data.

The other part of the struggle I'm having is that we want to avoid the use of VCOM as I believe we wouldn't have access to full-speed USB data rates (correct me if this assumption is incorrect).

I would like to setup a simple set of bulk end-points to which I send and receive data.  We will add the timing functions on the PC side.

I have been scouring the internet for intro training and have found some good info regarding USB generically, but not specific to basic USB development much less development of USB CDC devices for Kinetis K22!

If anyone can help get me started it would be greatly appreciated.

Labels (2)
Tags (1)
1 Reply

431 Views
mjbcswitzerland
Specialist V


Hi Nick

I can't help with NXP USB library but if you require a bullet-proof USB solution (also works with FreeRTOS) for the K22 (or any other Kinetis USB processor) you can look at the uTasker project:

Kinetis: http://www.utasker.com/kinetis.html
Kinetis K22:
- http://www.utasker.com/kinetis/FRDM-K22F.html
- http://www.utasker.com/kinetis/TWR-K22F120M.html
- http://www.utasker.com/kinetis/BLAZE_K22.html
- http://www.utasker.com/kinetis/tinyK22.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

The potential advantage is that it has a very simple user interface (looks like a UART to the programmer) and has personal support and USB simulation. This means that desk top support and training is included - directly with the USB stack developer and supporter of many industrial Kinetis USB projects.

If your are not allowed to use commercial solutions you can also use its Open Source version that supports the K22 tower board and still allows quality USB and simulation. One-on-one training can still be purchased on a hourly basis if there are questions or for general project support.

I have attached a binary for your tower board which will echo USB-CDC bulk data to get an idea of its speed. It includes full end to end flow control and also USB-UART bridging. It can be used on multiple VCOM connections (if configured accordingly). USB-CDC is typically used for bulk data (I don't know that the USB speed would be of any relevance since HS and FS are essentially compatible as the host negotiates it).


Here is how the echo is controlled in code. Of course sending data at any time or modifying actions is simple and doesn't need any further understanding of the USB principles or drivers below:

// Scheduled on any USB rx activity
//
// USBPortID_comms[FIRST_CDC_INTERFACE] is the USB interface handle obtained when the USB interface was opened (whereby multiple VCOM handles can exist)
unsigned char ucInputMessage[LARGE_MESSAGE];                         // reserve space for receiving messages
QUEUE_TRANSFER Length = fnRead(USBPortID_comms[FIRST_CDC_INTERFACE], ucInputMessage, LARGE_MESSAGE); // read up to LARGE_MESSAGE length of data from the USB input buffer
fnWrite(USBPortID_comms[FIRST_CDC_INTERFACE], ucInputMessage, Length); // echo received data back to the corresponding USB IN endpoint

Regards

Mark