-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
IBMPC: Read pin state earlier with Naked ISR #717
Comments
Another workaound would be fixed register. GCC option Note that the option doesn't effect precompiled libraries, which can already use the fixed register. Actually avr-libc can use all registers, for example
Makefile:
This naked ISR can reads the pin in 8 cycles. [5(interrupt) + 3(jmp in vector table)] https://github.com/tmk/tmk_keyboard/tree/ibmpc_naked_isr_fixed_reg |
We have to read data line as early as possible for IBM XT keyboard within 5us.
https://github.com/tmk/tmk_keyboard/wiki/IBM-PC-XT-Keyboard-Protocol#note-for-start0
https://github.com/tmk/tmk_keyboard/wiki/IBM-PC-XT-Keyboard-Protocol#isr-prologue
With normal ISR its prologue(pushing registers) is inevitable and it can consume tens of clocks before reading data pin. We have to read the pin before the prologue especially when ISR requires many registers and prologue is long.
To circumvent the ISR prologue we can use naked ISR which doesn't generate prologue. But there is no general purpose register(r0-r31) to store pin store safely in naked ISR.
One of possible workaround would be to store data pin state(PIND) temporarily in unused IO register(0x01) instead of general purpose register. ATMega32u2/4 has no PORTA but 0x01(DDRA) can seem to be used for this purpose. DDRE is another candidate.
This naked ISR can reads the pin in 10 cycles. [5(interrupt) + 3(jmp in vector table) + 2(push r0)]
One cycle time is 62.5ns at 16MHz.
ATmeaga32U4 datasheet:
https://github.com/tmk/tmk_keyboard/tree/ibmpc_naked_isr_io_reg
The text was updated successfully, but these errors were encountered: