diff --git a/C64_4joy_adapter/README.md b/C64_4joy_adapter/README.md index 74e629f..5a8829c 100644 --- a/C64_4joy_adapter/README.md +++ b/C64_4joy_adapter/README.md @@ -39,6 +39,22 @@ sei - lds/sts takes 2 cycles and in/out takes 1 cycle? ldi takes 1 cycle? - lds/sts: "M" \_SFR_MEM_ADDR(GPIOR2), in/out: "I" \_SFR_IO_ADDR(GPIOR0) +## interrupts +- https://billgrundmann.wordpress.com/2009/03/02/the-overhead-of-arduino-interrupts/ +- https://forum.arduino.cc/t/how-fast-can-i-interrupt/25884/5 +``` +This is from the datasheet for the AT90USB82 processor; things in parenthesis are from me... + +The interrupt execution response for all the enabled AVR interrupts is five clock cycles minimum (the processor is fixin' to execute the interrupt) +The vector is normally a jump to the interrupt routine, and this jump takes three clock cycles (the processor jumps to the ISR) +SREG must be saved and restored (the processor doesn't do this for us and SREG is important) +A return from an interrupt handling routine takes three clock cycles +When the AVR exits from an interrupt, it will always return to the main program and execute one more instruction before any pending interrupt is served +Those are the things necessary just to get the ISR called. We have not yet added the application stuff (incrementing an unsigned long in BetterSense's case). + +Adding those up gives us 5+3+2+3+1 = 14. The absolute maximum number of interrupts per second that can be handled by the AT90USB82 is 16 million instructions per second / 14 instructions per interrupt = 1,142,857 interrupts per second. +``` + ## avr asm - http://www.nongnu.org/avr-libc/user-manual/inline_asm.html - https://ucexperiment.wordpress.com/2016/03/04/arduino-inline-assembly-tutorial-1/