Calling Dsp/Bios Apis From Main - Texas Instruments TMS320 User Manual

Dsp/bios v5.40
Hide thumbs Also See for TMS320:
Table of Contents

Advertisement

Calling DSP/BIOS APIs from Main

2.11 Calling DSP/BIOS APIs from Main

2-32
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.

Advertisement

Table of Contents
loading

Table of Contents