I am interfacing an ADC (AD7892-2) with my DUE. Eventually I want to run it at 400 ksps, but while I debug I've slowed it down to just 30ksps. The DUE is interrupted by the "end of conversion" pulse from the ADC, when it will eventually read the result in either parallel or serial mode. For now, I am running a dummy interrupt service routine which is as short as I can make it (direct port manipulation to make a very short pulse). It seems like it takes about 4us just to call the routine, which is too long for what I need.
Here is my code:
void setup(){
pinMode(11, OUTPUT);
attachInterrupt(6,getData,FALLING);
delay(100);
}
void loop(){
}
void getData(){
REG_PIOD_ODSR |= (1<<7);
REG_PIOD_ODSR = 0;
}
I'm watching pins 11 and 6 on an oscilloscope and attached two oscillograms. The first shows that the pulse on pin 11 is just a couple of clock cycles long, as expected. This is the entire ISR. The second shows the trigger which should interrupt the DUE, and the ISR running after a wait of about 4us.
Is this delay unavoidable, or can I change something to call the ISR quicker? Is there a better way overall of doing this?
Thanks for reading!
-Matt
--I seem to be unable to upload the oscillograms right now. They are really pretty straightforward and show just what I've described.