Go Down

Topic: native usb : fast write solution ?  (Read 290 times) previous topic - next topic

Measureino

After reading a lot of posts I didn't find a solution for fast write on native usb port.
Please give me a hint.

Thanks!

ard_newbie


I guess that buffer size of each used endpoint for transmission (except control endpoint 0) could be a source of bottleneck....
 
Therefore it might be useful to know which endpoints are used by the Host, with which parameters. Endpoints enabled can be read in register:
UOTGHS->UOTGHS_DEVIMR, and parameters applied after a reset can be read in registers:
UOTGHS->UOTGHS_DEVEPTCFG[Num_endpoint].

An endpoint buffer size can be set between 64 and 1024 bytes (datasheet page 1115) , provided there is a coherency with the other parameters of UOTGHS->UOTGHS_DEVEPTCFG[Num_endpoint].

Measureino

Sorry, but that's a little too hard to understand. Although I'm working with processor registers for fast pin readings I don't know, where and how to use for example UOTGHS->UOTGHS_DEVIMR.

My problem is, that standard USBSerial on native USBport ist too slow.

MorganS

How slow is "slow"? Please give some actual measurements.

What is on the other end? Often the bottleneck is on the PC and not the Due.
GoForSmoke: "What GShield? You never mentioned a shield."

Measureino

I gather adc-data from parallel input on gpios by taking a complete 32-bit register, all that at an external clock with cycle of 1,6MHz. Therefore my dream would be 4Bytes * 1,6MHz=6,4 MB/s usb write-speed. If that's not possible I can reduce clock frequency by divider 2 or 4.That means 3,2MB/s or 1,6MB/s.

On the other side is a PC which stores data in RAM.

ard_newbie

#5
Mar 17, 2017, 09:42 am Last Edit: Mar 17, 2017, 09:42 am by ard_newbie

You can read ADC channels at 1 million samples/sec and output the data to SerialUSB, see an example of this here, reply #8 :


http://forum.arduino.cc/index.php?topic=137635.0


Measureino

#6
Mar 17, 2017, 11:28 am Last Edit: Mar 17, 2017, 11:40 am by Measureino
Thanks, but my problem is not adc, because I use a very special ADC-board with higher precision (18-24 Bit and parallel interface) which generates a clock signal when converting signal has been finished (1.6MHz clock). Checking the rising edge of this clock is possible with DUE. Even reading the pinstates by PIOC-Register is fast enough.

My problem instead is based on  sending the values fast enough over native usb-port with up to 6.4MB/s as mentioned above.

ard_newbie


OK.... , the full story is:

- Your ADC has a 18 to 24 bits resolution
- You receive samples on 18 to 24 input parallel pins
- The sampling frequency is 1.6 MHz
- You need to record incoming samples during ………. seconds ?

Some hints :

1/ Use a compression algorithm.
2/ Try to modify USBOTG HS as mentioned in reply #1.
3/ If the recording time is limited, I would try this code:


Code: [Select]

uint32_t My_Buffer[64][256]; // 64 K Buffer
boolean clock_ADC; // TODO : Signal from ADC

void setup() {

  SerialUSB.begin(250000);
  while (!SerialUSB);
}


void loop() {

  static uint32_t i;
  static uint32_t bufn, old_bufn;
  static boolean Flag;


  if (clock_ADC == 1) {
    My_Buffer[bufn][i] = PIOC->PIO_PDSR;
    i++;
    if (i == 256) {
      bufn = (bufn + 1) & 0b111111;  // %64
      i = 0;
      Flag = 1;  // Send the buffer
    }
  }

  if (Flag == 1) {

    SerialUSB.write((uint8_t *)My_Buffer[old_bufn], 1024); // send 1K
    old_bufn = (old_bufn + 1) & 0b111111; // %64
    Flag = 0; // A 1024 bytes buffer has been sent
  }
}



Measureino

Many thanks, perhaps this helps a lot.

But what does '2/ Try to modify USBOTG HS as mentioned in reply #1.' mean ' ?

Which code lines shall I insert for this in my .INO File?

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy