i have a square wave signal variing from 1-2 MHz and was wondering if i can detect every rising edge of the signal with the buit-in command attachInterrupt(digitalPinToInterrupt(pin), ISR, mode)?
In other words how fast is this command?
jannik_b:
I'm using the arduino due by the way. Do you know how fast this command is at max. ? I can't find anything related in the datasheet
I have not looked at a data sheet for your particular processor, but I suspect there is narrative describing the steps the processor takes to process an interrupt and the return from the interrupt. From that you can determine the exect number of processor steps taken and that will allow you to add up the times and that will tell you the minimum time for an interrupt.
Then add the times for the instructions in your interrupt code to the processor interrupt time. The sum is exactly how long each interrupt will take.
Paul
i have a square wave signal variing from 1-2 MHz and was wondering if i can detect every rising edge of the signal with the buit-in command attachInterrupt(digitalPinToInterrupt(pin), ISR, mode)?
In other words how fast is this command?
The speed of the attachInterrupt() "command" is irrelevant. What you care about is the speed of servicing the interrupt (as @Paul_KD7HB described).
In fact, for fastest servicing you would not use attachInterrupt() at all. Rather service the raw interrupt vector yourself.
jannik_b:
i have a square wave signal variing from 1-2 MHz and was wondering if i can detect every rising edge of the signal with the buit-in command attachInterrupt(digitalPinToInterrupt(pin), ISR, mode)?
In other words how fast is this command?
What processing do you need on every rising edge? Are you just counting them? If so, external hardware counters might be the answer.