EasyManuals Logo

Texas Instruments TMS320 User Manual

Texas Instruments TMS320
288 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #179 background imageLoading...
Page #179 background image
Timers, Interrupts, and the System Clock
Thread Scheduling 4-75
4.9.3 Example—System Clock
Example 4-16, clktest.c, shows a simple use of the DSP/BIOS functions that
use the system clock, TSK_time and TSK_sleep. The task, labeled task, in
clktest.c sleeps for 1000 ticks before it is awakened by the task scheduler.
Since no other tasks have been created, the program runs the idle functions
while task is blocked. The program assumes that the system clock is
configured and driven by PRD_clock. The trace log output for the code in
Example 4-16 would be similar to that shown in Example 4-17.
Example 4-16. Using the System Clock to Drive a Task
Note:
Non-pointer type function arguments to LOG_printf need explicit type
casting to (Arg) as shown in the following code example:
LOG_printf(&trace, "Task %d Done", (Arg)id);
/* ======== clktest.c =======
* In this example, a task goes to sleep for 1 sec and
* prints the time after it wakes up. */
#include <std.h>
#include <log.h>
#include <clk.h>
#include <tsk.h>
extern LOG_Obj trace;
/* ======== main ======== */
Void main()
{
LOG_printf(&trace, "clktest example started.\n");
}
Void taskFxn()
{
Uns ticks;
LOG_printf(&trace, "The time in task is: %d ticks",
(Int)TSK_time());
ticks = (1000 * CLK_countspms()) / CLK_getprd();
LOG_printf(&trace, "task going to sleep for 1 second... ");
TSK_sleep(ticks);
LOG_printf(&trace, "...awake! Time is: %d ticks",
(Int)TSK_time());
}

Table of Contents

Other manuals for Texas Instruments TMS320

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the Texas Instruments TMS320 and is the answer not in the manual?

Texas Instruments TMS320 Specifications

General IconGeneral
BrandTexas Instruments
ModelTMS320
CategoryComputer Hardware
LanguageEnglish

Related product manuals