Calling DSP/BIOS APIs from Main
2-32
2.11 Calling DSP/BIOS APIs from Main
The main routine in a DSP/BIOS application is for user initialization purposes
such as configuring a peripheral, or enabling individual hardware interrupts.
It is important to recognize that main does not fall into any of the DSP/BIOS
threads types (HWI, SWI, TSK, or IDL), and that when program execution
reaches main, not all of the DSP/BIOS initialization is complete. This is
because DSP/BIOS initialization takes place in two phases: during BIOS_init
which runs before main, and during BIOS_start which runs after your program
returns from main.
Certain DSP/BIOS API calls should not be made from the main routine,
because the BIOS_start initialization has not yet run. BIOS_start is
responsible for enabling global interrupts, configuring and starting the timer,
and enabling the schedulers so that DSP/BIOS threads can start executing.
Therefore, DSP/BIOS calls that are not appropriate from main are APIs which
assume hardware interrupts and the timer are enabled, or APIs that make
scheduling calls that could block execution. For example, functions such as
CLK_gethtime and CLK_getltime should not be called from main because the
timer is not running. HWI_disable and HWI_enable should not be called
because hardware interrupts are not globally enabled. Potentially blocking
calls, such as SEM_pend or MBX_pend, should not be called from main
because the scheduler is not initialized. Scheduling calls such as
TSK_disable, TSK_enable, SWI_disable, or SWI_enable are also not
appropriate within main.
BIOS_init, which runs before main, is responsible for initialization of the MEM
module. Therefore, it is okay to call dynamic memory allocation functions
from main. Not only are the MEM module functions allowed (MEM_alloc,
MEM_free, etc.), but APIs for dynamic creation and deletion of DSP/BIOS
objects, such as TSK_create and TSK_delete, are also allowed.
While blocking calls are not permitted from main, scheduling calls that make
a DSP/BIOS thread ready to run are permitted. These are calls such as
SEM_post or SWI_post. If such a call is made from main, the readied thread
is scheduled to run after the program returns from main and BIOS_start
finishes executing.
See the
TMS320 DSP/BIOS API Reference Guide
for your platform for more
information on a particular DSP/BIOS function call. The
Constraints and
Calling Context
sections indicates if the API cannot be called from main.
Summary of Contents for TMS320 Series
Page 1: ...TMS320 DSP BIOS v5 40 User s Guide Literature Number SPRU423G April 2009 ...
Page 16: ...xvi ...
Page 152: ...Tasks 4 48 Figure 4 12 Trace from Example 4 7 ...
Page 168: ...Semaphores 4 64 Figure 4 14 Trace Results from Example 4 11 ...
Page 202: ...5 20 ...
Page 287: ...Index 9 Index Void 1 11 W words data memory 3 15 of code 1 5 wrapper function 2 29 ...
Page 288: ...Index 10 Index ...