Page 224 - Programming Microcontrollers in C
P. 224
Summary 209
The numeric display takes four inputs that are merely the BCD value
of the number to be shown. With this particular display, a 4-bit num
ber between the values of 0 and 9 will be displayed. If each of the
four input lines to the display is turned on, the display will be turned
off. The parameters passed to the function—high and low—are
flags to indicate whether the corresponding output is to be turned on.
void display(int high, int low)
/* Display the contents of units and tens on the
appropriate LED displays. High corresponds to
tens, and low corresponds to units. If the proper
argument is TRUE, the corresponding LED will be
turned on. If the argument is FALSE, the LED will
be turned off. */
{
unsigned int save;
save = tens<<4;
save |= units70x0f;
PORTA=save;
if(!high)
PORTA |= 0xf0;
if(!low)
PORTA |= 0xf;
}
Summary
In this chapter, we have discussed programming techniques for a
few of the more important peripheral components found on
microcontrollers. Timers and ADC applications will be reconsidered
in later chapters. In later chapters, serial communications, attendant
programming of look-up tables, interpolation between data points in
look-up tables, and synchronous communications from standard digi
tal I/O pins rather than an SPI will be covered. Some small 8-bit
microcontrollers have pulse width modulation (PWM) outputs that
can be used as a digital-to-analog converter (DAC). Often the ranges
available from these fixed PWM systems are not satisfactory for the
required application. Other methods of accomplishing the PWM
operation will be discussed in later chapters.