PS/2 Direction for the Commander X16
Posted: Tue Aug 24, 2021 11:24 pm
Hello everyone,
I wanted to discuss an issue we have been struggling with, and that is PS/2 keyboard and mouse support. This is probably not a secret to anyone watching the videos on the X16 as most of the time we are running at 4MHz or 2MHz. This is completely due to PS/2 timing issues. I've spoken with Michael Steil about this issue many times and he has taken several approaches to get it to working stably. After adding the microcontroller to control the ATX power supply, I proposed the idea of adding a few more pins to also control the PS/2 ports. Like many in the community, he would perfer to get it working as it stands, so I proposed adding jumpers to select between the microcontroller, or the 65c22. So, I did just that on the third prototype. With tiny revisions, this will become our development board so it will give folks the option to try either approach.
I initially thought about writing the code for the Arduino myself. I've messed around with Atmel microcontrollers going on 20 years now, but the truth is, I'm probably not the best one for this task. The code I wrote for the ATX power control is working, but I can't seem to get my reboot function to work for some reason.... Anyway, I digress, I guess the real reason I'm making this post is to ask for some help from the community!
We are not committed to one approach or the other necessarily. IE, we are still planning to work on the 65c22 'bit-bang' approach (heck, we maybe could use some help here too), but alternately I wanted to start working on the microcontroller code to at least evaluate it before the final version of the board.
If you're interested, here are some details wrt to how I have the HW setup on the current prototype. The attached pic shows U18, which is the ATTINY861 microcontroller. I really wanted to stick with no more than a 20 pin IC if possible, to make it look like it matches the board. This chip can run at 8 or 16MHz without an external crystal, but I gather the 16MHz mode may not be as stable. Not sure if this will be an issue later, but I wanted to mention it. I sort of just guessed the chip would be fast enough to handle both the mouse and the keyboard. There are certainly plenty of keyboard libraries out there, and at least one mouse library I'm aware of, but I'm not sure if they have ever been combined. I am running the microcontroller as an I2C device with the 6522 acting as the host to this IC. Right now, it is only listening for commands to power-off the system, reboot, reset, NMI & HDD LED control. I also hooked a line up to the 65C02 IRQ, so it could be polled. (Just as an FYI, the real-time clock is U10, which is read via I2C. J16 is the external I2C header to drive other devices if desired. J16 will also work as a 6-pin ISP header to program the ATTINY861. J6-J9 toggles the clock/data line for each PS/2 port from 65c22 to the ATTINY861.)
In a nutshell, I'd like it to maintain the existing functions which should be taking next to nothing in terms of CPU, except maybe the I2C library. Integrate IRQ driven PS/2 mouse and keyboard routines and make the code as clean as possible for easy editing. If we do wind up going this route, your work could be part of the open-source library at the end of the rainbow for the system. Clearly, there will need to be some interaction on the kernal-side to process the data from these interrupts. This will take some coordination too, but I suspect the Arduino-side could be tested with another Arduino reading the data for the time being. Keep in mind, we could also wind up not using it too, just fair warning.
Keep the responses on this thread for the time-being. I know this is a big ask, but I really want to make sure we have a nice solid library, so I decided it would be better to get a rock-star developer out there. Assembly is fine too, if you want to do it the hard way ?, but I suspect C will be fine. I also attached the code which is running on the proto for now.
Please let me know if you have any questions, I'm looking forward to testing this out!
Thanks!
-Kevin
X16_Power-current.zip