DIY MSX(2+) keyboard issues, help needed

Página 1/2
| 2

Por lintweaker

Champion (474)

imagem de lintweaker

18-07-2018, 17:23

My DIY MSX(2+) is coming along nicely. I am currently building a PS/2 to MSX parallel keyboard converter using a microcontroller.
The keyboard converter works fine for most part but I do have some issues with a few keys like 1-7 and their
SHIFT counterparts.

E.g. When I press '1' get '41' and with '3' I get '63'. The SHIFT versions show '$1' and '^3' respectively.
Any idea what could be the cause of this and/or how to fix it? It seems all the trouble keys belong to row 0.

As background:
a interrupt is generated to the microcontroller whenever there is a read to IO port 0a9h from the MSX. The microcontroller then reads the current selected keyboard column from the MSX 8255 portC (PC0-3) and returns a 8-bit value to the MSX via 8255 PortB (PB0-7).
MSX 8255 PortB PB0-PB7 are used to sent a 8-bit row value of pressed keys back

Entrar ou registrar-se para comentar

Por meits

Scribe (6571)

imagem de meits

18-07-2018, 17:35

I remember getting double characters on some keys on my Sony HB-F1XDJ MSX2+ computer when a great deal of the capacitors and even some resistors had rotten off of the mainboard. The doctor reported about it here.
What happened here also applies on other Sony models.

Por lintweaker

Champion (474)

imagem de lintweaker

18-07-2018, 19:30

Hmm, okay. Not sure if these are similar issues. To be sure I'll check the signals with scope.

Por Danjovic

Champion (344)

imagem de Danjovic

30-07-2018, 05:00

Timing is critical on such kind of adapter as the microcontroller has to respond wihin hundreths of nanoseconds.
You can turn the game by generating a wait signal and then take your time to respond to PPI the correct data

Por Danjovic

Champion (344)

imagem de Danjovic

30-07-2018, 11:24

I have made some considerations about the timing involved on the reading of the keyboard on a typical MSX machine [1]. In numbers you have less than 4 us from detecting the writing of the PPI port until the data is ready for Z80 to read it.

If you consider that is possible to perform continous reading on the same row and decide to decode the Z80 reading you have only 680ns from detecting the reading until the data is ready.

On the ZX Spectrum [2] this is even worse as the keyboard reading is performed on the same IN instuction which means to decode the row and get the data ready in 280ns! Nevertheless it is possible to implement an external keyboard adapter using WAIT signal [3].

The WAIT line in Z80 was designed with the purpose of allowing 'slower' devices to be connected to the bus, and a decoded based on the interrupts of a microcontroller is such the case.

A side effect of using WAIT is that you have an overhead of few microseconds, which is nothing if you consider that MSX scan the keyboard 1 out of 3 vertical sync interrupts (50milliseconds on a NTSC machine) running BASIC. During games the typical scan rate is once at each 16.7ms (20ms for 50Hz machines).

[1] http://hotbit.blogspot.com/2012/02/adaptador-para-teclado-ps...
[2] http://danjovic.blogspot.com/2014/06/temporizacao-da-leitura...
[3] http://danjovic.blogspot.com/2014/06/

Por lintweaker

Champion (474)

imagem de lintweaker

30-07-2018, 20:44

Thanks guys, excellent reads (via google translate).
I made some progress, most keys are working now (currently without the need to use Z80 /WAIT). Once finished I'll see if the trickery to get it working makes any sense (issues with row 0 keys).

BTW I now generate an interrupt to the microcontroller when the PPI selects the keyboard row instead of when the Z80 want to read the column data back.

Por Matthew Splett

Supporter (14)

imagem de Matthew Splett

31-07-2018, 18:53

Your last BTW, sounds like a good approach.

I implemented USB to TI-99/4A matrix keyboard, and had similar symptoms initially, using a separate interrupt handler for each 'column' on the keyboard matrix. I solved it by using one common handler, that responded to all the columns, and read the column state first thing to decide how to respond. As the TI may have moved on before the interrupt handler was invoked. So even if you miss the column scan it was looking for, you'll most likely get it next time around. I used a teensy, and usb host device. Most of the teensy's cpu time was eaten up by the USB code.

https://github.com/jedimatt42/TI-99-usb-keys

There was another project that did PS/2 to the 4A's matrix, and he just polled the columns in a loop, instead of using interrupts.

http://www.harmlesslion.com/cgi-bin/onesoft.cgi?60

The code is there if that helps... The concepts are applicable.

GR8BIT also has done PS/2 to MSX and there is some info available on Eugeny's website, plus his open source microcode for a PIC:

http://www.gr8bit.ru/gr8bit-knowledge-base.html

-M@

Por lintweaker

Champion (474)

imagem de lintweaker

31-07-2018, 20:46

ah, more input Smile Thanks.

My current implementation is quite usable in BASIC now, but a test in a simple game (Comic Bakery) reveals it does not work there. The game only scans rows 7 and 8.
When I move to a loop based design I can control the game but the keyboard is horrible in BASIC.
So lots more work to do...

Por Danjovic

Champion (344)

imagem de Danjovic

02-08-2018, 00:54

I have wrote a program for testing keyboard emulators named Keyler.

It reads the row 0 consecutively with interrupts disabled and that is the worst case a keyboard emulator can be tested against. On a real keyboard it prints a hashtag (#) everytime a key from 0-7 change its state.

;
;   Keyler - Keyboard emulator tester for MSX - Danjovic 2014
;
org 0a000h
CHPUT: EQU 00A2H
START:
       ; CLS
       ld A,12
       call CHPUT
REPEAT:
       di
       in A,(0AAh)
       and 0F0h
       out (0AAh),A  ; select row 0
       in A,(0A9h)   ; read port B
       ld C,A
LOOP:
       in A,(0A9h)   ; read port B, but does not change state of port C
       cp C
       jr z,LOOP    ; repeat until value changes
       ld a,'#'
       call CHPUT
       jr REPEAT

On RUMSX it works as expected but in WebMSX it does not work. Haven' t tested other emulators, though. DSK and BIN versions available on the webpage.

Por lintweaker

Champion (474)

imagem de lintweaker

06-10-2018, 16:19

Just finished rev2 of my board which now includes a PS/2 to MSX keyboard converter....hope I did not make (too much) mistakes....quite a big board...

Por zett

Hero (608)

imagem de zett

02-02-2020, 19:49

lintweaker wrote:

Just finished rev2 of my board which now includes a PS/2 to MSX keyboard converter....hope I did not make (too much) mistakes....quite a big board...

Realy great in real life to see this board. nice done inc vdp card and psg card

Página 1/2
| 2