68HC11 Sample Code - PS/2 keyboard scancode reader/reporter
Simple interrupt-driven program to deserialise data-bitstream from a PS/2 keyboard, asynchronously insert scancode bytes into a circular buffer, and to on-demand report the contents of the buffered scancodes so received.
Uses on-chip SCI for commands/responses.
Uses PORT A pin 0 (input-capture #3) to detect falling PS/2 clock-edges.
Uses PORT C pin 3 to sample the PS/2 data-line.
Uses PORT B pins 0 1 to drive indicator/debug LEDs.
Runtime commands:
- r = report contents of received-scancodes buffer (in hex)
- 1 = directly toggle LED1
- 2 = directly toggle LED2
- q = restart BUFFALO
Whilst all the above is going on, you can type on the PS/2 keyboard attached via the passive interface circuit described at https://sparc90s.wordpress.com/2017/04/28/with-a-cherry-on-the-side-episode-seven-peripheral-action/.
Source Code:
- p2k.asm - the main program and PS/2 interface/interrupt routines
- lib.asm - utility routines located in on-chip EEPROM
- board.def - definitions for the target board (EVB, EVBU, Adapt-11, EVM, modern EVBU replicas, etc)
- hc11e.def - definitions for the 68HC11E MCU family
- mancon.def - manifest constants
- buffalo.def - definitions of addresses when using the 68HC11 BUFFALO monitor
- masm11 - shell-script to invoke cpp preprocessor and then as11 assembler to produce loadable object-code and symbol-table.
Mike Spooner, 30th April 2017