18.11.2014 Views

The Microcontroller Idea Book - Jan Axelson's Lakeview Research

The Microcontroller Idea Book - Jan Axelson's Lakeview Research

The Microcontroller Idea Book - Jan Axelson's Lakeview Research

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 8<br />

Listing 8-2. Causes a 7-segment LED to display each digit in sequence.<br />

10 REM configure all ports as outputs<br />

20 XBY(0FC03H)=80H<br />

30 REM write each value to the display in sequence<br />

40 FOR I=0 TO 9<br />

50 XBY (0FC00H)=I<br />

60 REM delay after each write<br />

70 FOR J=1 TO 500:NEXT J<br />

80 NEXT I<br />

90 END<br />

may be two common-anode pins.) To find the pin that controls each segment, leave the +5V<br />

lead on a common-anode pin, and connect the resistor to each pin in turn, noting the results.<br />

For a common-cathode display, to find the common-cathode pin or pins, connect a pin to<br />

+5V, and touch the others to ground through the 330-ohm resistor. <strong>The</strong> pin or pins that cause<br />

the segment to light are the common-cathode connections. To find the pin that controls each<br />

segment, move the +5V lead to each pin in turn, and note the results.<br />

Interfacing<br />

For 7-segment decoder/drivers, you can choose from single-digit and multi-digit chips.<br />

Single-digit driver. Figure 8-4 shows a 7-segment display controlled by a 4511B latch/decoder/driver.<br />

<strong>The</strong> display shows the value of the 4-bit number at the 4511’s data inputs A-D.<br />

<strong>The</strong> 4511 will drive common-cathode displays directly. Common-anode displays require<br />

inverters at the segment outputs. You can use any output port bits to control the display. An<br />

8-bit port will control a 2-digit display.<br />

Listing 8-2 tests Figure 8-4’s circuits by displaying each digit in sequence. <strong>The</strong> program<br />

assumes that a display connects to bits 0-3 of Port A on an 8255 addressed at FC00h. If your<br />

system has different addressing, change the program to match.<br />

Multi-digit driver. If you want to display more than a couple of digits, there are specialized<br />

chips that will drive and control multiple-digit displays. One example from Intersil (now<br />

part of Harris Semiconductor) is the ICM7218D multiplexed display driver, which can<br />

control up to 8 common-cathode digits. Figure 8-5 illustrates. For common-anode displays,<br />

use the ICM7218C.<br />

<strong>The</strong> segments of all eight displays connect to the 7218D’s segment-driver outputs (a-g, dp).<br />

Each display’s common cathode connects to one of eight DIGIT outputs. An internal oscillator<br />

132 <strong>The</strong> <strong>Microcontroller</strong> <strong>Idea</strong> <strong>Book</strong>

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!