I have a stupid question about the dmg-01 serial port interface

Discussion of programming and development for the original Game Boy and Game Boy Color.
Post Reply
spaceharrier
Posts: 40
Joined: Wed Jan 19, 2022 9:52 am

I have a stupid question about the dmg-01 serial port interface

Post by spaceharrier »

I would like to be able to use some off-the-shelf SPI to RS45 transceivers to make extra long cables.

The transceivers require you to set one transceiver in master mode and one in slave, and I don't see any sort of slave select on the connector.

How do games usually arbitrate which is master and which is slave?
calima
Posts: 1745
Joined: Tue Oct 06, 2015 10:16 am

Re: I have a stupid question about the dmg-01 serial port interface

Post by calima »

Timing. Whoever happens to contact at the right time. The protocol can be seen in the official GB doc.
spaceharrier
Posts: 40
Joined: Wed Jan 19, 2022 9:52 am

Re: I have a stupid question about the dmg-01 serial port interface

Post by spaceharrier »

calima wrote: Tue Jun 06, 2023 10:40 pm Timing. Whoever happens to contact at the right time. The protocol can be seen in the official GB doc.
I see. It looks like I might need to design a small bus sniffer that checks for writes to the serial control register in order to arbitrate direction of the clock.
tepples
Posts: 22708
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: I have a stupid question about the dmg-01 serial port interface

Post by tepples »

ISSOtm wrote in gbdev Discord server: "I think the handshake is attempt to exchange as master, if it matched an expected value you are the master; otherwise, write that expected value into SB, and attempt to exchange as a slave (with timeout)"

A bus sniffer may help even if it doesn't provide quite as much useful information as it does on the NES for a couple reasons. One is that writes to registers and HRAM do not show up on the external bus. You could trace it by watching opcode fetches, but then a lot of I/O writes are done through [HL] and [$FF00+C], meaning your bus sniffer would also have to track the address values loaded into those registers.
spaceharrier
Posts: 40
Joined: Wed Jan 19, 2022 9:52 am

Re: I have a stupid question about the dmg-01 serial port interface

Post by spaceharrier »

Most differential transceivers with auto direction just use a 555 as a timeout when switching the direction.

I could try to use a micro to read the line states and implement something similar. Since the gameboy's SPI clock is only about 8 khz, even a slow micro running at a few mhz would be fast enough to arbitrate.
User avatar
Jarhmander
Formerly ~J-@D!~
Posts: 569
Joined: Sun Mar 12, 2006 12:36 am
Location: Rive nord de Montréal

Re: I have a stupid question about the dmg-01 serial port interface

Post by Jarhmander »

Fun anecdote: I once designed an embedded system with a SoC using RS485 to communicate with other sensors via Modbus, and ended up using a small PIC12F to switch the communication direction because it was cheaper (!) and I could change the timeout by reflashing the microcontroller with the SoC if I needed to.
((λ (x) (x x)) (λ (x) (x x)))
Post Reply