The PIC 16F84 chip has a 13 pins which can be connected to the outside world. Other PICmicros have more or less pins, but the general philosophy is the same. Each of the pins can be either an input (we can use it to sense a voltage which may be applied to it) or an output (we can use it to produce a voltage).

At the moment we are considering purely digital behaviour, in that the signals will be either on or off. Other PICmicros have components which let them measure voltage levels and convert them to numbers (Analogue to Digital Converters). The PICmicro provides locations in the Special Function Register area which are used to interact with these pins. Such locations are called ports.

The 13 Programmable Input/Output (PIO) pins on the PIC16F84 are provided in two ports. Port A has 5 bits and Port B has eight bits.

The two tables on the right show the arrangement of the ports. Each pin is mapped onto a single bit in a given port. Because of the way that binary numbers are stored we can say that putting a particular power of two into a port will set one of the bits. For example, putting the value 2 into Port B will set the bit RB1 (note that we number pins starting at 0). If that bit was configured as an output it would mean that we are setting pin 7 on the PICmicro into the high state.

We can set several pins high at the same time by adding our powers of two together. For example to set RA3 and RA4 high we would use:

8 (the value for RA3) plus 16 (the value for RA4) - giving a value of 24 for Port A.

This would set pins 3 and 2 high. We will have to get used to combining powers of two in this way, we will also use these tricks to set the data direction registers. Note that we can control the state of the bits in a register by loading an eight bit value (which would update all the pins at once) or by setting or clearing individual pins. We will look at how this is done a little later.