Checked and can confirm this. There was a bug in the GPT implementation which leads to calling the ISR two times for very fast interrupt service routines. The bug was already fixed but for some reason the fix was commented out. I updated the GitHub repo already, but if you don't want to update you can also add a "DSB" instruction at the end of your ISR.
Code:void tRun(){ state = 1 - state; digitalWriteFast(pin, state); asm volatile("dsb"); // <--------------------------------- return; }
Alternatively you can do
Code:void tRun() { digitalWriteFast(pin, !digitalReadFast(pin)); }
which is a little bit less efficient than your code which makes it work as expected.
THANKs for spotting that!
Excellent! I’m glad my tests have been useful. I will be focusing my attention on the OneShotTimer next as I am curious to see if that might suit my needs better