Download presentation
Presentation is loading. Please wait.
Published byDaisy Scott Modified over 9 years ago
1
1 COMP541 Input Devices: Keyboards, Mice and Joysticks Montek Singh Apr 16, 2012
2
Keyboard Interface
3
3 PS/2 Keyboard Uses a synchronous serial protocol What does that mean? What does that mean? Each symbol is transmitted bit-by-bit Each symbol is transmitted bit-by-bit 8 data bits + 3 control bits
4
4 Physical Interface Two lines Clock (15-20KHz) Clock (15-20KHz) Data Data Normally high, asserted low Normally high, asserted low Read: pp 13-14 of Nexys 3 manual pp 13-14 of Nexys 3 manual
5
5Protocol Bidirectional Kybd-to-host and host-to-kybd on same wires Kybd-to-host and host-to-kybd on same wires CAPS LOCK light for example Assert low To send, keyboard starts clocking To send, keyboard starts clocking sends successive bit on positive edge of clock host reads bits on negative edges of clock You shouldn’t need to send to kybd
6
Protocol 11 bits a start bit: always 0 a start bit: always 0 8 bits of data 8 bits of data lsb first one parity bit (odd) one parity bit (odd) a stop bit: always 1 a stop bit: always 1 Clocked by keyboard Value should be latched by FPGA on neg edge of keyboard clock Value should be latched by FPGA on neg edge of keyboard clock 6 Illustration from http://www.beyondlogic.org/keyboard/keybrd.htm
7
7 What is Sent ASCII is not sent! Scan codes for keys Most keys have an 8-bit (single byte) scancode Most keys have an 8-bit (single byte) scancode Some have two bytes Some have two bytes A few have even more! A few have even more! Most (not all, be careful!) keyboards use these scancodes: Most (not all, be careful!) keyboards use these scancodes: Illustration from Nexys 3 manual
8
8 Scan Codes Normally translated by software You remap your keys, for example You remap your keys, for example Software takes care of Shift, caps lock, control Shift, caps lock, control
9
9 Some Scan Codes Long Two code sequence common Have a look at Break key! Have a look at Break key!
10
10 Even More Complicated Scan code generated when you press And when you release Two bytes: F0 followed by key scan code Two bytes: F0 followed by key scan code Example: Example: Space pressed, 29 sent Space released, F0 29 sent If you hold key, scan code repeated
11
11Resources Information http://www.beyondlogic.org/keyboard/keybrd.htm Scan codes http://www.barcodeman.com/altek/mule/scandoc.php My Verilog for keyboard is on the class website
12
12 My Verilog Have Verilog for keyboard Have tested it with the FPGA kit; seems to work fine To use: You should memory-map the character code register You should memory-map the character code register give the keyboard a memory address so the CPU can read it using lw instructions Handle presses and releases appropriately in software Handle presses and releases appropriately in software maybe add another register to indicate that a new character has arrived..??
13
Mice 13
14
Mouse Very similar interface (clk & data) But: 3 words sent w/ mouse movement or button press But: 3 words sent w/ mouse movement or button press Read pp 14-15 of Nexys 3 manual pp 14-15 of Nexys 3 manual 14
15
Movement Movement is relative XS, YS are sign (+ is up/right) XS, YS are sign (+ is up/right) XV, YV are overflow (too fast) XV, YV are overflow (too fast) L, R are buttons L, R are buttons 15
16
Scroll Wheel, etc. Extensions to original 2 button PS/2 mouse See http://www.computer-engineering.org/ps2mouse/ See http://www.computer-engineering.org/ps2mouse/ http://www.computer-engineering.org/ps2mouse/ 16
17
Joystick (Courtesy Anselmo Lastra)
18
Atari 2600 Joystick (we only have 2-3) 18 http://www.atariarchives.org
19
We Have Sega Joypads (we have 5-6) Enhanced version with more buttons Has mux Has mux Select pin chooses first or second set of buttons, L/R Select pin chooses first or second set of buttons, L/R 19 http://pinouts.ru/data/genesiscontroller_pinout.shtml
20
Six Button Use See http://www.cs.cmu.edu/~chuck/infopg/segasix.txt http://www.cs.cmu.edu/~chuck/infopg/segasix.txt http://www.cs.cmu.edu/~chuck/infopg/segasix.txt Use select to use buttons B & C To use X, Y, Z, need to pulse select 20
21
NEXYS Mappings (PMOD JA) We have to connect them using wires… 21 SignalFPGA PinDB-910- Pin UpM1514 DownL1723 LeftL1638 RightK1242 Btn A/BM1469 Start/CL1591 SelectM16710 Ground-85 Power-56 PMOD JA is 10-pin connector nearest VGA connector
22
Suggestion Create FF for Select Memory map so you can set from CPU Memory map so you can set from CPU Memory map the input signals I would not latch them I would not latch them Please power off when plugging or unplugging Sega joypads! Careful when plugging in PCB Careful when plugging in PCB 22
23
23Links http://pinouts.ru/data/JoystickAtari2600_pinout.shtml http://pinouts.ru/data/JoystickAtari2600_pinout.shtml http://pinouts.ru/data/genesiscontroller_pinout.shtml http://pinouts.ru/data/genesiscontroller_pinout.shtml http://www.epanorama.net/documents/joystick/ataristick.html http://www.epanorama.net/documents/joystick/ataristick.html http://www.epanorama.net/documents/joystick/tvgames.html http://www.epanorama.net/documents/joystick/tvgames.html http://www.cs.cmu.edu/~chuck/infopg/segasix.txt http://www.cs.cmu.edu/~chuck/infopg/segasix.txt
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.