FRDM-k66f usb CDC device HS

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

FRDM-k66f usb CDC device HS

2,578 Views
xanthurum
Contributor II

In a project with an 8 channel 12-bit simultaneous sampling ADC, the sampling rate is 100kHz.
So every 10µs the MCU needs to forward the data + a time difference, via USB to a host PC running Matlab.

In its raw form and comma separated, 26 bytes. In a timeframe of 5µs -> 5,2MB/s.
In ASCII formatted and comma separated, 56 bytes. In a time frame of 5µs -> 11,2MB/s.

The time frame is only an assumption, the other 5µs is to accommodate the other functions that need to be done.

The CDC class from the example can follow until an interval of 200µs. But after 16 transfers it stalls for 240 counts!
How come? Please advice.

Following the print screen at the receiving end in Matlab, with an interval of 200µs, 100µs and 10µs.
An example with only the bare necessities added to simulate the USB communication.

The number at the end is a count 0->255!

USB capture interval 200µs.PNG

USB capture interval 100µs.PNG

USB capture interval 10µs.PNG

0 Kudos
22 Replies

1,509 Views
xanthurum
Contributor II

Dear Mike

Ten days passed, did you still not hear from the Kinetis team?

Best regards

Pascal

0 Kudos

1,509 Views
Hui_Ma
NXP TechSupport
NXP TechSupport

Hi Pascal,

I get the feedback from Kinetis product team that:

For the PC Serial terminal software without measuring bandwidth feature, while PC Ethernet tool support that feature.

That's why our test team select to use USB CDC "Virtual Network Interface Controller" to measure the CDC class data throughput.

In fact, the USB CDC VCOM is using the same USB channel with USB CDC VNIC.

The data throughput rate should be same.

The USB data throughput rate also be affected by PC software and related driver.

 Thank you for the attention.


Have a great day,
Mike

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

0 Kudos

1,512 Views
xanthurum
Contributor II

Dear Mike,

I don't understand why you offer a completely different USB class as a solution.

I'm not familiar with a "Virtual Network Interface Controller" besides that the example is, as most of the other examples, barely or not documented.

The example driver which settings that need to be tuned is: "frdmk66f_dev_cdc_vcom_bm".

I hope to hear from you soon.


With kind regards

Pascal

0 Kudos

1,509 Views
Hui_Ma
NXP TechSupport
NXP TechSupport

Hi Pascal,

First of all, really sorry for the later reply.

I just back to office after one week absence.

I need to check with Kinetis team again about the setting.

I will let you know later.

best regards,

Mike

0 Kudos

1,512 Views
xanthurum
Contributor II

Dear Mike

14 days have past and still no answer.

Can you please look up the related settings.

Best regards

Pascal

0 Kudos

1,512 Views
Hui_Ma
NXP TechSupport
NXP TechSupport

Hi Pascal,

Sorry for the delay reply.

The product team feedback below:

8MB is available on usb_examples\usb_device_cdc_vnic.

You can have a check on it.

Please refer MCUXpresso SDK [usb_device_cdc_vnic] demo setting to check if that could match with your application requirement.

Wish it helps.


Have a great day,
Mike

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

0 Kudos

1,512 Views
xanthurum
Contributor II

Dear Mike

If the data is sent in it's raw format then a minimum speed of 5,2MB/s is needed.

So the 8MB/s would suffice for my project.

Would it be possible to point out the settings to achieve the tested speed of 8MB/s?

Best regards

Pascal

0 Kudos

1,512 Views
Hui_Ma
NXP TechSupport
NXP TechSupport

Hi Pascal,

Yes, I will check with Kinetis product team about related setting.

I will let you know when there with any feedback.

best regards,

Mike

0 Kudos

1,512 Views
xanthurum
Contributor II

Dear Mike

Have you already an idea about the cause of this fault?

Best regards

Pascal

0 Kudos

1,512 Views
Hui_Ma
NXP TechSupport
NXP TechSupport

Hi Pascal,

Sorry for the later reply.

I got the feedback from Kinetis product team, the USB CDC device HS throughput data tested speed is 8MB/s.

From your original speed required 11.2MB/s, there still exists the gap to match with your requirement.

I am checking with Kinetis team how to enhance the throughput speed.

While, checked the endpoint settings, no improvement can be made on current descriptor settings.

Sorry for that.


Have a great day,
Mike

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

0 Kudos

1,512 Views
xanthurum
Contributor II

Hi mike

I changed the optimization level to the highest level, but that makes no difference.

pastedImage_1.png

pastedImage_2.png

The last number is the value of a counter 0 -> 65535!

I'm still hoping to see this solved.

Best regards

Pascal

0 Kudos

1,512 Views
Hui_Ma
NXP TechSupport
NXP TechSupport

Thank you, Pascal.

I am still checking with SDK software team and will let you know later. Thanks.


Have a great day,
Mike

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

0 Kudos

1,513 Views
xanthurum
Contributor II

Dear Mike

I made the 'intervalCount' variable global as you suggested, that makes no difference.

pastedImage_6.png

I'm pretty sure it is the driver that can not follow the pace.

This is the send function and the errors because the Vcom driver can't cope.

pastedImage_2.png

The result on Matlab.

pastedImage_3.png

The interval is not even 10µs in that example.

pastedImage_4.png

This is the result with an interval of 10µs:

pastedImage_5.png

Best regards

Pascal

0 Kudos

1,513 Views
Hui_Ma
NXP TechSupport
NXP TechSupport

Hi Pascal,

I am still checking with SDK software team about this issue.

Could you try to set your project's Optimization level to speed up code execute speed?

I will let you know when there with any feedback. Thanks.


Have a great day,
Mike

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

0 Kudos

1,513 Views
Hui_Ma
NXP TechSupport
NXP TechSupport

Hi Pascal,

Sorry for the later reply.

I am checking with SDK USB stack software team about USB High speed CDC device performance.

I will let you know later.

Thank you for the patience.

best regards,

Mike

0 Kudos

1,513 Views
xanthurum
Contributor II

Dear Mike

Yes indeed, every 10µs the ADC data + a timestamp difference has to be send to the USB host.

Besides running the code to get the measurement data from the ADC.

In the Matlab program the 96000000 is the serial baud rate.

Have a nice day

Pascal

0 Kudos

1,513 Views
Hui_Ma
NXP TechSupport
NXP TechSupport

Hi,

In <virtual_com.c> file, the APPTask() function, there call below function to calculate the time difference.

uint16_t timeDifference = TimersAndCo_GetTimeDifference(); //At the moment only a count 0 -> 255

We don't think below function is robust, there need consider PIT timer overrun.

We recommend set a global variable as counter, which add 1 every set time interval passed (for example 200us).

/*
 * @brief Function to get the time difference.
 * @return uint16_t µs_difference    -> The time difference in µs.
 */
uint16_t TimersAndCo_GetTimeDifference(void)
{
    uint64_t currentTimerValue    = COUNT_TO_USEC(PIT_GetCurrentTimerCount(PIT, PIT_TIME_DIFFERENCE_CHANNEL), PIT_SOURCE_CLOCK);
    uint64_t timeDifference     = lastTimerValue - currentTimerValue;
    lastTimerValue                = currentTimerValue;

    //return (uint16_t)timeDifference;
    return intervalCount;
}

Then use that counter variable will check if there with the data lost issue.

Thank you for the attention.


Have a great day,
Mike

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

0 Kudos

1,512 Views
xanthurum
Contributor II

Dear Mike

These are the SDK's I am using, the version of the FRDM-K66 SDK is 2.3.0

pastedImage_1.png

Best regards

Pascal

0 Kudos

1,512 Views
Hui_Ma
NXP TechSupport
NXP TechSupport

Hi Pascal,

Thank you for the info.

I checked your code and issue description.

I couldn't get the clear idea about the problem.

In <virtual_com.c> file, the APPTask() function, the timeIntervalPassed will be set every 10us.

  • If that means, every 10us, the ADC conversion value with time stamp data will be transfer to USB host?

Another question is below code, I don't know the serial() function parameter 96000000 means.

  • If that means the system clock or serial baud rate?

pastedImage_1.png

Please help to provide some comments about above questions. Thanks.


Have a great day,
Mike

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

0 Kudos

1,513 Views
xanthurum
Contributor II

Dear Mike

pastedImage_1.png

The version of the IDE I am using.

Best regards

Pascal

0 Kudos