Microprocessors Lecture 11

Characters and Strings

Successful man-machine interaction requires the use of a common set of codes to convert between the internal representations in the microprocessor (binary) and the form that humans can understand (characters).

How are characters represented in a microprocessor system?

The convention below is used which allows printable and non-printing characters to be assigned a universally-agreed binary value. This is called the ASCII Character Set (American Standard Code for Information Interchange).

-------- Most significant three bits ----------
H
E
X
B
I
N
0
000
1
001
2
010
3
011
4
100
5
101
6
110
7
111
HEX
BIN
00000NULDLESP0@P`p
10001SOHDC1!1AQaq
20010STXDC2"2BRbr
30011ETXDC3#3CScs
40100EOTDC4$4DTdt
50101ENGNAK%5EUeu
60110ACKSYN&6FVfv
70111BELETB'7GWgw
81000BSCAN(8HXhx
91001HTEM)9IYiy
A1010LFSUB*:JZjz
B1011VTESC+;K[k{
C1100FFFS,<L\l|
D1101CRGS-=M]m}
E1110SORS.>N^n~
F1111SIVS/?O<-oDEL
Notes:

Control Characters

There are a number of non-printing (or 'control') characters in the ASCII table.

These are generated from the keyboard by holding down the CTRL key whilst hitting a letter key. An ASCII code which is $40 less than the upper-case character is generated.

Control codes may be used for any purpose, but in the interests of standardisation, the majority have a defined usage, for example:

	$0A	line feed (LF)		= CTRL-J
	$0D	carriage return (CR)	= CTRL-M
	$08	backspace (BS)		= CTRL-H
	$09	horizontal tab (HT)	= CTRL-I
Such representations of characters are used within a microprocessor system. A standard character set is especially important when transferring data between systems.

Transmission of Data

To transfer bytes of data between systems there are two types of interface, parallel and serial. Clearly, parallel interfaces are capable of higher transfer rates since 8 bits are transferred at once. However, it is not always possible to arrange to transfer data in parallel form and there can be problems with this type of interface when long-distance transfers are required.

Parallel interfaces

One example of a parallel interface is a PIA port, with handshaking controlling the transfer. Bi-directional transfers are possible using a single port, but a protocol must be used to change the direction of data transfer.

Parallel data transfers are commonly used for printers. Here, fast data transfer is possible as the distance from computer to printer is normally short. The 'Centronics' interface is one example of a parallel port.

With long lines and (or) high data rates, parallel interfaces run into problems with data skew or differential delay. At the remote end, the bits of data may no longer be aligned and it will be difficult to reconstruct the original data.

Another problem with long parallel lines is that of cross-talk where data from an adjacent line interferes with the data, so corrupting it.

For these reasons, parallel interfaces are normally only used for short distances.

A higher-performance parallel interface has been defined and is known as the General Purpose Interface Bus (GPIB) or HPIB (Hewlett-Packard Interface Bus, since HP originated the specification), or by its American Standard - IEEE 488.

Serial Interfaces

The most common serial interface is the RS232-C (or CCITT V.24). This standard defines the type of connectors used, the pin designations and the signal voltage levels. This is an asynchronous interface (although the specification does allow a synchronous mode).

Baud rate

One of RS232's parameters is the baud rate. A baud is one bit per second. If the time taken to transfer one serial bit is T, then the baud rate is 1/T.

Data Format

Since data is sent serially, we need to know when one 8-bit character ends and the next one starts. In RS232, this is achieved through the use of START and STOP bits. There may be more than one STOP bit to increase the gap between characters and to make the detection of the START bit more reliable.

A parity bit may also be used to detect single-bit errors.

The data may be sent as 8-bit ASCII or 7-bit ASCII and this format must be agreed in advance by transmitter and receiver.

e.g. 7-bit ASCII, 1 STOP bit

start 0 1 2 3 4 5 6 parity stop

In the format above, in order to transmit a 7-bit ASCII code, 10 bits are used in the frame.

Between characters, a continuous STOP bit is sent. This is a '1'. The START bit is always a '0' so a high-to-low transition defines the start of a character. The baud rate is agreed in advance, so that on receipt of a start bit, a half-bit delay is generated and each bit is then sampled at intervals of one bit (i.e. in the centre of each bit).

Framing Error

After all the data bits and the parity bit have been read, we expect to see a STOP bit next, when the final bit is sampled. If a '1' is not read for the STOP bit, then a framing error has occurred. This probably means that the START bit was incorrectly detected. It can also mean that the data format selected is incorrect. For example, 8-bit ASCII may have been transmitted, but the receiver was expecting 7-bit ASCII.

Parity Bit

The parity bit is used to detect transmission errors.

All the '1's in the data transmitted are counted (excluding START and STOP bits).

If even parity is selected, the parity bit is set so that the total number of bits which are '1' is an even number.

If odd parity is selected, the parity bit is set so that the total number of bits which are '1' is an odd number.

Data Levels

True RS232 signals are bipolar, that is they range between positive and negative levels when changing from '1' to '0' states.

Some RS232 derivative specifications use 0V and 5V levels. These are acceptable for short distances only.

The full RS232 specification allows for +/-15V to be sent by the transmitter. The receiver has a +/-3V threshold to allow for attenuation.

A SPACE (logic '0') is transmitted as a positive voltage and the MARK (logic '1') is transmitted as a negative voltage. It should be noted that negative logic is used here.

Physical connection

There are a large number of control signals provided in RS232. However, the simplest RS232 connection is shown below, which does not use any hardware control lines.

	Tx  2 -------------\  /-------------- 2 Tx
			    \/
	Rx  3 ______________/\_______________ 3 Rx


	GND 7 ------------------------------- 7 GND

In spite of the 'standard', there are numerous variations in RS232 connections found in equipment. This is why there are several RS232 analysers on the market. It may be necessary to experiment before achieving successful RS232 communications.
| Back | Next |