Sending a Character

Sending a Character

To send a character, we use the bottom two device registers, the XCSR and the XBUF. The XCSR (transmitter control and status register) is laid out as follows:

Polled Transmission

If we are using polling (rather than interrupt-driven I/O) then the CPU must loop continually checking whether the device is ready to send a character. The way we do this is to constantly check the T bit in the XCSR. If the SLU is able to send a character, this bit will be 1. If it is not ready, it will be 0. Once it is found to be 1, we simply write the output character into the XBUF. This will start the SLU sending our character. The T bit will become 1 again when the character has been sent.

Interrupt-Driven Transmission

To tell the SLU we want to use interrupt-driven transmission, we must set the I bit in the XCSR. With this bit set, the transmitter knows to interrupt the CPU as soon as it becomes available to send a character (which is probably right away if it wasn't already sending when we set the bit to 1). Once the bit is set, we need not set it again for each transmission - it will remain set until we reset it.

When the SLU interrupts the CPU saying it is able to send a character, we simply (as before with polling) write a character into the XBUF. This will start the transmitter sending. It will interrupt again when it is done sending that character.

1