3.1.4.2 FLASHLEDS.C
In addition to Dynamic C's implementation of C-language programming for embedded
systems, it supports assembly-language programming for very efficient processor-level
control of the module hardware and program flow. This application is similar to
and
FLASHLED.C
TOGGLELED.C
trol within cofunctions, another powerful multitasking tool.
Dynamic C permits the use of assembly language statements within C code. This program
creates three functions using assembly language statements, then creates a C cofunction to
call two of them. That cofunction is then called within
Within each of the C-like functions, the
the beginning and end of the assembly language statements.
In the function
initialize_ports( )
of port E is initialized to be an output.
In the function
ledon()
(0, which equals DS3, or 1 which equals DS4), turning that LED on. The
function works exactly the same way except that a 1 is written to the bit, turning the
selected LED off.
Finally, in the cofunction
onds, and the off time in milliseconds are passed as arguments. This function uses an end-
less
loop to call the
for(;;)
the wait function
DelayMs()
off.
As is proper in C program design, the contents of
first calls
initialize_ports()
loop, the program:
1. Calls the library function
(If the watchdog timer is not reset every so often, it will force a hard reset of the sys-
tem. The purpose is to keep an intermittent program or hardware fault from locking up
the system. Normally, this function is taken care of by the virtual driver, but it is called
explicitly here).
2. Sets up a costatement which calls two instances of the
each LED. Note that one LED is flashed one second on, one-half second (500 ms) off,
while the other is flashed in the reverse pattern.
Note also the
keyword in the costatement. This keyword (an abbreviation for
wfd
, which can also be used) must be used when calling cofunctions. For a complete
fordone
explanation, see Section 5 and 6 in the Dynamic C User's Manual.
More Information
See the entries for the
Manual, as well as those for the directives
User's Manual
, but uses assembly language for the low-level port con-
#asm
, port A is initialized to be all outputs while bit 0
, a 0 is written to the port A bit corresponding to the desired LED
, the LED to be flashed, the on time in millisec-
flashled()
and
ledon()
. This sequence will make the indicated LED flash on and
, then begins an endless
, which resets the microprocessor's watchdog timer.
hitwd()
and
hitwd()
DelayMs()
.
main()
and
directives are used to indicate
#endasm
functions, separated by calls to
ledoff()
are almost trivial. The program
main()
for(;;)
flashled()
functions in the Dynamic C User's
and
. For a complete explana-
#asm
#endasm
ledoff( )
loop. Within this
function, one for
wait-
17
Need help?
Do you have a question about the RabbitCore RCM2200 and is the answer not in the manual?
Questions and answers