I'm guessing from your example that reading a byte and storing it in the array would take several CPU cycles. Even if it was only 10 cycles the reads would be relatively slow - say 1.6m per second.
I was/am hoping there might be a special way to do it that would be able to read, say, 5m/s.
The data would be coming from a high speed ADC chip.
...R
johnwasser:
You can read 8 input pins in one instruction cycle using direct register access:
PIND = D7/D6/D5/D4/D3/D2/D1/D0
PINB = //D13/D12/D11/D10/D9/D8
PINC= //A5/A4/A3/A2/A1/A0
You could lose the overhead of the loop, at the expense of longer, more boring code.
Four lots of 256 acquisitions would maybe allow byte indices, which could be faster than into.
5Msps is still quick for a 16MHz processor.
A quick hack based on johnwasser's suggestion took about 500 usec per 1024 samples in a for loop, and about 200 usec in linear code (i.e. 1024 separate assignment statements).
That's slower than I expected, and also didn't seem to be affected by enabling/disabling interrupts, so I'm not sure I trust the results, but that's what I saw
This is very interesting. I think the faster timing implies about 3 CPU steps per byte read.
It will be worth having a look at AVR assembler code to see how it can be done. It's unlikely to be better than 3 steps/per but I hadn't expected anything as good as that. I would also need to look at the timing diagram to see whether data could be validly read at that rate.
Of course in a practical situation there also needs to be a clock signal which may consume more cycles.
Thanks.
And any more ideas will be very welcome.
...R
PeterH:
A quick hack based on johnwasser's suggestion took about 500 usec per 1024 samples in a for loop, and about 200 usec in linear code (i.e. 1024 separate assignment statements).
That's slower than I expected, and also didn't seem to be affected by enabling/disabling interrupts, so I'm not sure I trust the results, but that's what I saw
Its some time since I played around with my program to read data with the UM245R module. I have just been trying it again and I have remembered that I can read data more-or-less continuously at high speed with the UM245R module whereas the most I could read with an Arduino Uno would be 2k, even if the speed was fast enough. So I won't be exploring this aspect of the Arduino any further.
By the way the data-acquisition is from a home-made oscilloscope which I will be using to check that some of my Arduino output is correct for a radio control project.