I just bought an Arudino Due because I wanted the higher performance. I was wondering though, is the Due capable of reading digital inputs at 15MHz? I figure with a clock speed of 84MHz, it's gotta be able to read digital inputs at some respectable fraction of that. I've tried looking for this information in the Arduino pages but didn't find anything that clearly answered this question

I just bought an Arudino Due because I wanted the higher performance. I was wondering though, is the Due capable of reading digital inputs at 15MHz? I figure with a clock speed of 84MHz, it's gotta be able to read digital inputs at some respectable fraction of that. I've tried looking for this information in the Arduino pages but didn't find anything that clearly answered this question

Thanks for reading

It should be possible. But I think you'll have to use a bit of assembly for it. And it is not possible to time it correctly. You can also use DMA, but that is probably too fast.

I see. Do you know what the minimum time between digital reads would be then, without having to use assembly? As in, could I read the same digital input pin at 3MHz? 15MHz is probably a pipe dream considering all the other processes the arduino must handle

There's a schemata for input and output within about 0.4 µs. Surely you can make it a little bit faster. And instead of 8 Bit size you can - with some limitations - use 16 ore more bits without significant longer time because the bus has a size of 4 bytes.Tom

I see. Do you know what the minimum time between digital reads would be then, without having to use assembly? As in, could I read the same digital input pin at 3MHz? 15MHz is probably a pipe dream considering all the other processes the arduino must handle

As far as I know should the pio be able to read at 21MHz max. The problem is that you can try to read the inputs as fast as possible, but you can't control the speed. That's a big problem. DMA had been great if you could control it's speed.

You can use noInterrupts(); to disable interrupts. You need to use loop unrolling and assembly if you want to go that fast using the cpu. The DMA is (depending on the channel used) probably somewhere between 84 and 21 MHz or something. But I am nit sure.

Its quite involved setting up DMA, re-reading the datasheet a few times in the relevantsections is a start. However it should be able to do fancy stuff like this AFAICT.

Assembler is not needed, all IO is memory mapped so C is fine for all the lowlevel stuff on the ARM which is nice! Its worth getting to look at the relevantfiles in libsam for each piece of hardware to get a feel for things - you have allthe source code after all!

[ I will NOT respond to personal messages, I WILL delete them, use the forum please ]

Hey, thanks for the replies guys. Measureino - this is pretty much port manipulation for the Arduino Due, right? I recently started looking into all that (kind of a n00b with all arduino) to accomplish my fast input read speed. Seems like this worked for you huh? Very promising, I'll check it out and see if I can't do the same thing! I want to modify it to read 10 bits from two 8-bit registers, and write to one pin in the second 8-bit register. Does that seem feasible to you? Just sanity checking haha

Its quite involved setting up DMA, re-reading the datasheet a few times in the relevantsections is a start. However it should be able to do fancy stuff like this AFAICT.

Assembler is not needed, all IO is memory mapped so C is fine for all the lowlevel stuff on the ARM which is nice! Its worth getting to look at the relevantfiles in libsam for each piece of hardware to get a feel for things - you have allthe source code after all!

I made some code to make using DMA much simpler. I can post it here if you want.

@FingerBuckley Reply #6You should use PIOC if you want to read more than 8 Bit. For example:C1...C8, C19...C12 means dig. Pins 33...40,44...51There's no time difference when reading 8 or 16 bit, as IO always reads 32 bits. The only difference lies in some extra bit manipulations. You have to do input >> 1 to get low part and input >>12 to get high part of input.Take attention to the different order C19,C18...C12 but dig Pin 44...51I think it's a risk to use i.e. C for input and(!) output or you should be very careful to avoid reading from an output pin or writing to an input pin.

@Measureino - Smart idea! I changed everything to port C, and instead of doing bit manipulations during the sampling process, I am instead doing it after I've collected the number of samples I care about. So, this code here:

@Measureino - Smart idea! I changed everything to port C, and instead of doing bit manipulations during the sampling process, I am instead doing it after I've collected the number of samples I care about. So, this code here: