UART: Difference between revisions

From WSdev Wiki
Jump to navigationJump to search
m (Register formatting.)
(Splits Serial Data into Serial Receive Data and Serial Transmit Data)
 
(One intermediate revision by the same user not shown)
Line 6: Line 6:
This allows for an effective maximum transfer speed of 960 or 3840 bytes per second, respectively.
This allows for an effective maximum transfer speed of 960 or 3840 bytes per second, respectively.


The hardware also features a one-byte transmit and receive buffer, which allows for a slight delay in code when handling data to/from the console.
The hardware also features one-byte transmit and receive buffers, which allow for a slight delay in code when handling data to/from the console.


== Interrupts ==
== Interrupts ==
Line 12: Line 12:
The UART features two interrupts:
The UART features two interrupts:


* UART Send Ready - constantly active while the transmit buffer is empty (Serial Control bit 2),
* UART Send Ready - constantly active while the transmit buffer is empty (Serial Status bit 2),
* UART Receive Ready - constantly active while the receive buffer contains a byte (Serial Control bit 0).
* UART Receive Ready - constantly active while the receive buffer contains a byte (Serial Status bit 0).


== I/O ports ==
== I/O ports ==


=== Serial Data ===
{{Anchor|Serial Receive Data}}
=== Serial Receive Data ($B1 read) ===


<pre>
<pre>
Line 24: Line 25:
dddd dddd
dddd dddd
|||| ||||
|||| ||||
++++-++++- Read a byte from the transmit buffer;
++++-++++- Receive buffer value
          Write a byte into the receive buffer.
</pre>
</pre>


=== Serial Control ===
{{Anchor|Serial Transmit Data}}
=== Serial Transmit Data ($B1 write) ===


<pre>
<pre>
7  bit  0
7  bit  0
---- ----
---- ----
ebO. .tor
dddd dddd
|||||
|||| ||||
||||+- 1 if the receive buffer contains a byte
++++-++++- Transmit buffer value
|||+-- 1 on overrun (receive buffer overflow)
</pre>
||+--- 1 if the transmit buffer is empty (can transmit another byte)
 
{{Anchor|Serial Status}}
=== Serial Status ($B3 read) ===
 
<pre>
7  bit  0
---- ----
eb.. .tor
||   |||
||   ||+- 1 if the receive buffer contains a byte
||   |+-- 1 on overrun (receive buffer overflow)
||   +--- 1 if the transmit buffer is empty (can transmit another byte)
|+-------- UART speed: 0 = 9600 bps, 1 = 38400 bps
+--------- UART enable: 0 = off, 1 = on
</pre>
 
{{Anchor|Serial Control}}
=== Serial Control ($B3 write) ===
 
<pre>
7  bit  0
---- ----
ebO. ....
|||
||+------- Write 1 to reset overrun
||+------- Write 1 to reset overrun
|+-------- UART speed: 0 = 9600 bps, 1 = 38400 bps
|+-------- UART speed: 0 = 9600 bps, 1 = 38400 bps
+--------- UART enable: 0 = off, 1 = on
+--------- UART enable: 0 = off, 1 = on
</pre>
</pre>

Latest revision as of 12:05, 22 August 2023

The WonderSwan's EXT port features an UART operating with the following configuration:

  • 9,600 or 38,400 bps (bauds per second),
  • 8N1 (8 data bits followed by 1 stop bit, no parity).

This allows for an effective maximum transfer speed of 960 or 3840 bytes per second, respectively.

The hardware also features one-byte transmit and receive buffers, which allow for a slight delay in code when handling data to/from the console.

Interrupts

The UART features two interrupts:

  • UART Send Ready - constantly active while the transmit buffer is empty (Serial Status bit 2),
  • UART Receive Ready - constantly active while the receive buffer contains a byte (Serial Status bit 0).

I/O ports

Serial Receive Data ($B1 read)

7  bit  0
---- ----
dddd dddd
|||| ||||
++++-++++- Receive buffer value

Serial Transmit Data ($B1 write)

7  bit  0
---- ----
dddd dddd
|||| ||||
++++-++++- Transmit buffer value

Serial Status ($B3 read)

7  bit  0
---- ----
eb.. .tor
||    |||
||    ||+- 1 if the receive buffer contains a byte
||    |+-- 1 on overrun (receive buffer overflow)
||    +--- 1 if the transmit buffer is empty (can transmit another byte)
|+-------- UART speed: 0 = 9600 bps, 1 = 38400 bps
+--------- UART enable: 0 = off, 1 = on

Serial Control ($B3 write)

7  bit  0
---- ----
ebO. ....
|||
||+------- Write 1 to reset overrun
|+-------- UART speed: 0 = 9600 bps, 1 = 38400 bps
+--------- UART enable: 0 = off, 1 = on