Getting Started
27
4.3 Sample Program: FlashLED.c
If you did not load and compile
FlashLED.c
in the prior section, refer to Sections 4.2.3
Program Description
This program is about as simple as a Dynamic C application can get—the equivalent of
the traditional “Hello, world!” program found in most basic programming tutorials. If you
are familiar with ANSI C, you should have no trouble reading through the source code and
understanding it.
The only new element in this sample application should be Dynamic C’s handling of the
Rabbit microprocessor’s parallel ports. The program:
4. Initializes the pins of Port A as outputs.
5. Sets all of the pins of Port A high, turning off the attached LEDs.
6. Starts an endless loop with a
for(;;)
expression, and within that loop:
• Writes a bit to turn bit 1 off, lighting LED DS3;
• Waits through a delay loop;
• Writes a bit to turn bit 1 on, turning off the LED;
• Waits through a second delay loop;
These steps repeat as long as the program is allowed to run.
You can change the flash rate of the LED by adjusting the loop values in the two
for
expressions. The first loop controls the LED’s “off” time; the second loop controls its “on”
time.
NOTE: Since the variable
j
is defined as type
int
, the range for
j
must be between 0
and 32768. To permit larger values and thus longer delays, change the declaration of
j
to
unsigned int
or
long
.
More Information
See the section on primitive data types, and the entries for the library functions
WrPortI( )
and
BitWrPortI( )
in the Dynamic C Premier User’s Manual.
Summary of Contents for RCM2100
Page 28: ...24 RabbitCore RCM2100...
Page 43: ...C NONE CONFORMAL COATING BATTERY BACK UP BANK SELECT...
Page 45: ...B NONE B NONE...
Page 47: ......