Hi Rysard,
To explain the delay we can think on the following:
1 GPIO clocking.
According to the device Reference manual, the Bus clock, which feeds the GPIO, can run up to 24 MHz So that limits the GPIO sampling, GPIO interrupt latency and writing to be faster.
2 GPIO rise time .
The chapter 5.3.3.2 General switching specifications
Details the switching timing for the GPIO. For example the largest rise time is close to 34 n’s, but that depends on certain conditions listed on the table.
3 Software overhead
High level functions add additional timing. To diminish overhead you can use direct registers PTOR, PSOR to set the GPIO pin and check disassembly code to see what is taking additional time.
4 Interrupt latency.
For the NVIC of the Arm Cortex M0+ , the minimum latency to enter an ISR is close to 15 clock cycles, when the flash memory is read with 0 wait states. That will sum the global delay.
Beginner guide on interrupt latency and Arm Cortex-M processors - Processors blog - Processors - Arm...
5 Use Fast I/0
If you are willing to decrease the delay, you can us0 the Fast I/O.
The following post details this An experiment -- Fast GPIO vs normal GPIO and provide example codes.
Additionally, the information on this post may help you Interrupt latency time (cycles)
Unfortunately, I do not have access to an scope to follow you on this, But I hope this helps.
Regards,
Diego