ATTINY85 ADC Sampling Rate (pulse detection rate)

I am new to arduino programing...

I am trying to detect a single event pulse with a pulse width of ~100us (10kHz?). After the pulse is detected by the MCU, a digital output is activated HIGH.

Please see attached oscilloscope screenshot. channel 1 (Yellow) is my pulse. Channel 2 is my MCU digital output. It take ~140us after the pulse is detected by the MCU to read a digital output.

My goal is to reduce the time between detection and output. 20-50us would be ideal. How can I do that. Does this has to do with the sampling rate of the ADC or the MCU internal clock?

Does anyone know what the default Arduino/Attiny85 ADC sample rate is? I am able to detect 90% of the pulses but I would like to get 100% detection rate.

Is there a simple code to increase the sample rate say to 100kHz? or reduce time between pulse detection and output?

thanks

Why are you using an analog input to detect a digital pulse? Use a digital input.
Something like;

if(digitalRead(inPin) == HIGH)
  digitalWrite(outPin,HIGH);

Or:

digitalWrite(outPin,digitalRead(inPin));

My pulse has various of amplitudes. its between 1-4 volts. A digital input high should be 5volts?

Also I am using another device to set a threshold for the analog input. for example if the analog input is above the threshold the digital output high.

My pulse has various of amplitudes. its between 1-4 volts. A digital input high should be 5volts?

The digital threshold for logic 0 (low) is 0.3VCC = 1.5V, for logic 1 (high) its 0.6VCC = 3V. So a 1-4 volt signal should work fine on a digital input.

thanks but if my pulse amplitude is 1volts. the digital input of MCU will not detect the pulse. I will need to use the analog input. I want to detect pulse even with 1volt, maybe even 800mV. since the digital low is 0.3VCC=1.5V, 1V pulse will not be detected.

for higher amplitude pulses. I can try to see if I get any speed improvements using the digital input versus the analog input.

My pulse is already being amplified using a high-speed transimpedance op-amp with large bandwidth, I could replace it with a digital variable gain transimpedance op-amp and set the detection threshold using the variable gain. So the signal going to the digital input of the MCU will have a pulse amplitude of greater than 0.6VCC at all times.

But for now I am looking for a code that will improve the sampling rate and shorten the time between the detection and the digital output

Section 16 in the datasheet details the analog comparator included in the chip. It's not an often used peripheral, but it sounds like exactly what you need.

You don't have external access to the output so you can't wire up hardware hysteresis, but you can use a software method to filter out trigger events that happen to close to each other in time.