PS/2 Direction for the Commander X16

Announcements by the development team or forum staff.
Edmond D
Posts: 489
Joined: Thu Aug 19, 2021 1:42 am

PS/2 Direction for the Commander X16

Post by Edmond D »


I'm glad there are people to step up and take managing this community on, and there is time to figure out a way forward. 



To me the site IS the product at the moment. While we patently wait for a shipping X16 there is so much here to enjoy:


  •  the forum with all its users who have posted from the technical to the social (with their own wit, insight and opinions)


  • the library of software available, and


  • the ability to run a web emulator.


I believe the majority here will gladly become consumers because they are part of the community. One the hardware ships I hope there is an explosion of more free software here, rather than spread far and wide on the interweb.

 Finally, this site has the best forum implementation I've ever seen. Kudos to  those who built it,  those who will manage this community. and those who contribute content.

Stefan
Posts: 454
Joined: Thu Aug 20, 2020 8:59 am

PS/2 Direction for the Commander X16

Post by Stefan »



On 12/31/2021 at 6:26 PM, BruceMcF said:




That would seem to be the direct solution ... pull the PS2 SCL clock line low while leaving the data line high before starting to send data to the master over I2C, release it when done.



I still think using I2C will make matters more complicated, as evidenced by the fact that we have not yet a functional keyboard.

The Veronica's keyboard, that I mentioned above, does not need to disable the PS/2 line during operation. After receiving the 11th bit of a PS/2 envelope, the keyboard controller directly puts the byte received onto the shift register which is then available to the 6522. There is enough time to do this before receiving the next PS/2 start bit. The 6502 may then read the byte from the 6522 with a simple LDA instruction. In other words, the 6502 and 6522 are used as designed. We shouldn't fight that.

I don't know, but it feels like the PS/2 wasn't designed to be disabled after every scan code. There is, for instance, no standard saying how quickly the PS/2 device should start when enabled again, it's only said that it cannot start before 50 µs has passed.

paulscottrobson
Posts: 305
Joined: Tue Sep 22, 2020 6:43 pm

PS/2 Direction for the Commander X16

Post by paulscottrobson »


How about we have a microcontroller for every single key on the keyboard and every function on the circuit board. Think how fast it will go then.

Or we could stop pretending.

 

TomXP411
Posts: 1781
Joined: Tue May 19, 2020 8:49 pm

PS/2 Direction for the Commander X16

Post by TomXP411 »



On 1/1/2022 at 3:01 AM, Stefan said:




I still think using I2C will make matters more complicated, as evidenced by the fact that we have not yet a functional keyboard.



The Veronica's keyboard, that I mentioned above, does not need to disable the PS/2 line during operation. After receiving the 11th bit of a PS/2 envelope, the keyboard controller directly puts the byte received onto the shift register which is then available to the 6522. There is enough time to do this before receiving the next PS/2 start bit. The 6502 may then read the byte from the 6522 with a simple LDA instruction. In other words, the 6502 and 6522 are used as designed. We shouldn't fight that.



I don't know, but it feels like the PS/2 wasn't designed to be disabled after every scan code. There is, for instance, no standard saying how quickly the PS/2 device should start when enabled again, it's only said that it cannot start before 50 µs has passed.



I keep looping back to the same issue… a dedicated keyboard controller just makes more sense. IBM did it for a reason. I don’t care whether the interface between the keyboard controller and the computer is serial or parallel… but letting an AVR handle the low level PS/2 implementation really does make sense. 

martinot
Posts: 115
Joined: Fri Aug 21, 2020 3:32 pm

PS/2 Direction for the Commander X16

Post by martinot »



On 1/1/2022 at 2:01 AM, Perifractic said:




Off-topic: Just to clarify a little further, yes I am hosting the site still. The site’s creation came about with the endorsement of the whole X16 dev team on Slack, and indeed everyone seemed quite pleased with it initially. It even allowed David to shut down his own forum Murray2 with his brother and move the archives to this one. The team were all encouraged to post official updates here first, and copy the forum url to Facebook. However I think people just find Facebook quicker, and ultimately I couldn’t force the team to keep updates going here without starting to sound like I was nagging them each time ?



Still I think it’s a wonderful site and @MattGrandisand I are very pleased with it, particularly the software library with built in emulator. Don’t see that very often elsewhere!



That is why, when there were no other offers from the team to keep the site alive, I financed another year of it recently even though I had stepped back from the X16 project itself. There’s a ton of time and work here that would’ve been lost and disappointed hundreds of people  



We’re open to passing the baton to the community as long as it is properly maintained and moderated. Feel free to DM @MattGrandis and I in a group message if you are serious about taking it on. I’m already discussing with one member also but we have about 8 months before we have to make the switch so no rush.



Thanks for your belief in the site as a cool place to be and a useful ecosystem. Happy new year! 



Thanks @Perifractic for all the fantasitic work you have put into the site.

I think this is one of most beautiful and well functional forum I ever used. It is a true raw model for a great community site. Love the design of it!

EMwhite
Posts: 220
Joined: Mon Sep 07, 2020 1:02 pm

PS/2 Direction for the Commander X16

Post by EMwhite »


Getting back to on-topic of this thread, why is supporting PS/2 so difficult?  Is it that the rest of the architecture of the orig. X16 does not play well with PS/2?

It seems peculiar that others have implanted PS/2 kbd. and mouse with zero fanfare or difficulty and X16 is awaiting the return [to the project] of one person (I don’t know the name is the person, somebody that wrote the kernel I believe).

BruceMcF
Posts: 1336
Joined: Fri Jul 03, 2020 4:27 am

PS/2 Direction for the Commander X16

Post by BruceMcF »



On 1/2/2022 at 12:13 PM, EMwhite said:




Getting back to on-topic of this thread, why is supporting PS/2 so difficult?  Is it that the rest of the architecture of the orig. X16 does not play well with PS/2?



It seems peculiar that others have implanted PS/2 kbd. and mouse with zero fanfare or difficulty and X16 is awaiting the return [to the project] of one person (I don’t know the name is the person, somebody that wrote the kernel I believe).



One thing to be careful about is that somebody interfacing with the PS/2 keyboard they have doesn't guarantee that the same code will interface with every keyboard that obeys the PS2 spec.

One possibility, which is waiting on Micheal Steil having time for the X16 project to open up again, is that the timeout on the 65C02/6522 code is just too fast when the code runs at 8MHz, and adjusting the timeout will fix the issue.

Wavicle
Posts: 281
Joined: Sun Feb 21, 2021 2:40 am

PS/2 Direction for the Commander X16

Post by Wavicle »



On 1/2/2022 at 9:13 AM, EMwhite said:




Getting back to on-topic of this thread, why is supporting PS/2 so difficult?  Is it that the rest of the architecture of the orig. X16 does not play well with PS/2?



It seems peculiar that others have implanted PS/2 kbd. and mouse with zero fanfare or difficulty and X16 is awaiting the return [to the project] of one person (I don’t know the name is the person, somebody that wrote the kernel I believe).



I'm mostly interested in the hardware on this project, but your prompted me to look into the PS/2 code. I think we are seeing the result of two factors in the way the X16 handles PS/2:


  1. KERNAL inhibits PS/2 communication except when servicing the keyboard.


  2. KERNAL polls for a fixed time after resuming PS/2 communication.


The code for this is in kernal/drivers/x16/ps2.s:

[code]

ps2_receive_byte:

; set input, bus idle

    lda port_ddr,x ; set CLK and DATA as input

    and #$ff-bit_clk-bit_data

    sta port_ddr,x ; -> bus is idle, keyboard can start sending

    lda #bit_clk+bit_data

    ldy #10 * mhz

:    dey

    beq lc08c

    bit port_data,x

    bne :- ; wait for CLK=0 and DATA=0 (start bit)

[/code]

That "ldy #10 * mhz" is the delay. In this case it is 10 * 8 = 80 loops. The last 4 lines are executed 80 times waiting to see the PS/2 start condition (both CLK and DATA going low). If there is no start condition, the code re-inhibits communication and returns. I do not believe that the PS/2 spec provides a guarantee for how long after the host resumes communication before the device must send a start a bit if it has data ready. The device itself probably has an always running PS/2 clock so it probably won't send the start bit until the clock after it detects that the host has de-inhibited traffic.

I suspect that this is the problem hitting the X16. At higher frequency, 80 loops is not a long enough delay for some keyboards. After seeing nothing for 80 loops, KERNAL re-inhibits the device before it has had a chance to send a start bit. At 2MHz, the delay is 4x longer and is an adequate delay, again, for some keyboards. This inhibit/poll solution is not what the PS/2 interface was designed for. Inhibiting communication is expected to be a rare event (e.g. during BIOS/UEFI initialization at system BOOT). The keyboard needs to be attached to a controller that doesn't keep communication inhibited and is ready to consume data when it is available. In other words - it needs a dedicated controller or a host keyboard handler that is interrupt driven.

The issue might be fixed for now by changing the loop count from 10 * mhz to 40 * mhz.

kelli217
Posts: 531
Joined: Sun Jul 05, 2020 11:27 pm

PS/2 Direction for the Commander X16

Post by kelli217 »



On 1/2/2022 at 7:07 PM, Wavicle said:




The issue might be fixed for now by changing the loop count from 10 * mhz to 40 * mhz.



Or (32 * MHz) - 1. as the case may be. ? 

Wavicle
Posts: 281
Joined: Sun Feb 21, 2021 2:40 am

PS/2 Direction for the Commander X16

Post by Wavicle »



On 1/2/2022 at 5:33 PM, kelli217 said:




Or (32 * MHz) - 1. as the case may be. ? 



Fair point, I hadn't accounted for the register being 8 bits.

Post Reply