Registers in PIC Microcontroller

PIC Microcontrollers use registers for storage. They store the data that is going to be used, they store the instructions that are to be used and they store the results obtained. Registers are made up of using a number of flip-flops. Each flip-flop can only store one bit so to handle 32 bits at a time we would need 32 flip-flops and would refer to this as a 32-bit register. The memory of the PIC microcontroller is divided into a series of such registers.

There are two distinct groups of connections in the register: the data bits and the control signals. Data lines carry the binary levels in or out of the register. The number of the data lines determine the size of the register

Control Signals

1. Read/write: ‘read’ and ‘write’ describe the direction of data movement in the register. Data is read from the register and new data is written into the register.

2. Enable: This acts like an on/off switch for the register. When the enable line is ‘low’, the register is switched on. This is also called the ‘active low’ of the line. Similarly when the enable line is ‘high’, the register is switched off. This is achieved using a tri-state buffer because of which we can use a single line for both read and write. The benefit of having the enable line is that we are able to disconnect a register without doing any physical uncoupling of links.

In most cases in PIC Microcontroller, the data to be stored is applied to the inputs of the register and, after a short pause to let the voltages stabilize, the register is enabled by the voltage on the enable control. The information is then safely stored until it is next required.

The sequence is:

1. The read/write line is taken to logic 0 to allow the register to receive data from an external source.
2. The enable control switches ON the tri-state buffers at the input to each flip-flop.
3. The data is written to each flip-flop and then the enable control puts the register to sleep until the next time it is needed.

Information stored within registers can be moved around using shift registers or rotate registers:

Shift Register in PIC Microcontroller

As the name implies, this register shifts data from one flip-flop to the next each time the clock runs one cycle.

The image above shows a shift left register as each bit moves one place to the left on each clock pulse. all the bits move at the same time. After each clock pulse, the data in bit 7 drops off the end and is lost while at the other end, new data is entered into bit 0. Similarly, with a bit of modification we can have shift right registers which would shift data towards the right.

 What if no input is fed at bit 0?

If the input connection is simply left unconnected, there will be no voltage information coming into the first flip-flop. The input is said to be ‘floating’ and will assume some voltage which may be low or high. As the clock pulses are applied this may well result in random data entering the register. Random data is of no help to anyone so we normally overcome this problem by building in a bias in the design of the register to make it have a tendency to move towards one logic level rather than the other. It is up to the manufacturer but most floating inputs will float high and enter ones

Rotate Register

In PIC Microcontroller these are modified versions of the shift registers. They deviate from shift registers in two ways. Firstly, data is loaded in parallel, that is, the data is loaded into each flip-flop in the register at the same time. The downside is that this requires a separate connection to carry data to each bit, but all the data is loaded under the control of a single clock pulse so it is much faster than shift register.

The benefit of using a rotate rather than a shift register is that the data is not destroyed. We have seen that a shift register is progressively emptied as bits fall into the bin at the end. With a rotate register, the data is not changed. If we rotate left, say, six times, we only have to rotate right six times to recover all the original data.

PIC Microcontroller

Also read relevant Blogs:

Logical Intrustions in 8051

For more info – Please refer Wikipedia

Spread knowledge

Leave a Comment

Your email address will not be published. Required fields are marked *