6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Fri Nov 01, 2024 5:38 am

All times are UTC




Post new topic Reply to topic  [ 11 posts ] 
Author Message
 Post subject: Keyboard decoder
PostPosted: Sat Aug 21, 2004 4:32 am 
Offline
User avatar

Joined: Fri Aug 30, 2002 9:02 pm
Posts: 1745
Location: Sacramento, CA
I have created a PC keyboard decoder using an Atmel ATTiny26 controller. (20 pin DIP package).

Here are the preliminary specs:

This chip does all of the scancode decoding of a standard keyboard and provides an 8 bit output containing the standard ASCII codes in addition to special codes for the extra keys (Alt, windows, pause, scroll lock, etc).
Data ready and data acknowlege signals are used for handshaking.

This takes the workload off of the 6502 and can be easily connected using an 8 bit port on a 6522. I have a working prototype connected to Port B of a 6522 on my SBC. Port A has my Text Video Display connected, allowing complete stand alone operation of my SBC. (No Serial port terminal required!)

I hope to have a working PCB designed soon that will integrate the keyboard decoder, text video, and the necessary logic to allow connection thru the expansion port, keeping the SBC's 6522s available for general I/O.

I'll update my website soon with all the details.

Thanks!

Daryl


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Wed Feb 28, 2007 9:18 am 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8534
Location: Southern California
In your diagram at http://sbc.rictor.org/io/pckbavr.html (diagram shown below), you show a pull-up resistor on both the clock line and the data line. Is there any need to have one on the clock line? It is only fed from the controller end isn't it, so it could be connected to a totem-pole output with no resistors? You show the other keyboard interface at http://sbc.rictor.org/io/pckb6522.html with the 6522 with no pull-ups at all, but I figured that was because the older ones really did have LSTTL-type inputs instead of high-impedance like WDC's CMOS ones, so they were naturally pulled up internally.

Image


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Wed Feb 28, 2007 1:49 pm 
Offline
User avatar

Joined: Fri Aug 30, 2002 9:02 pm
Posts: 1745
Location: Sacramento, CA
Garth,

Both resistors are optional. I think I threw them in because some of the reference material I was using showed the pull-up resistors in their interfaces. I made them 10k in value so they were providing a weak pull-up. Just above the schematic on the web page, I included this text:

Quote:
This keyboard decoder takes all of the overhead associated with scancode to ASCII conversion and places it in the interface. This frees the 6502 to handle more important operations. The simple circuit consists of an 6-pin PS2 keyboard socket, an Atmel ATTiny26 microcontroller, a 14 pin header, and two optional resistors!


Hope that answers your question?

Daryl


Last edited by 8BIT on Sat Feb 21, 2009 4:14 pm, edited 1 time in total.

Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Wed Feb 28, 2007 6:29 pm 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8534
Location: Southern California
Obviously I haven't looked into it enough to do it myself but it is my understanding that the data line has to be a wire-OR open-drain-type arrangement so data can be sent both directions on an interface that is much like I²C; so it would require the pull-up. I²C needs it on the clock line too if you have a multi-master situation (which is not common).


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Thu Mar 01, 2007 12:39 am 
Offline
User avatar

Joined: Tue Mar 02, 2004 8:55 am
Posts: 996
Location: Berkshire, UK
The I2C standard allows slave devices to perform 'clock-stretching' if they need more time to process a request. If a slave holds the clock line low then the master should wait for line to return to the high state before continuing with the next byte transfer. So both clock and data can be bi-directional even in a single master configuration.

_________________
Andrew Jacobs
6502 & PIC Stuff - http://www.obelisk.me.uk/
Cross-Platform 6502/65C02/65816 Macro Assembler - http://www.obelisk.me.uk/dev65/
Open Source Projects - https://github.com/andrew-jacobs


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Tue Mar 06, 2007 10:13 pm 
Offline

Joined: Tue Mar 06, 2007 6:37 pm
Posts: 5
The PS/2 clock can be driven from either end too, so if the data line needs a
pull-up odds are the clock will too. The reason for this is that if the host wants
to send commands to the keyboard it signals this by pulling the clock low for
(at least) 100 microseconds, then releasing it and waiting for the keyboard to
start clocking in the bits.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Mon May 07, 2007 2:08 pm 
Offline

Joined: Sat May 20, 2006 2:54 pm
Posts: 43
Location: Brighton, England
Both the clock and data lines need a pull-up of some sort. The keyboard specification requires the lines be driven with open-collector style outputs at both ends, so both ends can pull the lines low at the same time but neither end can pull it high and create a short-circuit when the other end pulls it low.

If your microcontroller chip has built-in pullups you can use these, keeping the pin as an input except when you want to pull it low. I prefer adding external 10k pullup resistors - they help to improve the noise immunity.

_________________
Shift to the left, shift to the right,
mask in, mask out,
BYTE! BYTE! BYTE!


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Mon May 07, 2007 7:12 pm 
Offline

Joined: Fri Aug 30, 2002 2:05 pm
Posts: 347
Location: UK
The spec requires the attached device, keyboard or mouse, to have the pullups.

Lee.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Fri May 11, 2007 9:45 pm 
Offline

Joined: Sat May 20, 2006 2:54 pm
Posts: 43
Location: Brighton, England
Thanks for that snippit - in all the pages of stuff I've read on the keyboard & mouse interface, that fact was notable by its absence. Darn - all those resistors I could have saved... :roll:

_________________
Shift to the left, shift to the right,
mask in, mask out,
BYTE! BYTE! BYTE!


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Tue Apr 28, 2009 8:46 pm 
Offline
User avatar

Joined: Sun Feb 13, 2005 9:58 am
Posts: 85
hi Daryl, i'm investigatin on ps2 keyboard.
a question: why did you choose to use an external controller and not use a 6522 direct interface?
do you think is it a problem to put under irq an interfacing routine?
i asking to myself why didnt we (forum) already make some "standard" interface routines for general purpose use ps2 keyboard.
thanks!


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Tue Apr 28, 2009 9:34 pm 
Offline
User avatar

Joined: Fri Aug 30, 2002 9:02 pm
Posts: 1745
Location: Sacramento, CA
Why not use the 6522?

Personal preference on my part. Depending upon your application, the 6522 is a great choice. It requires no additional parts or address decoding. If you want to reduce the chores of decoding the serial data from the 6502, then a microcontroller is a good choice. It adds extra hardware and decoding.

In the case of the SBC-3, I wanted to leave as much of the 6522's resources open as possible for user applications. Also, since I didn't want the 65816 to be bogged down servicing numerous I/O tasks, I chose the microcontroller. The added benefit was an RS-232 port for no extra hardware!

I have written a PC keyboard decoding routine for the 6522. The code is on my website. It does not require interrupts as it disables the keyboard from clocking until the 6502 is ready to read it. It could be modified for intterupts if desired.

http://sbc.rictor.org/io/pckb6522.html

Hope that helps!

Daryl


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 11 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: