I have to wait for an ACK after a command, that I expect to become high within 100us. If the signal won’t switch during this period, the communication failed.
First try is to use a “for” loop, with “max cycle count” calculated as number of clocks in 100us (given 16MHz clock). Something like
boolean gotACK = false; for(int i = 0; i < MAX_ACK_DELAY; i++) if(digitalRead(ackPin) == HIGH) gotACK = true;
But the single “for” cycle needs more than a single clk cycle to run, since several operations are involved (increment index, check cycle termination, read digital signal).
Is there a more precise way to monitor the input for exactly 100us?