Does anyone have any suggestions or code snippets to share that will help be in my quest to read data from an older style PS/2 keyboard? One-way communication is all I need - from keyboard to PIC. (I have no real need to switch on Caps Lock leds etc, although that would be an added bonus)
Mikrobasic offers a library for PS/2 keyboard communications, but I don't really want to change to a different comiler at the last minute of development.
Warmest regards,
Ralph
PS/2 Keyboard
Moderators: David Barker, Jerry Messina
Its fairly easy as it is a simple synchronous buss
http://www.computer-engineering.org/ps2protocol/
should be all the info you need
http://www.computer-engineering.org/ps2protocol/
should be all the info you need
If you can read this you are too close
I recently made a user module for PS/2 AT Keyboards, perhaps it will do the job for you?
It's software driven with optional interrupt driven timeouts. Here's an example of the modules use:
It's software driven with optional interrupt driven timeouts. Here's an example of the modules use:
Code: Select all
Device = 18F2520 // 18F2520 PIC in use, could be any 18F PIC
Clock = 32 // clock speed is 32Mhz (8MIPS)
Config MCLRE = Off // disable MCLR
Include "InternalOscillator.bas" // search for "User Module Pack" at www.digital-diy.com
Include "USART.bas" // used for displaying content on a uart terminal
Include "swKBD.bas" // PS2 Keyboard module. URL http://digital-diy.com/home/swordfish/user-modules/242-ps2-keyboard-module-swkbdbas.html
SetBaudrate(br38400) // initialise USART for 38400 baud
USART.Write("Power On",13,10) // send a message to the terminal
While True // main program loop
If swKBD.NewKey Then // checks the device for new information
If KBD.ValidChar Then // ensure the key is a valid non-white space character
USART.Write(KBD.KeyChar) // yes, display it via USART
ElseIf KBD.KeyCode = KBD_ENTER Then // check if the 'Enter' key was pressed
USART.Write(13,10) // yes, send a line feed and carriage return
EndIf //
EndIf //
High(PORTB.7) // toggle PORTB.7 high then low,
Low(PORTB.7) // to measure the time it takes between loops
Wend //
digital-diy.com - Hobby microcontroller projects and tutorials. Assembly, PICBasic and C examples.
Australian distributor for the Swordfish Compiler
Australian distributor for the Swordfish Compiler
Perfect - thanks
Superb - thanks Graham, that is just what the doctor ordered!