Hi everyone!
I'm trying to use Arduino Due for my little project and was expecting the communication bandwidth to be at least ~15MB/s for my use. I saw that the Native port supports up to 480MB/s throughput while Arduino due runs at ~80MHz, so I assumed it would definitely satisfy my request.
However, I tried to implement a very simple program testing if I could get the communication right. The result shows the speed is only around 520KB/s. I'm posting my code below - Generally due reads some unsigned int data from the SerialUSB then returns them back. I tried to send 2560 packages and it took about 20 seconds too complete. With the array length of each package being 256 the speed is roughly only 520KB/s, far away from the 480MB/s or 80MHz clock speed can do.
I'm very new to Arduino and definitely do not understand how it works very well. Is this just the normal speed or did I do something wrong? Could it be Serial buffer issue or the power supply to the board (I'm only using USB as a power source)? Thank you!
const int length_pack=256;
unsigned int data_in[length_pack];
unsigned int n[2];
void setup() {
SerialUSB.begin (230400); //does not matter for Native Port
while(!SerialUSB){}
}
void loop() {
if (SerialUSB.available()) {
SerialUSB.readBytes((uint8_t*)n,4)
SerialUSB.readBytes((uint8_t*)data_in,length_pack*4);
SerialUSB.write((uint8_t*)data_in,length_pack*4);
}
}