User manual
DSM tutorials
par
{
while (1)
{
unsigned 1 Temp;
do
{
par
{
Count++;
PalSevenSegWriteDigit (PalSevenSegCT (0), Count, 0);
}
} while(Count != 0);
CountChan ! 0; /* Write to one channel */
CircleChan ? Temp; /* Read from other channel */
}
while (1)
{
unsigned 1 Temp;
CountChan ? Temp; /* Read from one channel */
do
{
par
{
Circle++;
PalSevenSegWriteShape (PalSevenSegCT (1),
CircleDisplayEncode[Circle]);
}
} while(Circle != 6);
Circle = 0; /* Reset Circle for next loop */
CircleChan ! 0; /* Write to other channel */
}
}
The first process counts from 0x0 to 0xF on its display, writes to the
CountChan channel, and then
reads from the
CircleChan channel, before counting again. The second process reads from the
CountChan channel, circles a lit segment around the display, writes to the CircleChan channel, and
then waits to read from the
CountChan channel again.
The channels are only a single bit wide, and are used for synchronization rather than communication of
data. The result is that the two 7-segment displays operate alternately, as the channel synchronization
ensures that only one process can be executing its display loop at any time.
When a channel is read, it must be read into a variable, so the example uses
Temp to receive the value
coming from each of the channels. Because this variable is never read from, the optimizer in DK will be
able to remove the hardware used by the variable during compilation.
www.celoxica.com
Page 48