<!-- PDF page 245 -->

### Communication

#### Port 4155 (103Bh) – I²C SCL

<table>
<thead>
<tr><th rowspan="2">Group Name</th><th rowspan="2">R</th><th rowspan="2">W</th><th colspan="8">Data Bits</th><th rowspan="2">Description</th></tr>
<tr><th>7</th><th>6</th><th>5</th><th>4</th><th>3</th><th>2</th><th>1</th><th>0</th></tr>
</thead>
<tbody>
<tr><td>I²C Clock Line Control</td><td>■</td><td>■</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>•</td><td>State of the Clock Line</td></tr>
</tbody>
</table>

#### Port 4411 (113Bh) – I²C SDA

<table>
<thead>
<tr><th rowspan="2">Group Name</th><th rowspan="2">R</th><th rowspan="2">W</th><th colspan="8">Data Bits</th><th rowspan="2">Description</th></tr>
<tr><th>7</th><th>6</th><th>5</th><th>4</th><th>3</th><th>2</th><th>1</th><th>0</th></tr>
</thead>
<tbody>
<tr><td>I²C Data Line Control</td><td>■</td><td>■</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>•</td><td>State of the Data Line</td></tr>
</tbody>
</table>

#### Port 231 (E7h) – SPI CS\*

<table>
<thead>
<tr><th rowspan="2">Group Name</th><th rowspan="2">R</th><th rowspan="2">W</th><th colspan="8">Data Bits</th><th rowspan="2">Description</th></tr>
<tr><th>7</th><th>6</th><th>5</th><th>4</th><th>3</th><th>2</th><th>1</th><th>0</th></tr>
</thead>
<tbody>
<tr><td>SD Card 0 Select</td><td>■</td><td>■</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>•</td><td>Select SD Card 0</td></tr>
<tr><td>SD Card 1 Select</td><td>■</td><td>■</td><td></td><td></td><td></td><td></td><td></td><td></td><td>•</td><td></td><td>Select SD Card 1</td></tr>
<tr><td>PI SPI 0 Select¹</td><td>■</td><td>■</td><td></td><td></td><td></td><td></td><td></td><td>•</td><td></td><td></td><td>Select Pi SPI 0 on the GPIO pins</td></tr>
<tr><td>PI SPI 1 Select¹</td><td>■</td><td>■</td><td></td><td></td><td></td><td></td><td>•</td><td></td><td></td><td></td><td>Select Pi SPI 1 on the GPIO pins</td></tr>
<tr><td>FPGA Flash Select</td><td>■</td><td>■</td><td>•</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>Select the FPGA Flash ROM (Internal Use Only)</td></tr>
</tbody>
</table>

\* The SPI port's data lines are active low (**0** to select).\
¹ Pi GPIO must be configured for SPI. See **NR 160 (A0h)**\
Five devices are connected to the SPI interface. The ZX Spectrum Next must be\
SPI master.\
Only one of **D0** through **D3** can be **0** at one time. If not, the result will be no device selected

#### Port 235 (EBh) – SPI Data

<table>
<thead>
<tr><th rowspan="2">Group Name</th><th rowspan="2">R</th><th rowspan="2">W</th><th colspan="8">Data Bits</th><th rowspan="2">Description</th></tr>
<tr><th>7</th><th>6</th><th>5</th><th>4</th><th>3</th><th>2</th><th>1</th><th>0</th></tr>
</thead>
<tbody>
<tr><td>SPI Data</td><td>■</td><td>■</td><td>•</td><td>•</td><td>•</td><td>•</td><td>•</td><td>•</td><td>•</td><td>•</td><td>Read/Write data to the selected SPI device</td></tr>
</tbody>
</table>

#### Port 5435 (153Bh) – UART Control

<table>
<thead>
<tr><th rowspan="2">Group Name</th><th rowspan="2">R</th><th rowspan="2">W</th><th colspan="8">Data Bits</th><th rowspan="2">Description</th></tr>
<tr><th>7</th><th>6</th><th>5</th><th>4</th><th>3</th><th>2</th><th>1</th><th>0</th></tr>
</thead>
<tbody>
<tr><td>Prescalar MSB Value</td><td>■</td><td>■</td><td></td><td></td><td></td><td></td><td></td><td>•</td><td>•</td><td>•</td><td>Baud rate prescalar MSB</td></tr>
<tr><td>Prescalar MSB Write Enable</td><td>■</td><td>■</td><td></td><td></td><td></td><td>•</td><td></td><td></td><td></td><td></td><td>D2:D0 write enable</td></tr>
<tr><td rowspan="2">UART Select**</td><td rowspan="2">■</td><td rowspan="2">■</td><td></td><td>0</td><td></td><td></td><td></td><td></td><td></td><td></td><td>ESP UART Select</td></tr>
<tr><td></td><td>1</td><td></td><td></td><td></td><td></td><td></td><td></td><td>Pi0 UART Select*</td></tr>
</tbody>
</table>

\* Pi GPIO must be configured for UART. See **NR 160 (A0h)**\
\*\* Either UART can be redirected to the joystick ports, see **NR 11 (0Bh)**

#### Port 4923 (133Bh) – UART Transmit

<table>
<thead>
<tr><th rowspan="2">Group Name</th><th rowspan="2">R</th><th rowspan="2">W</th><th colspan="8">Data Bits</th><th rowspan="2">Description</th></tr>
<tr><th>7</th><th>6</th><th>5</th><th>4</th><th>3</th><th>2</th><th>1</th><th>0</th></tr>
</thead>
<tbody>
<tr><td>Read buffer status flag</td><td>■</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>•</td><td>Set if read buffer contains received bytes</td></tr>
<tr><td>Transmitter busy flag</td><td>■</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>•</td><td></td><td>Set if the transmit buffer is full</td></tr>
<tr><td>Read buffer full flag</td><td>■</td><td></td><td></td><td></td><td></td><td></td><td></td><td>•</td><td></td><td></td><td>Set if the read buffer overflowed*</td></tr>
<tr><td>Read buffer near-full flag</td><td>■</td><td></td><td></td><td></td><td></td><td></td><td>•</td><td></td><td></td><td></td><td>Set if the read buffer in near-full (¾)</td></tr>
<tr><td>Transmit buffer empty flag</td><td>■</td><td></td><td></td><td></td><td></td><td>•</td><td></td><td></td><td></td><td></td><td>Set if the transmit buffer is empty</td></tr>
<tr><td>Receive data after error flag</td><td>■</td><td></td><td></td><td></td><td>•</td><td></td><td></td><td></td><td></td><td></td><td>Set if the next Rx byte was recv'd after an error**</td></tr>
<tr><td>Receive framing error flag</td><td>■</td><td></td><td></td><td>•</td><td></td><td></td><td></td><td></td><td></td><td></td><td>Set if the Rx experienced a framing error***</td></tr>
<tr><td>Receive in break flag</td><td>■</td><td></td><td>•</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>Set if the Rx is in a break condition****</td></tr>
<tr><td>Data Transmit</td><td></td><td>■</td><td>•</td><td>•</td><td>•</td><td>•</td><td>•</td><td>•</td><td>•</td><td>•</td><td>Send a byte to the connected device</td></tr>
</tbody>
</table>

\* Clears on read\
\*\* Framing or overflow\
\*\*\* Clears on read; includes parity and stop bit errors\
\*\*\*\* External device has held Tx=0 for at least 20 bit periods\
Both UARTs have a 64-byte transmit buffer

#### Port 5179 (143Bh) – UART Receive

<table>
<thead>
<tr><th rowspan="2">Group Name</th><th rowspan="2">R</th><th rowspan="2">W</th><th colspan="8">Data Bits</th><th rowspan="2">Description</th></tr>
<tr><th>7</th><th>6</th><th>5</th><th>4</th><th>3</th><th>2</th><th>1</th><th>0</th></tr>
</thead>
<tbody>
<tr><td>Data Receive</td><td>■</td><td></td><td>•</td><td>•</td><td>•</td><td>•</td><td>•</td><td>•</td><td>•</td><td>•</td><td>Reads a byte from the receive buffer*</td></tr>
<tr><td rowspan="2">Prescalar LSB Value¹</td><td rowspan="2"></td><td rowspan="2">■</td><td>0</td><td>•</td><td>•</td><td>•</td><td>•</td><td>•</td><td>•</td><td>•</td><td>Lower 7 bits of the 14-bit prescalar value LSB</td></tr>
<tr><td>1</td><td>•</td><td>•</td><td>•</td><td>•</td><td>•</td><td>•</td><td>•</td><td>Upper 7 bits of the 14-bit prescalar value LSB</td></tr>
</tbody>
</table>

\* If the buffer is empty **0** is returned.\
¹ The UART's baud rate is determined by the prescalar according to this formula:\
Prescalar = **F<sub>sys</sub> / baudrate**; **F<sub>sys</sub>** = System Clock from **NR 17 (11h)**.\
Example: If the system is on a Digital display, **NR 17 (11h)** indicates that **F<sub>sys</sub>** = **27000000**.\
The prescalar for a baud rate of **115200** is **27000000** / **115200** = **234**\
Both UARTs have a 512-byte receive buffer

#### Port 5691 (163Bh) – UART Frame

<table>
<thead>
<tr><th rowspan="2">Group Name</th><th rowspan="2">R</th><th rowspan="2">W</th><th colspan="8">Data Bits</th><th rowspan="2">Description</th></tr>
<tr><th>7</th><th>6</th><th>5</th><th>4</th><th>3</th><th>2</th><th>1</th><th>0</th></tr>
</thead>
<tbody>
<tr><td>Stop bits control</td><td>■</td><td>■</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>•</td><td>Set if 2 stop bits, clear for 1 stop bit</td></tr>
<tr><td>Parity type control</td><td>■</td><td>■</td><td></td><td></td><td></td><td></td><td></td><td></td><td>•</td><td></td><td>Set if odd parity, clear for even parity</td></tr>
<tr><td>Parity check control</td><td>■</td><td>■</td><td></td><td></td><td></td><td></td><td></td><td>•</td><td></td><td></td><td>Set to enable parity check</td></tr>
<tr><td rowspan="4">Frame size (bits) control</td><td rowspan="4">■</td><td rowspan="4">■</td><td></td><td></td><td></td><td>0</td><td>0</td><td></td><td></td><td></td><td>5 bits</td></tr>
<tr><td></td><td></td><td></td><td>0</td><td>1</td><td></td><td></td><td></td><td>6 bits</td></tr>
<tr><td></td><td></td><td></td><td>1</td><td>0</td><td></td><td></td><td></td><td>7 bits</td></tr>
<tr><td></td><td></td><td></td><td>1</td><td>1</td><td></td><td></td><td></td><td>8 bits</td></tr>
<tr><td>Hardware Flow control</td><td>■</td><td>■</td><td></td><td></td><td>•</td><td></td><td></td><td></td><td></td><td></td><td>Set enables hardware flow control*</td></tr>
<tr><td>Transmit break control**</td><td>■</td><td>■</td><td></td><td>•</td><td></td><td></td><td></td><td></td><td></td><td></td><td>Send a byte to the connected device</td></tr>
<tr><td>Reset Rx and Tx Control</td><td>■</td><td>■</td><td>•</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>Set to immediately reset Rx, Tx and empty FIFOs</td></tr>
</tbody>
</table>

\* Honoured only on an Issue 4 ESP module, no effect on Issue 2 boards. In joystick I/O mode only CTS is available\
\*\* Asserts break on Tx when Tx becomes idle

### Sprites

#### Port 12347 (303Bh) – Sprite Slot Select\*¹

<table>
<thead>
<tr><th rowspan="2">Group Name</th><th rowspan="2">R</th><th rowspan="2">W</th><th colspan="8">Data Bits</th><th rowspan="2">Description</th></tr>
<tr><th>7</th><th>6</th><th>5</th><th>4</th><th>3</th><th>2</th><th>1</th><th>0</th></tr>
</thead>
<tbody>
<tr><td>Sprite Collision flag</td><td>■</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>•</td><td>Set if any two displayed sprites collide on screen</td></tr>
<tr><td>Max. No. of Sprites per line flag</td><td>■</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>•</td><td></td><td>Set if maximum no. of sprites per line exceeded</td></tr>
<tr><td>Current Pattern Index Select²</td><td></td><td>■</td><td>•</td><td></td><td>•</td><td>•</td><td>•</td><td>•</td><td>•</td><td>•</td><td>Sets Current Pattern Index</td></tr>
<tr><td>Current Sprite Index Select¹</td><td></td><td>■</td><td></td><td>•</td><td>•</td><td>•</td><td>•</td><td>•</td><td>•</td><td>•</td><td>Sets Current Sprite (0 - 127)</td></tr>
</tbody>
</table>

\* Reading the port clears all flags\
¹ The current sprite and pattern index are separate quantities internally\
² The pattern index is 6-bit in bits **D0** through **D5** and selects pattern **0 - 63** in the pattern RAM. Each pattern is **256** bytes long. **D7** can be used to offset **128** bytes halfway through the pattern; this accommodates 4-bit sprites whose patterns are **128** bytes in size.

#### Port (57h) – Sprite Attributes

<table>
<thead>
<tr><th rowspan="2">Group Name</th><th rowspan="2">R</th><th rowspan="2">W</th><th colspan="8">Data Bits</th><th rowspan="2">Description</th></tr>
<tr><th>7</th><th>6</th><th>5</th><th>4</th><th>3</th><th>2</th><th>1</th><th>0</th></tr>
</thead>
<tbody>
<tr><td>Attribute Data</td><td></td><td>■</td><td>•</td><td>•</td><td>•</td><td>•</td><td>•</td><td>•</td><td>•</td><td>•</td><td>Attribute Data</td></tr>
</tbody>
</table>

Writes the current sprite's attributes. Each sprite has either 4 or 5 attributes and after all are written, the current sprite pointer is advanced to the next sprite. The pointer wraps from **127** to **0**.

#### Port (5Bh) – Sprite Pattern

<table>
<thead>
<tr><th rowspan="2">Group Name</th><th rowspan="2">R</th><th rowspan="2">W</th><th colspan="8">Data Bits</th><th rowspan="2">Description</th></tr>
<tr><th>7</th><th>6</th><th>5</th><th>4</th><th>3</th><th>2</th><th>1</th><th>0</th></tr>
</thead>
<tbody>
<tr><td>Pattern Data</td><td></td><td>■</td><td>•</td><td>•</td><td>•</td><td>•</td><td>•</td><td>•</td><td>•</td><td>•</td><td>Pattern Data</td></tr>
</tbody>
</table>

Writes a byte to the current pattern address and advances the current address by one. The pattern address is changed by writing the pattern index in port **12347 (303Bh)**. A pattern index indicates the start of a 256-byte range of data used to define an 8-bit sprite pattern or a 128-byte range of data use to define a 4-bit sprite pattern.

### DMA

#### Port 107 (6Bh) / 11 (0Bh) – zxnDMA / Z80DMA

<table>
<thead>
<tr><th rowspan="2">Group Name</th><th rowspan="2">R</th><th rowspan="2">W</th><th colspan="8">Data Bits</th><th rowspan="2">Description</th></tr>
<tr><th>7</th><th>6</th><th>5</th><th>4</th><th>3</th><th>2</th><th>1</th><th>0</th></tr>
</thead>
<tbody>
<tr><td>DMA Control</td><td>■</td><td>■</td><td>•</td><td>•</td><td>•</td><td>•</td><td>•</td><td>•</td><td>•</td><td>•</td><td>DMA command value</td></tr>
</tbody>
</table>

The zxnDMA implements a subset of the Zilog Z80DMA architecture while adding a burst mode primarily used to play digital music. Accessing the DMA via port **11 (0Bh)** rather than **107 (6Bh)** selects the DMA compatibility mode (Z80DMA). **See https://www.specnext.com/the-zxndma/**

### Layer 2 Graphics

#### Port 4667 (123Bh) – Layer 2 Control

<table>
<thead>
<tr><th rowspan="2">Group Name</th><th rowspan="2">R</th><th rowspan="2">W</th><th colspan="8">Data Bits</th><th rowspan="2">Description</th></tr>
<tr><th>7</th><th>6</th><th>5</th><th>4</th><th>3</th><th>2</th><th>1</th><th>0</th></tr>
</thead>
<tbody>
<tr><td>Memory Write Mapping Control</td><td>■</td><td>■</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>•</td><td>Enable Mapping for Memory Writes</td></tr>
<tr><td>Layer 2 Display Control</td><td>■</td><td>■</td><td></td><td></td><td></td><td></td><td></td><td></td><td>•</td><td></td><td>Enable Layer 2 Display</td></tr>
<tr><td>Memory Read Mapping Control</td><td>■</td><td>■</td><td></td><td></td><td></td><td></td><td></td><td>•</td><td></td><td></td><td>Enable Mapping for Memory Reads</td></tr>
<tr><td rowspan="2">Active/Shadow Control</td><td rowspan="2">■</td><td rowspan="2">■</td><td></td><td></td><td></td><td></td><td>0</td><td></td><td></td><td></td><td>Map Active Layer 2¹</td></tr>
<tr><td></td><td></td><td></td><td></td><td>1</td><td></td><td></td><td></td><td>Map Shadow Layer 2²</td></tr>
<tr><td>Reserved</td><td></td><td>■</td><td></td><td></td><td>0</td><td>0</td><td></td><td></td><td></td><td></td><td>Reserved, Must be 0</td></tr>
<tr><td rowspan="4">Layer 2 Map Type Select</td><td rowspan="4">■</td><td rowspan="4">■</td><td>0</td><td>0</td><td></td><td></td><td></td><td></td><td></td><td></td><td>First 16K of Layer 2 in the bottom 16K</td></tr>
<tr><td>0</td><td>1</td><td></td><td></td><td></td><td></td><td></td><td></td><td>Second 16K of Layer 2 in the bottom 16K</td></tr>
<tr><td>1</td><td>0</td><td></td><td></td><td></td><td></td><td></td><td></td><td>Third 16K of Layer 2 in the bottom 16K</td></tr>
<tr><td>1</td><td>1</td><td></td><td></td><td></td><td></td><td></td><td></td><td>First 48K of Layer 2 in the bottom 48K</td></tr>
</tbody>
</table>

\* Memory pointed at by **NR 18 (12h)** or **NR 19 (13 h)** can be mapped into the lower 16K or 48K if Layer 2 memory mapping is enabled in **D2** and/or **D0**. This mechanism is separate from MMU and will overlay the paging state set by MMU but only if the memory access type matches the enable condition (Read-only, Write-only)\
¹ See **NR 18 (12h)**\
² See **NR 19 (13h)**

### Memory Mapping Modes

The current memory mapping is maintained by the hardware in eight MMUs with each MMU, numbered MMU0 – MMU7, holding an 8K page number currently mapped into corresponding eight 8K slots of the Z80's 64K memory space. The individual MMUs can be programmed via **NextREGs 80 – 87 (50h – 57h)**.

The traditional banking mechanism used in various Spectrum models is via ports 7FFDh, DFFDh, 1FFDh and EFF7h with writes to these ports making changes to one or more MMUs in the hardware.

The 128K Spectrum used port 7FFDh, the +3 used 7FFDh and 1FFDh and the ZX Spectrum Next extends that with port DFFDh to increase the range of 16K banks that can be paged into the top 16K.

Russian ZX Spectrum models extended the banking in various ways to support up to 1MB of memory. The ZX Spectrum Next, also supports some of these banking methods which modify the behaviour of ports **7FFDh** and **DFFDh**. The current memory mapping mode is held in **NextREG 143 (8Fh)** and can be one of standard ZX Spectrum, Pentagon 512K or Pentagon 1024K. The ZX Spectrum Next normally operates in standard Spectrum mode.

In standard spectrum mode, ports **7FFDh** and **1FFDh** operate as on the +3 and as described above.

Port **DFFDh** adds four bits to extend the three bit bank number in bits **D2:D0** of port **7FFDh** so that the full range of the ZX Spectrum

