Hi there,
I am looking to read the adc when there is an external interrupt.
The problem I have is that if the signal interrupt less than 100 micro seconds, the interrupt does not occur.
Is there a way to reduce this time down?
int led = 13;
int interr = 12;
unsigned long values;
void bink(){
while((ADC->ADC_ISR & 0x80)==0); // wait for conversion
values=ADC->ADC_CDR[7]; //get values
//digitalWrite(led, HIGH);
//delayMicroseconds(100);
//digitalWrite(led, LOW);
Serial.println(values);
delayMicroseconds(100);
}
void setup() {
// initialize the digital pin as an output.
pinMode(led, OUTPUT);
pinMode(interr, OUTPUT);//generator interrupt
pinMode(3, INPUT);
Serial.begin(250000);
ADC->ADC_MR |= 0x80; //set free running mode on ADC
ADC->ADC_CHER = 0x80; //enable ADC on pin A0
attachInterrupt(3, bink, RISING);
}
// the loop routine runs over and over again forever:
void loop() {
digitalWrite(interr, HIGH);
delayMicroseconds(100);
digitalWrite(interr, LOW);
delayMicroseconds(100);
}
Hi ard_newbie,
I mean the time to jump to the function interrupt (bink()) when the arduino due has external interrupt.
I just sent data from arduino due to computer and didn't transfer from computer to arduino due so I can't have serial interrupt.
ard_newbie:
Some thoughts:
1/ A Serial.println() takes several tens of us
2/ Avoid any Serial print inside an interrupt. Instead, set a Flag in the interrupt routine, test this Flag inside lopp() to Serial print (or not).
3/ You want to debounce the input interrupt signal