|
|
|
|
Shift registers
There are two types of shift registers: input
and output. Input shift registers receive data in parallel,
through 8 lines and then send it serially through two lines to a
microcontroller. Output shift registers work in the opposite
direction; they receive serial data and on a "latch" line
signal, they turn it into parallel data. Shift registers are generally
used to expand the number of input-output lines of a microcontroller.
They are not so much in use any more though, because most modern
microcontrollers have a large number of input/output lines. However, their
use with microcontrollers such as PIC16F84 is very important.
An outline of the connection of the shift register 74HC597 to a micro, is shown below.
How to connect an input shift register to a microcontroller In order to simplify the main program, a
macro can be used for the input shift register. Macro HC597 has two
arguments:
Example of how to use the HC597 macro is given in the following program. Program receives data from a parallel input of the shift register and moves it serially into the RX variable of the microcontroller. LEDs connected to port B will indicate the result of the data input.
Output shift register
An outline of the 74HC595 shift register connections is shown on the diagram below:
Connecting an output shift register to a microcontroller
An example of how to use the HC595 macro is given in the following program. Data from variable TX is serially transferred to shift register. LEDs connected to the parallel output of the shift register will indicate the state of the lines. In this example value 0xCB (1100 1011) is sent so that the eighth, seventh, fourth, second and first LEDs are illuminated.
|
|
|
|
|
© Copyright 1999. mikroElektronika. All Rights Reserved. For any comments contact webmaster.
|