User`s manual

74 digi.com Multitasking with Dynamic C
5.10 µC/OS-II
µC/OS-II is a simple, clean, efficient, easy-to-use real-time operating system that runs on the Rabbit
microprocessor and is fully supported by the Dynamic C development environment. With Dynamic C,
there is no fee to pay for the “Object Code Distribution License” that is usually required for embedding
µC/OS-II in a product.
µC/OS-II is capable of intertask communication and synchronization via the use of semaphores, mail-
boxes, and queues. User-definable system hooks are supplied for added system and configuration control
during task creation, task deletion, context switches, and time ticks.
For more information on µC/OS-II, please refer to Jean J. Labrosse’s book, MicroC/OS-II, The Real-Time
Kernel (ISBN: 0-87930-543-6). The data structures (e.g., Event Control Block) referenced in the Dynamic
C µC/OS-II function descriptions are fully explained in Labrosse’s book. It can be purchased at
http://www.ucos-ii.com/.
The Dynamic C version of µC/OS-II has the new features and API changes available in version 2.51 of
µC/OS-II. The documentation for these changes will be in the /Samples/UCos-II directory. The file
Newv251.pdf contains all of the features added since version 2.00 and Relv251.pdf contains release
notes for version 2.51.
The remainder of this section discusses the following:
Dynamic C enhancements to µC/OS-II
Tasking aware ISRs
Dynamic C library reentrancy
How to get a µC/OS-II application running
TCP/IP compatibility
API function descriptions
Debugging tips
5.10.1 Changes to µC/OS-II
Minor changes have been made to µC/OS-II to take full advantage of services provided by Dynamic C.
5.10.1.1 Ticks per Second
In most implementations of µC/OS-II, OS_TICKS_PER_SEC informs the operating system of the rate at
which OSTimeTick is called; this macro is used as a constant to match the rate of the periodic interrupt.
In µC/OS-II for the Rabbit, however, changing this macro will change the tick rate of the operating system
set up during OSInit. Usually, a real-time operating system has a
tick rate of 10 Hz
to 100 Hz, or 10–100
ticks per second. Since the periodic interrupt on the Rabbit occurs at a rate of 2 kHz, it is recommended
that the tick rate be a power of 2 (e.g., 16, 32, or 64). Keep in mind that the higher the tick rate, the more
overhead the system will incur.
In the Rabbit version of µC/OS-II, the number of ticks per second defaults to 64. The actual number of
ticks per second may be slightly different than the desired ticks per second if TicksPerSec does not
evenly divide 2048.
Changing the default tick rate is done by simply defining OS_TICKS_PER_SEC to the desired tick rate
before calling OSInit(). For example, to change the tick rate to 32 ticks per second: