A shift register chip is very useful for expanding the digital I/O. Getting more digital outputs, the 74HC595 is very popular due to its ease of use. It is called a serial in parallel out shift register IC. The 74XX prefix belong to the clue logic family of the digital IC.
74HC595 chips in DIP package |
The communication interface between the MCU and this controller is quite simple. It basically use three pins as in the form of the Serial Peripheral Interface (SPI) which are,
- Serial Data
- Serial Clock
- Enable
This IC has an 8 bit output with an optional serial data out for a daisy-chain connection.
Pin diagram of this device |
An SPI communication that used by the MCU to send the data to this chip could be an SPI peripheral inside the MCU, or a software bit-banging written by the programmer. The SPI peripheral usually has a fixed pins but using the software bit-banging the output pins are select-able by the programmer.
With the software bit-banging, the program need to spend more more time executing this SPI-like communication. In this case it doesn't provide a high speed SPI.
CCS PICC has a built-in driver allowing the PIC microcontroller to send a serial data to this chip. We need to set up some basic steps as shown below:
- Select a serial data pin
- Select a serial clock pin
- Select a enable pin
- Set the numbers of register
- Send some bytes of data with a preset numbers of register
The 74595.c is ready to use in the CCS PICC compiler after the installation. The write_expanded_outputs(eo) function writes some bytes to this chip. The number of bytes is a preset number of register.
In this example, PIC18F4550 connects to a two-digit display driven by two distinct shift registers. The MCU counts the number of input up to 99 before it reset to 0.
Schematic Diagram |
Source of this program is written using CCS PICC.
No comments:
Post a Comment