Chapter 4 DSP/BIOS
description
Transcript of Chapter 4 DSP/BIOS
Chapter 4Chapter 4
DSP/BIOSDSP/BIOS
Chapter 4Chapter 4
DSP/BIOSDSP/BIOS
Part 1 - IntroductionPart 1 - Introduction
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
Chapter 4, Slide 3
Learning ObjectivesLearning Objectives
Introduce DSP/BIOS and its Introduce DSP/BIOS and its components.components.
Introduce the software tools for Introduce the software tools for managing DSP/BIOS components and managing DSP/BIOS components and objects.objects.
Run some examples.Run some examples.
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
Chapter 4, Slide 4
DSP/BIOSDSP/BIOS
The DSP/BIOS is an operating system that can provide:The DSP/BIOS is an operating system that can provide: A graphical interface for static system setup.A graphical interface for static system setup. Real-time scheduling.Real-time scheduling. Real-time analysis (RTA).Real-time analysis (RTA). Real-time data exchange (RTDX).Real-time data exchange (RTDX).
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
Chapter 4, Slide 5
DSP/BIOS ComponentsDSP/BIOS Components
The user writes code (‘C’/assembly) using the The user writes code (‘C’/assembly) using the DSP/BIOS library.DSP/BIOS library.
The user can use the configuration tools to setup the The user can use the configuration tools to setup the system.system.
All the files generated constitute a project.All the files generated constitute a project.
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
Chapter 4, Slide 6
DSP/BIOS ComponentsDSP/BIOS Components
The project is then compiled, assembled and linked by The project is then compiled, assembled and linked by the code generation tools in order to generate an the code generation tools in order to generate an executable file (*.out).executable file (*.out).
There are also some DSP/BIOS plug-ins that can be used, There are also some DSP/BIOS plug-ins that can be used, for instance, as program test while the target is running.for instance, as program test while the target is running.
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
Chapter 4, Slide 7
DSP/BIOS ComponentsDSP/BIOS Components
Code composer simulator/debugger and the host Code composer simulator/debugger and the host emulator support are also part of the code composer emulator support are also part of the code composer studio.studio.
The host and target communicate through the JTAG The host and target communicate through the JTAG (Joint Test Action Group) connection ((Joint Test Action Group) connection (ssya002c.pdfssya002c.pdf).).
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
Chapter 4, Slide 8
Graphical Interface for Static System SetupGraphical Interface for Static System Setup
Static system setup is performed using the DSP/BIOS GUI configuration tool.Static system setup is performed using the DSP/BIOS GUI configuration tool. The configuration tool has an interface similar to windows explorer.The configuration tool has an interface similar to windows explorer. It lets you:It lets you:
Specify a wide range of parameters used by the DSP/BIOS real-time library.Specify a wide range of parameters used by the DSP/BIOS real-time library. Create run-time objects that are used by the target application’s DSP/BIOS API calls.Create run-time objects that are used by the target application’s DSP/BIOS API calls.
Note: API: Application Programming Interface Note: API: Application Programming Interface
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
Chapter 4, Slide 9
Graphical Interface for Static System SetupGraphical Interface for Static System Setup
The DSP/BIOS main objects are:The DSP/BIOS main objects are:(1)(1) Hardware interrupts (HWI).Hardware interrupts (HWI).
(2)(2) Software interrupts (SWI).Software interrupts (SWI).
(3)(3) Tasks (TSK, IDL).Tasks (TSK, IDL).
(4)(4) Data and I/O streams (RTDX, SIO, PIP, HST).Data and I/O streams (RTDX, SIO, PIP, HST).
(5)(5) Synchronisation and Communication (SEM, MBX, LCK).Synchronisation and Communication (SEM, MBX, LCK).
(6)(6) Timing (PRD, CLK).Timing (PRD, CLK).
(7)(7) Logging and statistics (LOG, STS, TRC).Logging and statistics (LOG, STS, TRC).For a complete list see: For a complete list see: \Links\SPRU303.pdf\Links\SPRU303.pdf (Page 1-5). (Page 1-5).
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
Chapter 4, Slide 10
Graphical Interface for Static System SetupGraphical Interface for Static System Setup
How to create a configuration file:How to create a configuration file: Open CCS and create a new project and name it “lab1.pjt”.Open CCS and create a new project and name it “lab1.pjt”. Create a new configuration file by using a pre-built Create a new configuration file by using a pre-built
template file:template file:
FFile:ile:NNew:DSP/BIOS Configurationew:DSP/BIOS Configuration
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
Chapter 4, Slide 11
Graphical Interface for Static System SetupGraphical Interface for Static System Setup How to create a configuration file:How to create a configuration file:
Double click on the “dsk6711.cdb” icon and Double click on the “dsk6711.cdb” icon and the following configuration will appear:the following configuration will appear:
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
Chapter 4, Slide 12
Graphical Interface for Static System SetupGraphical Interface for Static System Setup
How to create a configuration file:How to create a configuration file: Now that you have selected the template, save it in your Now that you have selected the template, save it in your
current working directory, current working directory, e.g: Code\Chapter4 - DSP_BIOS\e.g: Code\Chapter4 - DSP_BIOS\Lab1\lab1.cdb.Lab1\lab1.cdb.
Finally, add the “*.cdb” configuration file to the project.Finally, add the “*.cdb” configuration file to the project.
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
Chapter 4, Slide 13
Graphical Interface for Static System SetupGraphical Interface for Static System Setup
Files created by the configuration tools:Files created by the configuration tools: Once the lab1.cdb file is modified, saved and added to the project, the configuration manager will Once the lab1.cdb file is modified, saved and added to the project, the configuration manager will
create and load the following files:create and load the following files: lab1cfg.s62lab1cfg.s62 Assembly fileAssembly file lab1cfg_c.clab1cfg_c.c C fileC file lab1cfg.hlab1cfg.h Header file for CHeader file for C lab1cfg.h62lab1cfg.h62 Header file for assemblyHeader file for assembly
A file called “lab1cfg.cmd” is also created but must be loaded by the user.A file called “lab1cfg.cmd” is also created but must be loaded by the user.
Note:Note: the user must add the *.cdb and *.cmd the user must add the *.cdb and *.cmd files to the project.files to the project.
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
Chapter 4, Slide 14
Graphical Interface for Static System SetupGraphical Interface for Static System Setup
Files used to create the DSP/BIOS Files used to create the DSP/BIOS program:program: The abbreviation 62 is used for the C6000 The abbreviation 62 is used for the C6000
processors.processors.
Programs generated by the userPrograms generated by the user
Programs/Files generated by the Programs/Files generated by the configuration managerconfiguration manager
Chapter 4Chapter 4
DSP/BIOSDSP/BIOS
Part 2 - Real Time SchedulingPart 2 - Real Time Scheduling
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
Chapter 4, Slide 16
Learning ObjectivesLearning Objectives
What is a real-time scheduler?What is a real-time scheduler? Why do we need a real-time scheduler?Why do we need a real-time scheduler? DSP/BIOS Thread Types.DSP/BIOS Thread Types. Example.Example.
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
Chapter 4, Slide 17
Real-time schedulingReal-time scheduling
Before embarking into real-time Before embarking into real-time scheduling let us first state the problem:scheduling let us first state the problem:
main ()main ()
{{
for (;;);for (;;);
}}
ISR1()ISR1()
{{
algorithm1();algorithm1();
}}
ISR2()ISR2()
{{
algorithm2();algorithm2();
}}
Once ISR1 or 2 is called, algorithm 1 or 2 runs Once ISR1 or 2 is called, algorithm 1 or 2 runs to completion. Can this cause a problem?to completion. Can this cause a problem?
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
Chapter 4, Slide 18
Real-time schedulingReal-time scheduling
Before embarking into real-time Before embarking into real-time scheduling let us first state the problem:scheduling let us first state the problem:
main ()main ()
{{
for (;;);for (;;);
}}
ISR1()ISR1()
{{
algorithm1();algorithm1();
}}
ISR2()ISR2()
{{
algorithm2();algorithm2();
}}
Once ISR1 or ISR2 is called, algorithm 1 or 2 Once ISR1 or ISR2 is called, algorithm 1 or 2 runs to completion. Can this cause a problem?runs to completion. Can this cause a problem?
There is no guarantee of meeting There is no guarantee of meeting the real-time deadlines because:the real-time deadlines because:
(1)(1) The algorithms can run at different The algorithms can run at different rates.rates.
(2)(2) One algorithm can overshadow the One algorithm can overshadow the other.other.
(3)(3) The timing can be non-deterministic.The timing can be non-deterministic.
etc.etc.
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
Chapter 4, Slide 19
Real-time schedulingReal-time scheduling
The answer depends on the application.The answer depends on the application. If we want to process two algorithms in real-time then we have to answer the If we want to process two algorithms in real-time then we have to answer the
following questions:following questions: Are ISR1 and ISR2 synchronised? If yes, then we can use only an ISR that processes both Are ISR1 and ISR2 synchronised? If yes, then we can use only an ISR that processes both
algorithms (assuming that we have enough processing power to complete algorithm 1 and 2 on time).algorithms (assuming that we have enough processing power to complete algorithm 1 and 2 on time). What happens if the algorithms are not synchronised?What happens if the algorithms are not synchronised? Which algorithm has a higher priority?Which algorithm has a higher priority? Can the algorithm of lower priority be pre-empted (stopped)?Can the algorithm of lower priority be pre-empted (stopped)?
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
Chapter 4, Slide 20
Real-time schedulingReal-time scheduling
Example: Simple application.Example: Simple application. System description:System description:
Algorithm 1 and 2 are not synchronised.Algorithm 1 and 2 are not synchronised. Assume algorithm 1 has the highest priority.Assume algorithm 1 has the highest priority. Algorithm 2 can be pended.Algorithm 2 can be pended.
Algorithm 1Algorithm 1
Algorithm 2Algorithm 2
CPU processing CPU processing Algorithm 1Algorithm 1
CPU processing Algorithm 2CPU processing Algorithm 2
MISSED!MISSED!
Remember: there is only one CPU and therefore Remember: there is only one CPU and therefore only one algorithm can be processed at a time.only one algorithm can be processed at a time.
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
Chapter 4, Slide 21
Real-time schedulingReal-time scheduling
Example: Simple application.Example: Simple application. Solution 1: Algorithm decomposition:Solution 1: Algorithm decomposition:
The algorithm can be decomposed into sub-functions:The algorithm can be decomposed into sub-functions:
When the CPU is not processing algorithm1 it can process one of the sub-functions When the CPU is not processing algorithm1 it can process one of the sub-functions (to completion) as shown:(to completion) as shown:
algorithm2 ();algorithm2 (); function1();function1();
function2();function2();
function3();function3();
Algorithm 1Algorithm 1
Algorithm 2Algorithm 2function1function1 function2function2 function3function3
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
Chapter 4, Slide 22
Real-time schedulingReal-time scheduling
Example: Simple application.Example: Simple application. Problems with this solution:Problems with this solution:
Difficult to write (as timing is critical).Difficult to write (as timing is critical). Difficult to change (what happens if algorithm is Difficult to change (what happens if algorithm is
modified or another algorithm is added).modified or another algorithm is added).
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
Chapter 4, Slide 23
Real-time schedulingReal-time scheduling
Example: Simple application.Example: Simple application. Solution 2: Using an operating systemSolution 2: Using an operating system
Advantages:Advantages: Easy to write (algorithms are written independently).Easy to write (algorithms are written independently). Easy to maintain or change (operating system takes care of the scheduling).Easy to maintain or change (operating system takes care of the scheduling). Enables fast time to market.Enables fast time to market.
Which operating system? Depends on:Which operating system? Depends on: The processor being used.The processor being used. The DSP platform (single/multi processors).The DSP platform (single/multi processors).
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
Chapter 4, Slide 24
Real-time scheduling: DSP/BIOSReal-time scheduling: DSP/BIOS
For all TI DSPs there is a DSP/BIOS operating system which includes:For all TI DSPs there is a DSP/BIOS operating system which includes: Small sized real-time library.Small sized real-time library. An API for using the library services.An API for using the library services. Easy-to-use configuration tools.Easy-to-use configuration tools. Real-time analysis programs.Real-time analysis programs.
DSP/BIOS scheduling solution provides:DSP/BIOS scheduling solution provides: Fixed-priority preemptive scheduler.Fixed-priority preemptive scheduler. Multiple thread types.Multiple thread types.
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
Chapter 4, Slide 25
Real-time scheduling: TerminologyReal-time scheduling: Terminology
No preemption: Resources cannot be preempted; which means that the only way of releasing a resource is by the process of holding it.No preemption: Resources cannot be preempted; which means that the only way of releasing a resource is by the process of holding it.
Object: Term for data and code structures provided by DSP/BIOS, e.g. an event, task, semaphore.Object: Term for data and code structures provided by DSP/BIOS, e.g. an event, task, semaphore.
Pend: Wait for an event Resource preemption: Release of a resource.Pend: Wait for an event Resource preemption: Release of a resource.
Post: Signal an event, e.g. post a software interrupt, that is make a software interrupt ready.Post: Signal an event, e.g. post a software interrupt, that is make a software interrupt ready.
Preemption: A higher priority function (or thread) interrupts other functions (or threads) of lower priority.Preemption: A higher priority function (or thread) interrupts other functions (or threads) of lower priority.
Priority scheduling: Priority scheduling can be either preemptive or non-preemptive. A preemptive priority scheduling algorithm will preempt (release) Priority scheduling: Priority scheduling can be either preemptive or non-preemptive. A preemptive priority scheduling algorithm will preempt (release) the CPU if another process of higher priority arrives.the CPU if another process of higher priority arrives.
Process: A task or thread of execution.Process: A task or thread of execution.
Scheduler: System software to manage the execution of threads.Scheduler: System software to manage the execution of threads.
Scheduling: The planning used to share a resource.Scheduling: The planning used to share a resource.
Semaphore: Synchronisation system object that enables tasks to synchronise their activities.Semaphore: Synchronisation system object that enables tasks to synchronise their activities.
Thread: An independent function.Thread: An independent function.
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
Chapter 4, Slide 26
DSP/BIOS Thread TypesDSP/BIOS Thread TypesP
rio
rity
Pri
ori
tyHWIHWI
Hardware InterruptsHardware Interrupts
HWI priorities set by hardwareHWI priorities set by hardware
One ISR per interrupt.One ISR per interrupt.
HWI triggered by hardware interrupt.HWI triggered by hardware interrupt.
IDL runs as the background thread.IDL runs as the background thread.
What causes a SWI or TSK to run?What causes a SWI or TSK to run?
SWISWISoftware InterruptsSoftware Interrupts
14 SWI priority levels14 SWI priority levels
Multiple SWIs at each level.Multiple SWIs at each level.
TSKTSKTasksTasks
15 TSK priority levels15 TSK priority levels
Multiple TSKs at each level.Multiple TSKs at each level.
IDLIDLBackgroundBackground
Multiple IDL functionsMultiple IDL functions
Continuous loop.Continuous loop.
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
Chapter 4, Slide 27
Triggering SWI or TSKTriggering SWI or TSK
SWI cannot pend.SWI cannot pend.
SWI always returnsSWI always returns
from function.from function.
SWISWI
startstart
endend
SWI_postSWI_post
““run torun to
completion”completion”
TSK only returns when no TSK only returns when no
longer needed, otherwiselonger needed, otherwise
normally an infinite loop.normally an infinite loop.
TSKTSK
SEM_pendSEM_pend
startstart
endend
blockblock
SEM_postSEM_post
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
Chapter 4, Slide 28
Considerations in Selecting Thread TypesConsiderations in Selecting Thread Types
Thread latency and data rates.Thread latency and data rates. Multi-tiered response to interrupts:Multi-tiered response to interrupts:
HWI is fast (for sample-by-sample response time).HWI is fast (for sample-by-sample response time). SWI is slower (triggered to process frame).SWI is slower (triggered to process frame).
Priority of thread.Priority of thread. Stack needs:Stack needs:
O.K. to share system stack? then use SWI.O.K. to share system stack? then use SWI. Need private stack? then use TSK.Need private stack? then use TSK.
Synchronization and communication methods:Synchronization and communication methods: SWI and TSK have different methods.SWI and TSK have different methods.
User preference or ease-of-use.User preference or ease-of-use.
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
Chapter 4, Slide 29
Thread Preemption ExampleThread Preemption Example
HWIHWI
SWI 2SWI 2
SWI 1SWI 1
IDLIDL
main()main()
TSK 2TSK 2
TSK 1TSK 1
interruptinterrupt
pend pend sem2sem2
returnreturn
interruptinterrupt
interruptinterrupt
pend pend sem2sem2
pend pend sem1sem1
interruptinterrupt
returnreturn
returnreturn
post post swi1swi1 returnreturn post post
swi2swi2 returnreturn post post sem2sem2 returnreturn post post
swi2swi2 returnreturn
post post sem1sem1
post post sem2sem2
returnreturn
pend pend sem2sem2
pend pend sem1sem1
Events over timeEvents over time
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
Chapter 4, Slide 30
Laboratory ExerciseLaboratory Exercise
Laboratory objectives:Laboratory objectives:(1)(1) Set the internal timer 1 to generate ticks at 8kHz.Set the internal timer 1 to generate ticks at 8kHz.
(2)(2) Set a hardware interrupt that is triggered by internal timer 1.Set a hardware interrupt that is triggered by internal timer 1.
(3)(3) Create a software interrupt that can be posted by the hardware interrupt.Create a software interrupt that can be posted by the hardware interrupt.
(4)(4) Create a task that can be posted by the hardware interrupt.Create a task that can be posted by the hardware interrupt.
(5)(5) Create a semaphore that can be used by the task functions.Create a semaphore that can be used by the task functions.
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
Chapter 4, Slide 31
(1) Setting Internal Timer 1(1) Setting Internal Timer 1
(1)(1) Create a new project and call it “bios_lab.pjt”.Create a new project and call it “bios_lab.pjt”.
(2)(2) Add the “dsk6711.cdb” file (see slide 10) and rename it Add the “dsk6711.cdb” file (see slide 10) and rename it “bios_lab2.cdb”.“bios_lab2.cdb”.
(3)(3) Set a timer configuration by using the “Timer Set a timer configuration by using the “Timer Configuration Manager” and call it “timerCfg0” and set the Configuration Manager” and call it “timerCfg0” and set the properties:properties:
The GUI interface will generate the “bios_labcfg.c”, see The GUI interface will generate the “bios_labcfg.c”, see \Links\\Links\bios_labcfg.pdfbios_labcfg.pdf
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
Chapter 4, Slide 32
(2) Setting the Hardware Interrupt(2) Setting the Hardware Interrupt
(1)(1) Open the CDB file.Open the CDB file.
(2)(2) Select the “HWI - Hardware Interrupt Service …”.Select the “HWI - Hardware Interrupt Service …”.
((3)3) Select HWI_INT15 and right Select HWI_INT15 and right click to select properties.click to select properties.
Source = Timer_1Source = Timer_1
Function = _timerIsrFunction = _timerIsr
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
Chapter 4, Slide 33
(2) Setting the Hardware Interrupt(2) Setting the Hardware Interrupt
(4)(4) Write the Interrupt Service Routine in C.Write the Interrupt Service Routine in C.
void timerIsr (void)void timerIsr (void)
{{
/* Put your code here *//* Put your code here */
}}
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
Chapter 4, Slide 34
(3) Creating a Software Interrupt(3) Creating a Software Interrupt
(1)(1) Open the cdb file and select the “SWI - Software Interrupt Manager”Open the cdb file and select the “SWI - Software Interrupt Manager”
and create a new software interrupt called “SWI_for_algorithm_1”.and create a new software interrupt called “SWI_for_algorithm_1”.
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
Chapter 4, Slide 35
(3) Creating a Software Interrupt(3) Creating a Software Interrupt
(2)(2) Change the properties of the “SWI_for_algorithm_1” to:Change the properties of the “SWI_for_algorithm_1” to:
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
Chapter 4, Slide 36
(3) Creating a Software Interrupt(3) Creating a Software Interrupt
(3)(3) Create a software interrupt function in C.Create a software interrupt function in C.
void algorithm_1 (void)void algorithm_1 (void)
{{
/* Put your code here *//* Put your code here */
}}
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
Chapter 4, Slide 37
(4) Creating a Task(4) Creating a Task
(1)(1) Open the cdb file and select the “TSK - Task Manager”Open the cdb file and select the “TSK - Task Manager”
and create a new task called “TaskOneTsk”.and create a new task called “TaskOneTsk”.
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
Chapter 4, Slide 38
(4) Creating a Task(4) Creating a Task
(2)(2) Change the properties to:Change the properties to:
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
Chapter 4, Slide 39
void ProcessTask (void)void ProcessTask (void)
{{
/* Put your algorithm here *//* Put your algorithm here */
}}
(4) Creating a Task(4) Creating a Task
(3)(3) Create a task function in C:Create a task function in C:
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
Chapter 4, Slide 40
(5) Creating a Semaphore(5) Creating a Semaphore
(1)(1) Open the cdb file and select the “SEM - Semaphore Manager” Open the cdb file and select the “SEM - Semaphore Manager” and create a new semaphore called “taskOneSem”.and create a new semaphore called “taskOneSem”.
(2)(2) Change the properties of the “taskOneSem” to:Change the properties of the “taskOneSem” to:
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
Chapter 4, Slide 41
Posting Software Interrupts and TasksPosting Software Interrupts and Tasks
(1)(1) Software InterruptsSoftware Interrupts
The software interrupts can be posted simply by writing:The software interrupts can be posted simply by writing:
(2)(2) TasksTasks
The task can be removed from semaphore queue and put it on the ready queue:The task can be removed from semaphore queue and put it on the ready queue:
SWI_post (&SWI_for_algorithm_1);SWI_post (&SWI_for_algorithm_1);
SEM_post (&taskOneSem);SEM_post (&taskOneSem);
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
Chapter 4, Slide 42
More on Tasks… More on Tasks…
A task can be pending where as Software Interrupts (SWI) run to completion.A task can be pending where as Software Interrupts (SWI) run to completion. Tasks normally run in an infinite loop and within the loop the task tests for a semaphore.Tasks normally run in an infinite loop and within the loop the task tests for a semaphore. A task can preempt itself, e.g:A task can preempt itself, e.g:
void ProcessTask (void)void ProcessTask (void)
{{
while (1)while (1)
{{
SEM_pend (&taskOneSem, SYS_FOREVER);SEM_pend (&taskOneSem, SYS_FOREVER);
/* Insert your code here *//* Insert your code here */
}}
}}
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
Chapter 4, Slide 43
Putting it all together… Putting it all together… void main (void)void main (void){{
/* Put all your setup code here *//* Put all your setup code here */return; /*DSP BIOS starts after the return */return; /*DSP BIOS starts after the return */
}}
/* Hardware Interrupt *//* Hardware Interrupt */void timerIsr (void)void timerIsr (void){{
/* Put your code here *//* Put your code here */SWI_post (&SWI_for_algorithm_1);SWI_post (&SWI_for_algorithm_1);SEM_post (&taskOneSem);SEM_post (&taskOneSem);
}}
/*Software Interrupt *//*Software Interrupt */void algorithm_1 (void)void algorithm_1 (void){{
/* Put your code here *//* Put your code here */}}
/* Task *//* Task */void ProcessTask (void)void ProcessTask (void){{
while (1)while (1){{
SEM_pend (&taskOneSem, SYS_FOREVER);SEM_pend (&taskOneSem, SYS_FOREVER);/* Insert your code here *//* Insert your code here */
}}}}
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
Chapter 4, Slide 44
Putting it all together… Putting it all together… void main (void)void main (void){{
/* Put all your setup code here *//* Put all your setup code here */return; /*DSP BIOS starts after the return */return; /*DSP BIOS starts after the return */
}}
/* Hardware Interrupt *//* Hardware Interrupt */void timerIsr (void)void timerIsr (void){{
/* Put your code here *//* Put your code here */SWI_post (&SWI_for_algorithm_1);SWI_post (&SWI_for_algorithm_1);SEM_post (&taskOneSem);SEM_post (&taskOneSem);
}}
/*Software Interrupt *//*Software Interrupt */void algorithm_1 (void)void algorithm_1 (void){{
/* Put your code here *//* Put your code here */}}
/* Task *//* Task */void ProcessTask (void)void ProcessTask (void){{
while (1)while (1){{
SEM_pend (&taskOneSem, SYS_FOREVER);SEM_pend (&taskOneSem, SYS_FOREVER);/* Insert your code here *//* Insert your code here */
}}}}
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
Chapter 4, Slide 45
Putting it all together… Putting it all together…
See example located in:See example located in:
……\ Chapter 04 - DSP BIOS\Bios_Lab2\bios_lab_2.pjt\ Chapter 04 - DSP BIOS\Bios_Lab2\bios_lab_2.pjt
Chapter 4Chapter 4
DSP/BIOSDSP/BIOS
Part 3 - Real Time Analysis ToolsPart 3 - Real Time Analysis Tools
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
Chapter 4, Slide 47
Learning ObjectivesLearning Objectives
Introduction to the analysis tools.Introduction to the analysis tools. Using the LOG module.Using the LOG module. Using the STS module.Using the STS module. Defining DSP/BIOS objects using the Defining DSP/BIOS objects using the
configuration tools.configuration tools. Example.Example.
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
Chapter 4, Slide 48
IntroductionIntroduction
Traditionally analysis was performed by Traditionally analysis was performed by halting the processor and examining variables halting the processor and examining variables or memory.or memory.
This traditional method is invasive and does not This traditional method is invasive and does not represent the reality of real-time issues.represent the reality of real-time issues.
Real-time analysis is the analysis of data Real-time analysis is the analysis of data acquired during real-time operation of a system acquired during real-time operation of a system without having to stop or interfere with the without having to stop or interfere with the target.target.
The API’s and Plug-ins provided with The API’s and Plug-ins provided with DSP/BIOS enable the programmer to monitor DSP/BIOS enable the programmer to monitor data while the target is running.data while the target is running.
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
Chapter 4, Slide 49
IntroductionIntroduction
So how can data be monitored without So how can data be monitored without stopping the target?stopping the target? Target-host communications is performed in Target-host communications is performed in
the background (IDL) thread (e.g. the CPU the background (IDL) thread (e.g. the CPU is performing NOPs or waiting for an is performing NOPs or waiting for an interrupt).interrupt).
Data formatting is done by the host and Data formatting is done by the host and therefore releases the CPU to perform useful therefore releases the CPU to perform useful tasks.tasks.
For more details see Chapter 3 of the For more details see Chapter 3 of the DSP/BIOS Users Guide (DSP/BIOS Users Guide (Links\SPRU303.pdfLinks\SPRU303.pdf).).
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
Chapter 4, Slide 50
DSP/BIOS - API ModulesDSP/BIOS - API Modules
Instrumentation/Real-Time AnalysisInstrumentation/Real-Time Analysis
LOGLOG Message Log mangerMessage Log mangerSTSSTS Statistics accumulator manager Statistics accumulator manager TRCTRC Trace manager Trace manager RTDXRTDX Real-Time Data Exchange manager Real-Time Data Exchange manager
Thread Types Thread Types
HWIHWI Hardware interrupt manager Hardware interrupt manager SWISWI Software interrupt manager Software interrupt manager TSKTSK Multitasking manager Multitasking manager IDLIDL Idle function & processing loop manager Idle function & processing loop manager
Clock and Periodic Functions Clock and Periodic Functions
CLKCLK System clock manager System clock manager PRDPRD Periodic function manger Periodic function manger
Comm/Synch between threadsComm/Synch between threads
SEMSEM Semaphores manager Semaphores manager MBXMBX Mailboxes manager Mailboxes manager LCKLCK Resource lock manager Resource lock manager
Input/OutputInput/Output
PIPPIP Data pipe manager Data pipe manager HSTHST Host input/output manager Host input/output manager SIOSIO Stream I/O manager Stream I/O manager DEVDEV Device driver interface Device driver interface
Memory and Low-level PrimitivesMemory and Low-level Primitives
MEMMEM Memory manager Memory manager SYSSYS System services manager System services manager QUEQUE Queue manager Queue manager ATMATM Atomic functions Atomic functions GBLGBL Global setting manager Global setting manager
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
Chapter 4, Slide 51
LOG ModuleLOG Module
The LOG module contains functions that can be used The LOG module contains functions that can be used to capture events in Real-Time while the target to capture events in Real-Time while the target program is running.program is running.
Functions in LOG module:Functions in LOG module:(1)(1) LOG_disable( ):LOG_disable( ): Disable the system logDisable the system log
(2)(2) LOG_enable( ):LOG_enable( ): Enable the system logEnable the system log
(3)(3) LOG_error( ):LOG_error( ): Write a user error event Write a user error event to the system logto the system log
(4)(4) LOG_event( ):LOG_event( ): Append unformatted Append unformatted message to a message logmessage to a message log
(5)(5) LOG_message( ):LOG_message( ): Write a user message to Write a user message to the system logthe system log
(6)(6) LOG_printf( ):LOG_printf( ): Append a formatted Append a formatted message to a message logmessage to a message log
(7)(7) LOG_reset( ):LOG_reset( ): Reset the system logReset the system log
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
Chapter 4, Slide 52
Moving from “printf” to the faster Moving from “printf” to the faster “LOG_printf”“LOG_printf”
How many cycles does the printf() function require?How many cycles does the printf() function require?
> 34000> 34000
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
Chapter 4, Slide 53
Moving from “printf” to the faster Moving from “printf” to the faster “LOG_printf”“LOG_printf”
(1)(1) Include the following headers in the C file:Include the following headers in the C file:
/* #include <stdio.h> NOT required *//* #include <stdio.h> NOT required */
#include <std.h>#include <std.h> /* this is required by all DSP/BIOS modules *//* this is required by all DSP/BIOS modules */
#include <log.h>#include <log.h> /* this is required by the LOG module *//* this is required by the LOG module */
(2)(2) Include the following external reference to the DSP/BIOS object in the C Include the following external reference to the DSP/BIOS object in the C code:code:
extern far LOG_Obj fastprint; /*fastprint is a user chosen name */extern far LOG_Obj fastprint; /*fastprint is a user chosen name */
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
Chapter 4, Slide 54
Moving from “printf” to the faster Moving from “printf” to the faster “LOG_printf”“LOG_printf”
(3) Create a LOG object using the configuration tool:(3) Create a LOG object using the configuration tool:
(a)(a) Open the cdb file, select instrumentation and Open the cdb file, select instrumentation and open the “LOG - Event Log Manager”.open the “LOG - Event Log Manager”.
(b)(b) Create a new object, call it “fastprint” and Create a new object, call it “fastprint” and change its properties as shown below:change its properties as shown below:
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
Chapter 4, Slide 55
Moving from “printf” to the faster Moving from “printf” to the faster “LOG_printf”“LOG_printf”
(4) Use the following code when using the LOG_printf function:(4) Use the following code when using the LOG_printf function:
/* #include <stdio.h> NOT required *//* #include <stdio.h> NOT required */
#include <std.h>#include <std.h> /* this is required by all DSP/BIOS modules *//* this is required by all DSP/BIOS modules */
#include <log.h>#include <log.h> /* this is required by the LOG module *//* this is required by the LOG module */
extern far LOG_Obj fastprint;extern far LOG_Obj fastprint;
void algorithm_1 (void)void algorithm_1 (void)
{{
LOG_printf (&fastprint, “Algorithm 1 is running\n”);LOG_printf (&fastprint, “Algorithm 1 is running\n”);
}}
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
Chapter 4, Slide 56
Moving from “printf” to the faster Moving from “printf” to the faster “LOG_printf”“LOG_printf”
(5) To visualise the output of the fastprint log you must open the Message Log window, see below:(5) To visualise the output of the fastprint log you must open the Message Log window, see below:
Note: The complete code can be found in: Note: The complete code can be found in: \Code\Chapter 04 - \Code\Chapter 04 - DSP BIOS\Bios_Lab2\DSP BIOS\Bios_Lab2\
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
Chapter 4, Slide 57
STS ModuleSTS Module
The STS module manages objects called statistics The STS module manages objects called statistics accumulators.accumulators.
Each STS object accumulates the following Each STS object accumulates the following information:information:
Count:Count: The number of valuesThe number of values Total:Total: The sum of count valuesThe sum of count values Maximum:Maximum: The longest value encounteredThe longest value encountered
Functions in the STS Module:Functions in the STS Module:(1)(1) STS_add( ):STS_add( ): Update statistics using provided valueUpdate statistics using provided value
(2)(2) STS_delta( ):STS_delta( ): Update statistics using the difference Update statistics using the difference between the provided value and the set pointbetween the provided value and the set point
(3)(3) STS_reset( ):STS_reset( ): Reset the values stored in the STS objectReset the values stored in the STS object
(4)(4) STS_set( ):STS_set( ): Save a setpoint valueSave a setpoint value
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
Chapter 4, Slide 58
Using the STS ModuleUsing the STS Module
(1)(1) Include the following headers in the C file:Include the following headers in the C file:
/* #include <stdio.h> NOT required *//* #include <stdio.h> NOT required */
#include <std.h>#include <std.h> /* this is required by all DSP/BIOS modules *//* this is required by all DSP/BIOS modules */
/* #include <sts.h> : Created by the tools */
(2)(2) Create an object with the configuration tool:Create an object with the configuration tool:
(a)(a) Open the cdb file, select “Instrumentation” and Open the cdb file, select “Instrumentation” and open the “STS - Statistics Object Manager”.open the “STS - Statistics Object Manager”.
(b)(b) Create a new object and call it “mystsObj”.Create a new object and call it “mystsObj”.
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
Chapter 4, Slide 59
Using the STS ModuleUsing the STS Module
(3)(3) You can use the following code to benchmark the printf function:You can use the following code to benchmark the printf function:
#include <stdio.h> /* Needed for the printf function */#include <stdio.h> /* Needed for the printf function */
#include <std.h>#include <std.h> /* this is required by all DSP/BIOS modules *//* this is required by all DSP/BIOS modules */
#include <sts.h>#include <sts.h>
#include <clk.h>#include <clk.h>
extern far STS_Obj mystsObj;extern far STS_Obj mystsObj;
void algorithm_1 (void)void algorithm_1 (void)
{{
STS_set (&mystsObj, CLK_gethtime());STS_set (&mystsObj, CLK_gethtime());
printf (“Algorithm 1 is running\n”);printf (“Algorithm 1 is running\n”);
STS_delta (&mystsObj, CLK_gethtime());STS_delta (&mystsObj, CLK_gethtime());
}}
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
Chapter 4, Slide 60
Moving from “printf” to the faster Moving from “printf” to the faster “LOG_printf”“LOG_printf”
(4) To visualise the statistics, open the statistics window as shown below:(4) To visualise the statistics, open the statistics window as shown below:
(5)(5) Exercise: Compare the number of cycles the printf and LOG_printf take.Exercise: Compare the number of cycles the printf and LOG_printf take.
Note: The complete code can be found in: Note: The complete code can be found in: \Code\Chapter 04 - \Code\Chapter 04 - DSP BIOS\Bios_Lab3\DSP BIOS\Bios_Lab3\
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
Chapter 4, Slide 61
Low Instrumentation OverheadLow Instrumentation OverheadLOG, STS and TRC module operations are very fast and execute in constant time, as shown in the following list:LOG, STS and TRC module operations are very fast and execute in constant time, as shown in the following list:
LOG_printf and LOG_event:LOG_printf and LOG_event: approx 32 cyclesapprox 32 cycles STS_add:STS_add: approx 18 cyclesapprox 18 cycles STS_delta:STS_delta: approx 21 cyclesapprox 21 cycles TRC_enable and TRC disable:TRC_enable and TRC disable: approx 6 cyclesapprox 6 cycles
Each STS object uses only four words of data memory. This means that the host transfers only four words to upload data from a statistics object.Each STS object uses only four words of data memory. This means that the host transfers only four words to upload data from a statistics object.
Chapter 4Chapter 4
DSP/BIOSDSP/BIOS
Part 4 - Real-Time Data ExchangePart 4 - Real-Time Data Exchange
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
Chapter 4, Slide 63
Learning ObjectivesLearning Objectives
Introduction.Introduction. Example: Send data from the target Example: Send data from the target
(DSK6711) to the host (PC).(DSK6711) to the host (PC).
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
Chapter 4, Slide 64
RTDX: Real-Time Data ExchangeRTDX: Real-Time Data ExchangePCPCTMS320 DSPTMS320 DSP
IEEEIEEEJTAGJTAG
EM
U H
/WE
MU
H/W
R T
D X
R
T D
X
US
ER
CO
DE
US
ER
CO
DE
Third PartyThird PartyDisplayDisplay
CCSCCS
DisplayDisplay UserUser TITI 3rd Party3rd Party MS COMMS COM
RTDX enables non-obtrusive two-way communication between the RTDX enables non-obtrusive two-way communication between the host PC and the DSP (host PC and the DSP (during IDLduring IDL).).
Since it runs in IDL (by default), it runs lower priority than your Since it runs in IDL (by default), it runs lower priority than your real-time code.real-time code.
RTDX is used by DSP/BIOS RTA, but it is also available directly RTDX is used by DSP/BIOS RTA, but it is also available directly to DSP programmer (useful for testing or if end-equipment is PC to DSP programmer (useful for testing or if end-equipment is PC resident).resident).
Transfer speed limited by:Transfer speed limited by: JTAG connection type (parallel, PCI, etc.).JTAG connection type (parallel, PCI, etc.). DSP activity level.DSP activity level.
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
Chapter 4, Slide 65
RTDX: Flow of DataRTDX: Flow of Data
Code Composer Studio controls the flow Code Composer Studio controls the flow of data between the host (PC) and the of data between the host (PC) and the target.target.
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
Chapter 4, Slide 66
RTDX: Example (1)RTDX: Example (1)
In this application a program is written In this application a program is written for sending data from the for sending data from the DSK6711DSK6711 to to the host.the host.
Code location:Code location:\CD ROM 2004\DSP Code 6711 Update\Chapter 04 - DSP BIOS\Bios_Lab3\CD ROM 2004\DSP Code 6711 Update\Chapter 04 - DSP BIOS\Bios_Lab3
DSK6711DSK6711bios_lab3.pjtbios_lab3.pjt
HostHosts1l1.cs1l1.c
s1l1.exes1l1.exe
HostHostTargetTarget
DSK6711DSK6711
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
Chapter 4, Slide 67
RTDX: Example (2) - Testing the CodeRTDX: Example (2) - Testing the Code
(1)(1) Connect and power up the Connect and power up the DSK.DSK.
(2)(2) Envoke CCS and load the Envoke CCS and load the program (bios_lab3.out).program (bios_lab3.out).
(3)(3) Enable the RTDX as shown Enable the RTDX as shown opposite.opposite.
(4)(4) Run the code.Run the code.
(5)(5) Run the host code “s1l1.cpp.exe” and observe the output.Run the host code “s1l1.cpp.exe” and observe the output.
The DSP C code is shown in: The DSP C code is shown in: \Links\Main3.pdf\Links\Main3.pdf
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
Chapter 4, Slide 68
FeaturesFeatures BenefitsBenefitsEasy to useEasy to use Saves development timeSaves development timeSmall Footprint (<2Kw)Small Footprint (<2Kw) Easily fits in limited memory systemsEasily fits in limited memory systemsFast Execution Fast Execution Ideal for real time systemsIdeal for real time systemsReal-Time Analysis Real-Time Analysis View system parametersView system parameters while system is executing withoutwhile system is executing without
breakpoints and without additionalbreakpoints and without additionaloverhead - “Test what you fly and flyoverhead - “Test what you fly and flywhat you test”what you test”
Set of Library FunctionsSet of Library Functions Use only what you need to minimize Use only what you need to minimize footprintfootprint
ExtensibleExtensible Full featured kernel allows additional Full featured kernel allows additional OS functions in futureOS functions in future
DSP/BIOS Feature SummaryDSP/BIOS Feature Summary
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
Chapter 4, Slide 69
DSP/BIOS SummaryDSP/BIOS Summary
At present DSP/BIOS does not support At present DSP/BIOS does not support multiprocessors.multiprocessors.
The “VSPWorks” operating system from The “VSPWorks” operating system from WindRiver Systems does support WindRiver Systems does support multiprocessing.multiprocessing. www.windriver.comwww.windriver.com
Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004
Chapter 4, Slide 70
DSP/BIOSDSP/BIOS
Code location:Code location: Code\Chapter 04_- DSP BIOS\BIOS_Lab3\bios_lab_3.pjtCode\Chapter 04_- DSP BIOS\BIOS_Lab3\bios_lab_3.pjt
Further Reading:Further Reading:(1)(1) Use the help provided with the CCS (Help also Use the help provided with the CCS (Help also
includes tutorials c:\ti\tutorial\dsk6711).includes tutorials c:\ti\tutorial\dsk6711).
(2)(2) TMS320C6000 DSP/BIOS: User Guide.TMS320C6000 DSP/BIOS: User Guide.
(3)(3) TMS320C6000 DSP/BIOS: Application Programming TMS320C6000 DSP/BIOS: Application Programming Interface (API) Interface (API) SPRU403SPRU403..
(4)(4) Application Report: DSP/BIOS II Timing Application Report: DSP/BIOS II Timing Benchmarks on the TMS320C6000 DSP Benchmarks on the TMS320C6000 DSP SPRA662SPRA662..
(5)(5) Application Report DSP/BIOS II Sizing Guidelines Application Report DSP/BIOS II Sizing Guidelines for the TMS320C62x DSP for the TMS320C62x DSP SPRA667SPRA667..
Chapter 4Chapter 4
DSP/BIOSDSP/BIOS
- End -- End -