Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Real time embedded FreeRTOS mailing list 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem TCP & FAT Training




Loading

Tips please :-) SAM7 USB-CDC FreeRTOS Driver

Posted by Christoph Kronen on July 18, 2011
Dear Community,

since I need a USB-CDC Driver for some projects, I tried the USB-CDC driver from the demo "lwIP_Demo_Rowley_ARM7".

In the description, it says that it does not have a great performance due to heavy queue usage. I benchmarked the RX performance and compared it to the driver provided by ATMEL. The results when I do not process the received bytes any further:

FreeRTOS CDC driver: ~71 kbyte/s (RX)
ATMEL CDC driver: ~850kbyte/s (RX), which is pretty close to the theoretical maximum

Since the ~71 kbyte/s are not sufficient, I thought about implementing the ATMEL driver into the FreeRTOS environment. The biggest difference I can see, is how the received data gets taken out of the endpoint FIFO:

FreeRTOS: The bytes are taken out of the FIFO in a Task and written to a queue (byte for byte)

ATMEL: The bytes from the FIFO are copied into a buffer during the Interrupt

What walls would I run into when taking the ATMEL driver ? Where do you see the problems ?

Thank you very much for reading all this and giving me suggestions :-)

Greetings,

Chris

RE: Tips please :-) SAM7 USB-CDC FreeRTOS Driver

Posted by Richard Damon on July 18, 2011
The biggest issue with a single buffer is that if a second message shows up before the "USB Task" processes the previous one, you need to throw away the new message. If the task can make sure this doesn't happen (limited tasks in competition to it, and not needing to wait for some other task/resource) then it might not be a serious issue. The driver (I am not familiar with it) might be built with this sort of assumption, and maybe your application allows it too.

One solution to this is to have several buffers that you use in rotation, so that if the task isn't done yet, you still have a place to put the data rather than just discarding it. You will still have the possibility that you fall far enough behind that all the buffers are in use, but you can greatly cut down the risk, or the level of analysis needed to prove that you can generally keep up.

RE: Tips please :-) SAM7 USB-CDC FreeRTOS Driver

Posted by Christoph Kronen on July 20, 2011
Thanks for your answer,

the USB Task will always have the highest priority in the projects, this will not be an issue. Both drivers already use 2 FIFO banks.

I think before I port something new I will try to find out why the FreeRTOS USB-CDC driver is so slow.

Greetings,

Chris

RE: Tips please :-) SAM7 USB-CDC FreeRTOS Driver

Posted by Richard on July 20, 2011
“I think before I port something new I will try to find out why the FreeRTOS USB-CDC driver is so slow.”


I should point out, there is no such thing as a FreeRTOS USB-CDC driver, only demo projects that include drivers that are not intended to be commercial quality and are normally supplied by silicon vendors. FreeRTOS is a kernel for which there is a wide ecosystem that comes from third parties - not FreeRTOS itself.

Regards.

RE: Tips please :-) SAM7 USB-CDC FreeRTOS Driver

Posted by Christoph Kronen on July 20, 2011
Yes of course Richard, sorry. I always think of it as the "FreeRTOS USB-CDC" driver, I know it is just a sample from a demo. It even says in the description that it does not have a great performance due to heavy queue usage.

Greetings,

Chris

RE: Tips please :-) SAM7 USB-CDC FreeRTOS Driver

Posted by Hein_Tibosch on January 2, 2012
Hi Chris,

Although your post was quite some time ago:
I think the FreeRTOS USB-CDC was slow because the data were stored/queued byte-per-byte
You better store packages of 64 bytes at a time, along with a length field
Try to wake up the USB task from the USB-EP interrupt, both for Rx as well as Tx events, using xSemaphoreGiveFromISR().
It is safer to keep interrupts short, the price is low: only a few uS delay between interrupt and wakeup.
In this way I managed to get a throughput of a few hundred kB/sec (on a slower UC3A)

Best regards, Hein

RE: Tips please :-) SAM7 USB-CDC FreeRTOS Driver

Posted by tuxscreen on April 10, 2012
Hi Hein,

you replied that you get a throughput of several 100kB/sec. May I ask, how much exactly? I tried to solve it, just as you described - I tried to read as much bytes as they were available and I put them into a "test" queue, just for speed measurements. I'm getting ~ 230kb/sec but I need more, something about 500kb/sec...


[ Back to the top ]    [ About FreeRTOS ]    [ Sitemap ]    [ ]




Copyright (C) 2004-2010 Richard Barry. Copyright (C) 2010-2016 Real Time Engineers Ltd.
Any and all data, files, source code, html content and documentation included in the FreeRTOSTM distribution or available on this site are the exclusive property of Real Time Engineers Ltd.. See the files license.txt (included in the distribution) and this copyright notice for more information. FreeRTOSTM and FreeRTOS.orgTM are trade marks of Real Time Engineers Ltd.

Latest News:

FreeRTOS V9.0.0 is now available for download.


Free TCP/IP and file system demos for the RTOS


Sponsored Links

⇓ Now With No Code Size Limit! ⇓
⇑ Free Download Without Registering ⇑


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Renesas Electronics Gold Alliance RTOS Partner.jpg

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Atmel RTOS partner supporting ARM Cortex-M3 and AVR32 microcontrollers

STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Xilinx Microblaze and Zynq partner

Silicon Labs low power RTOS partner

Altera RTOS partner for Nios II and Cortex-A9 SoC

Freescale Alliance RTOS Member supporting ARM and ColdFire microcontrollers

Infineon ARM Cortex-M microcontrollers

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

Cypress RTOS partner supporting ARM Cortex-M3

Fujitsu RTOS partner supporting ARM Cortex-M3 and FM3

Microsemi (previously Actel) RTOS partner supporting ARM Cortex-M3

Atollic Partner

IAR Partner

Keil ARM Partner

Embedded Artists