User manual

DSM tutorials
B
LOCK DIAGRAM
4.2.2 Seven-segment display hardware interface
First define macro expressions for the pins which the seven-segment displays are connected to. The
example shown is for the RC200:
static macro expr SevenSeg0Pins = {"L5", "G4", "F3", "K3", "L4", "L3", "H4",
"G3"};
static macro expr SevenSeg1Pins = {"K4", "G5", "H3", "L6", "F5", "H5", "J3",
"J4"};
Now define registers to hold the values to be displayed, initialising them to zero. The example shown is
for the RC200, which has two seven-segment displays, hence the array of two 8-bit unsigned integers.
static unsigned 8 SevenSeg[2] = {0, 0};
Now define a Handel-C interface to attach the pins to the variables. Use the Handel-C
bus_out
interface as the pins are outputs from the device driver.
static interface bus_out () SevenSeg0Out (SevenSeg[0]) with {data =
SevenSeg0Pins};
static interface bus_out () SevenSeg1Out (SevenSeg[1]) with {data =
SevenSeg1Pins};
Note that making the SevenSeg variable and the various macros static prevents them from being
visible outside the file they are defined in.
Now implement a macro procedure to display a ‘shape’ on the seven-segment display. The figure below
shows how the segments of the display are numbered, so that when an 8-bit data value is written to the
display, bit 0 is the top segment, and bit 7 is the decimal point.
macro proc SevenSeg0WriteShape (Shape)
{
SevenSeg[0] = Shape;
}
NUMBERING OF DISPLAY SEGMENTS
Now implement a macro procedure which accepts a 4-bit unsigned integer and displays the
corresponding hexadecimal digit on the seven-segment display. The decimal point is set according to a
further 1-bit unsigned integer parameter. The required shapes to display hexadecimal digits have been
provided in the ROM
TranslationROM0 in the example project (TutorialSevenSeg1).
www.celoxica.com
Page 54