Go Down

Topic: fast SerialUSB for Arduino DUE (Read 10068 times) previous topic - next topic

sined23

#30
Apr 16, 2016, 08:26 pm Last Edit: Apr 16, 2016, 08:31 pm by sined23
Hi Graham! Try to copy all files from cores/arduino from 1.6.7 to 1.6.5.

Speed 125KB/s can be becouse of not optimized other lib (not SerialUSB read) which make program slowly.
Try to mesure max speed of only SerialUSB.readBlock in 1.6.5 without other commands/lib in sketch

GaM3r2Xtreme

Hi sined,

Great work with the serial communications mate. I will have to check your edited code myself and see how well communications are for me. I've been trying to figure out how to obtain faster speeds to send 6kB chunks of data to refresh some of those adafruit rgb led matrices, and I think this might be the answer. Any luck getting this code into the official library?

ghlawrence2000

About as much luck as I have getting an answer out of them for something else.

Regards,

Graham
UTFT_SdRaw now included in library manager!! ;) High speed image drawing from SD card to UTFT displays for Mega & DUE.
UTFT_GHL - a VASTLY upgraded version of UTFT_CTE. Coming soon to a TFT near you! 8) Shipping April 1 2016!

AdderD

Has anyone considered adding DMA support to the Due USB code? I'm really wondering why such a thing wouldn't have been done from the start. The SAM3X has support for direct transfer of data to and from USB right to RAM without the core processor having to be involved. That should *drastically* increase the maximum read/write speed while also freeing up processor time. It's a little more complicated but might be worth doing. Though, since I'm writing this post and not doing it myself I guess it isn't worth *that* much to me. ;)

But, if you're in the code anyway, give it a try. Once it's all spiffy and fast I'll try to help get it pushed into the mainline code.

ghlawrence2000

#34
Apr 20, 2016, 10:26 pm Last Edit: Apr 20, 2016, 10:28 pm by ghlawrence2000
Hi Sined,

Here are the results of my tests, as you can see, the sketch doesn't get much more basic....

IDE 1.6.5 ReadBytes



IDE 1.6.8 ReadBytes



IDE 1.6.5 ReadBlock



IDE 1.6.8 ReadBlock



Regards,

Graham
UTFT_SdRaw now included in library manager!! ;) High speed image drawing from SD card to UTFT displays for Mega & DUE.
UTFT_GHL - a VASTLY upgraded version of UTFT_CTE. Coming soon to a TFT near you! 8) Shipping April 1 2016!

GaM3r2Xtreme

I would have some use for that DMA if it were implemented. This would be a great idea to work on making serial communication even faster. Collin, would you happen to have any idea where the information on the DMA controller is located within the SAM3X8E datasheet? I'd like to look into it a little more to see what I can make out of it, but that datasheet can be a little tricky finding something. I did see a small mention about DMA on the Due in this thread:
http://community.atmel.com/forum/synchronous-serial-controller-ssc-or-i2s-using-dma-controller-sam3x8e-incomplete-data-transfer

The code sin has worked on, this is based on the async peripheral, correct? Just the basic communications as seen in the Serial library?

ghlawrence2000

The code sin has worked on, this is based on the async peripheral, correct? Just the basic communications as seen in the Serial library?
Correct.

Regards,


Graham
UTFT_SdRaw now included in library manager!! ;) High speed image drawing from SD card to UTFT displays for Mega & DUE.
UTFT_GHL - a VASTLY upgraded version of UTFT_CTE. Coming soon to a TFT near you! 8) Shipping April 1 2016!

sined23

Hi sined,

Great work with the serial communications mate. I will have to check your edited code myself and see how well communications are for me. I've been trying to figure out how to obtain faster speeds to send 6kB chunks of data to refresh some of those adafruit rgb led matrices, and I think this might be the answer. Any luck getting this code into the official library?
Hi GaM3r2Xtreme! I changed code in github of Arduino.

https://github.com/arduino/Arduino/pull/4871

If admins will approve my changes it will be officially put into new version.

sined23

#38
Apr 21, 2016, 01:24 pm Last Edit: Apr 21, 2016, 01:39 pm by sined23
Hi Graham! I installed IDE 1.6.5 for test and got speed 10-12 Mbit/s

I used this simple sketch:

Code: [Select]
char buf[500];

void setup() {
  SerialUSB.begin(250000);

}

void loop() {
  if (SerialUSB.available() > 0) {
     SerialUSB.readBlock(buf, 500);
  }
}



I prepared fast_usbread for IDE 1.6.5. You can use it.
BTW length in readBytes now can be any :)

ghlawrence2000

#39
Apr 21, 2016, 01:50 pm Last Edit: Apr 21, 2016, 01:58 pm by ghlawrence2000
Hi Sined,

I didn't look at your code yet, but that did the trick :D.



Regards,

Graham

Edit: And with a readblock size of 1000 !!!  ;) :D 8)

UTFT_SdRaw now included in library manager!! ;) High speed image drawing from SD card to UTFT displays for Mega & DUE.
UTFT_GHL - a VASTLY upgraded version of UTFT_CTE. Coming soon to a TFT near you! 8) Shipping April 1 2016!

sined23


ghlawrence2000

Well done Sined!! 

I really hope this gets into the next release of the IDE!!

Regards,

Graham
UTFT_SdRaw now included in library manager!! ;) High speed image drawing from SD card to UTFT displays for Mega & DUE.
UTFT_GHL - a VASTLY upgraded version of UTFT_CTE. Coming soon to a TFT near you! 8) Shipping April 1 2016!

ghlawrence2000

#42
Apr 21, 2016, 04:22 pm Last Edit: Apr 21, 2016, 04:57 pm by ghlawrence2000
Hi Sined,


:smiley-roll-blue: Now you have USB2 Full speed working, when are you planning to work on High speed implementation ? :P ;)


What am I missing? Why didn't arduino team use the UOTGHS interface to implement CDC? This is where all the DMA goodies are hidden for USB, section 39 of the Sam Data sheet, if SOMEBODY (not me) clever can figure that out we should have serious speed transfer capabilites.


Regards,


Graham

Edit: I stumbled across another Atmel application note for High Speed CDC.... http://www.atmel.com/Images/Atmel-42338-USB-Host-Interface-UHI-for-Communication-Class-Device-CDC_ApplicationNote_AT09333.pdf  and also a very detailed article on setting up a USB connection.... Between those two articles, there should be enough information to figure it out for somebody REALLY clever.... http://www.codeproject.com/Articles/893727/Getting-video-stream-from-USB-web-camera-on-Ardu
UTFT_SdRaw now included in library manager!! ;) High speed image drawing from SD card to UTFT displays for Mega & DUE.
UTFT_GHL - a VASTLY upgraded version of UTFT_CTE. Coming soon to a TFT near you! 8) Shipping April 1 2016!

sined23

#43
Apr 21, 2016, 07:34 pm Last Edit: Apr 21, 2016, 07:40 pm by sined23
Hi Graham! I think this is task for Arduino's developers. I am not a developer, just an engineer :)

ghlawrence2000

Hi sined,

I agree with you, I wasn't being serious... It looks incredibly complicated...

Regards,

Graham
UTFT_SdRaw now included in library manager!! ;) High speed image drawing from SD card to UTFT displays for Mega & DUE.
UTFT_GHL - a VASTLY upgraded version of UTFT_CTE. Coming soon to a TFT near you! 8) Shipping April 1 2016!

Go Up