Page 381 - ARM Based Microcontroller Projects Using MBED
P. 381
15.4 PROJECT 1—DIFFERENT FLASHING A PAIR OF LEDs—USING Mbed THREAD 367
FIG. 15.4 Program PDL.
15.4.3 Circuit Diagram
LEDA and LEDB are connected to GPIO ports PC_0 and PC_1, respectively, through
390 ohm current limiting resistors.
15.4.4 The PDL
Fig. 15.4 shows the program PDL.
15.4.5 Mbed Thread
Function Thread allows defining and creating tasks in a program. Main in a program is a
special case of a thread function that is started at system startup time and it has normal pri-
ority, known as osPriorityNormal.
A thread is basically a function in a program which normally runs continuously after it is
started. Function thread.start(name) starts thread called name. Function Thread::wait(n)
should be used to create n milliseconds of delay in a thread.
The program is called MultiLED. Before using the RTOS functions we have to load the
RTOS library to our program. The steps are as follows:
• Create a blank program called MultiLED
• Go to the following web site:
https://os.mbed.com/handbook/RTOS
• Click Import Library to import the RTOS library to your program space
• Select Target Path as MultiLED
Fig. 15.5 shows the program listing. At the beginning of the program, header files mbed.h
and rtos.h are included in the program, LEDA and LEDB are configured as digital outputs are