PS/2 Mouse working with ATTINY and I2C

Chat about anything CX16 related that doesn't fit elsewhere
BruceMcF
Posts: 1336
Joined: Fri Jul 03, 2020 4:27 am

PS/2 Mouse working with ATTINY and I2C

Post by BruceMcF »



On 8/11/2022 at 10:50 AM, ZeroByte said:




If there were legs available, you could just wire them to a data port on VIA1 and have them as "data waiting" bits that only requires 4 cycles to read (assuming nobody has futzed with the DDR on VIA1)



Yes. if it was me, I would use one of the VIA(#?) PortB pins freed up -- by not putting PS2 KBD/Mouse on the VIA -- as a VIA input /ACK with a pull up resister to +VCC (so on power up it will read as 1), another as an VIA output /ALERT, and two more VIA outputs as MODE1/MODE0 to select one of four modes (IDLE, Data Write, Data Read, Address Write), and connect 8 GPIO to the data bus, with the MCU setting them up as Inputs (including when Idle) or Outputs as appropriate. That's 12 GPIO, 4 more for the two PS2 ports is 16, and the ATX power supply pins seems to me{*FN} like it would fit in a 22 GPIO model of ATTiny.

But also, it it was me, I'd just use the I2C that they in any event need for the RTC ... it's a computer talking with People over the PS2 ports, so they really AREN'T time critical the way that talking to a video card etc. would be. That would free up more pins for the User Port, allowing for a parallel port AND a half-bit banged SPI with the User Port VIA Serial Shift Register ... or a partially bit banged serial port with hardware flow control if taking the PS2 off of the VIA frees up the system VIA serial shift register so both serial shift registers are available for really flexible serial oriented user port #2.

__________________

{*Footnote: But what in the Sam Hill do I know? This is all hardware, and to the extent that I'm anything, I'm a software guy.}

Fabio
Posts: 41
Joined: Sat Aug 21, 2021 12:13 pm

PS/2 Mouse working with ATTINY and I2C

Post by Fabio »


@Wavicle I'm fullly convinced with the I2C route  maybe we can add 2 legs to the microcontroller as keyb data\ mouse data available:

to calculate the legs needed we should add (correct me if i'm wrong)

3 legs for the power supply control

2 for keyboard ps\2

2for mouse ps\2

2 for I2C comunication

2 for optional keyb data / mouse data waiting

1 for power status  led

 I remember that the micro used is the attiny 861 : it has 16 pins GPIO with a total consumed of 12 : if 12 pins are all we need then the attiny 84 would be enough

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

PS/2 Mouse working with ATTINY and I2C

Post by Wavicle »



On 8/15/2022 at 9:53 AM, Fabio said:




@Wavicle I'm fullly convinced with the I2C route  maybe we can add 2 legs to the microcontroller as keyb data\ mouse data available:



to calculate the legs needed we should add (correct me if i'm wrong)



3 legs for the power supply control



2 for keyboard ps\2



2for mouse ps\2



2 for I2C comunication



2 for optional keyb data / mouse data waiting



1 for power status  led



 I remember that the micro used is the attiny 861 : it has 16 pins GPIO with a total consumed of 12 : if 12 pins are all we need then the attiny 84 would be enough



I created a diagram of the current pin commitment on the 861 in the SMC source code here: x16-smc/smc_pins.h at main · commanderx16/x16-smc (github.com).

The next step up from ATTINY861 is pretty much the ATmega328p (the Arduino microcontroller). I don't particularly like the ATmega328p for aesthetic reasons, but Kevin seems ready to make the switch. If I can plan strategy with him prior to his doing proto 4 design, I could pitch the idea of placing footprints on the PCB for both. Not sure how that will go over though - Kevin and David both want the HW finalized post haste; nobody wants there to be a proto 5.

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

PS/2 Mouse working with ATTINY and I2C

Post by BruceMcF »



On 8/15/2022 at 12:53 PM, Fabio said:




@Wavicle I'm fullly convinced with the I2C route  maybe we can add 2 legs to the microcontroller as keyb data\ mouse data available:



to calculate the legs needed we should add (correct me if i'm wrong)



3 legs for the power supply control



2 for keyboard ps\2



2for mouse ps\2



2 for I2C comunication



2 for optional keyb data / mouse data waiting



1 for power status  led



 I remember that the micro used is the attiny 861 : it has 16 pins GPIO with a total consumed of 12 : if 12 pins are all we need then the attiny 84 would be enough



Yes, the 24 GPIO ATTiny88 at, eg, Mouser, is not in stock & with a long lead time. Also, is the timing given for ATTiny parts the speed after any PLL clock doubling? I guess that might be another issue, as the ATTiny88 is a listed as a 12MHz part, rather than a 16MHz part.

But if 16 GPIO covers the needs with 4 to spare, that seems a good fit.

Fabio
Posts: 41
Joined: Sat Aug 21, 2021 12:13 pm

PS/2 Mouse working with ATTINY and I2C

Post by Fabio »


@Wavicle posted the real pinout: it looks like that only PB7 on the SMC is free: for this reason the data waiting lines should be combined.

I'm not sure if the microcontroller should be further expanded (besides issues of supply chain)

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

PS/2 Mouse working with ATTINY and I2C

Post by BruceMcF »



On 8/15/2022 at 7:39 PM, Fabio said:




@Wavicle posted the real pinout: it looks like that only PB7 on the SMC is free: for this reason the data waiting lines should be combined.



I'm not sure if the microcontroller should be further expanded (besides issues of supply chain)



Yes...  the PS control includes both button input and interrupt/reset lines output,  so that is six pins,  not three.

I am not sure how noticeable a benefit it would be, but for a system polling mouse and keyboard in alternate frames, a data waiting pin does indeed allow skipping the I2C channel access when there is nothing to read. It would be simplest going to one of the system VIA PortB pins freed up by putting the PS2 on the MCU.

Post Reply