Full Speed USB on XMega

Go To Last Post
4 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I'm using Xmega128A4U, with ASF 3.5.1
I use the USB Device driver for cdc_stdio.

It all worked fine, but my transfer speed was about 22KBytes/sec.

So I commented out the line

#define  UDI_CDC_LOW_RATE

in the conf_usb.h file, and hoped to go at a faster rate (full speed 12 Mb/s) - but it was just the same speed as above. I use

putchar()

to transfer data into the USB stack - I'm a bit concerned it may send a byte at a time - but i can't find where putchar() is implemented - its just defined as an extern.

My questions:

1) Anyone know how configure the USB stack to run at full speed and get a higher transfer rate?
2) how can i find out where my putchar() implementation is so i can have a look at what's happening?
3) can i use a more block oriented write instead of putchar()

Many Thanks in advance!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I'm assuming your using the stdio cdc example. The function stdio_usb_init() replaces input and output routines.

putchar will eventually call stdio_usb_putchar() which calls udi_cdc_putc() which calls udi_cdc_multi_putc().

As you said, you need to send your data as blocks to get good through-put. I use udi_cdc_write_buf().

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

As USB works on endpoint transfers every 1ms and I think the endpoint here may be 64 bytes then the best you can hope to achieve is 64,000 bytes/s. If you only get 22000bytes/sec it could be that the 64 byte buffer is not being completely filled at every opportunity.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

There are many factors affecting the speed if you use CDC. Here are some:
1) CDC is a bulk class transfer which means data integrity is guaranteed, but promptness is not (it gets low priority) If you have other USB devices on the same USB bus, these will interfere and if they have high priority, then you might not get any data transfer in the extreme case.
2) endpoint size is 64 bytes so it's best if you can always send/receive data in 64 byte chunks. When I last looked in the ASF CDC, it is smart enough to aggregate 64 bytes (if you use 64 putchars, then it will put them together and send it over together, but you can't really control reception)

Based on my understanding, if you really want full speed, then you are going to have to use the other class types like control or isochronous (I forgot what it is called) and make a custom class. But then that becomes a big project because then you have to write your own host side driver.

Maybe you can try the mass storage class profile.