Presentation is loading. Please wait.

Presentation is loading. Please wait.

Chapter 4 DSP/BIOS. DSP/BIOS Part 1 - Introduction.

Similar presentations


Presentation on theme: "Chapter 4 DSP/BIOS. DSP/BIOS Part 1 - Introduction."— Presentation transcript:

1 Chapter 4 DSP/BIOS

2 DSP/BIOS Part 1 - Introduction

3 Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004 Chapter 4, Slide 3 Learning Objectives  Introduce DSP/BIOS and its components.  Introduce the software tools for managing DSP/BIOS components and objects.  Run some examples.

4 Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004 Chapter 4, Slide 4DSP/BIOS  The DSP/BIOS is an operating system that can provide:  A graphical interface for static system setup.  Real-time scheduling.  Real-time analysis (RTA).  Real-time data exchange (RTDX).

5 Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004 Chapter 4, Slide 5 DSP/BIOS Components  The user writes code (‘C’/assembly) using the DSP/BIOS library.  The user can use the configuration tools to setup the system.  All the files generated constitute a project.

6 Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004 Chapter 4, Slide 6 DSP/BIOS Components  The project is then compiled, assembled and linked by the code generation tools in order to generate an executable file (*.out).  There are also some DSP/BIOS plug-ins that can be used, for instance, as program test while the target is running.

7 Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004 Chapter 4, Slide 7 DSP/BIOS Components  Code composer simulator/debugger and the host emulator support are also part of the code composer studio.  The host and target communicate through the JTAG (Joint Test Action Group) connection (ssya002c.pdf). ssya002c.pdf

8 Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004 Chapter 4, Slide 8 Graphical Interface for Static System Setup  Static system setup is performed using the DSP/BIOS GUI configuration tool.  The configuration tool has an interface similar to windows explorer.  It lets you:  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. Note: API: Application Programming Interface

9 Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004 Chapter 4, Slide 9 Graphical Interface for Static System Setup  The DSP/BIOS main objects are: (1)Hardware interrupts (HWI). (2)Software interrupts (SWI). (3)Tasks (TSK, IDL). (4)Data and I/O streams (RTDX, SIO, PIP, HST). (5)Synchronisation and Communication (SEM, MBX, LCK). (6)Timing (PRD, CLK). (7)Logging and statistics (LOG, STS, TRC). For a complete list see: \Links\SPRU303.pdf (Page 1-5). \Links\SPRU303.pdf

10 Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004 Chapter 4, Slide 10 Graphical Interface for Static System Setup  How to create a configuration file:  Open CCS and create a new project and name it “lab1.pjt”.  Create a new configuration file by using a pre- built template file: File:New:DSP/BIOS Configuration

11 Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004 Chapter 4, Slide 11 Graphical Interface for Static System Setup  How to create a configuration file:  Double click on the “dsk6711.cdb” icon and the following configuration will appear:

12 Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004 Chapter 4, Slide 12 Graphical Interface for Static System Setup  How to create a configuration file:  Now that you have selected the template, save it in your current working directory, e.g: Code\Chapter4 - DSP_BIOS\Lab1\lab1.cdb.  Finally, add the “*.cdb” configuration file to the project.

13 Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004 Chapter 4, Slide 13 Graphical Interface for Static System Setup  Files created by the configuration tools:  Once the lab1.cdb file is modified, saved and added to the project, the configuration manager will create and load the following files:  lab1cfg.s62Assembly file  lab1cfg_c.cC file  lab1cfg.hHeader file for C  lab1cfg.h62Header file for assembly  A file called “lab1cfg.cmd” is also created but must be loaded by the user. Note:the user must add the *.cdb and *.cmd files to the project.

14 Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004 Chapter 4, Slide 14 Graphical Interface for Static System Setup  Files used to create the DSP/BIOS program:  The abbreviation 62 is used for the C6000 processors. Programs generated by the user Programs/Files generated by the configuration manager

15 Chapter 4 DSP/BIOS Part 2 - Real Time Scheduling

16 Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004 Chapter 4, Slide 16 Learning Objectives  What is a real-time scheduler?  Why do we need a real-time scheduler?  DSP/BIOS Thread Types.  Example.

17 Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004 Chapter 4, Slide 17 Real-time scheduling  Before embarking into real-time scheduling let us first state the problem: main () { for (;;); }ISR1(){algorithm1();}ISR2(){algorithm2();}  Once ISR1 or 2 is called, algorithm 1 or 2 runs to completion. Can this cause a problem?

18 Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004 Chapter 4, Slide 18 Real-time scheduling  Before embarking into real-time scheduling let us first state the problem: main () { for (;;); }ISR1(){algorithm1();}ISR2(){algorithm2();}  Once ISR1 or ISR2 is called, algorithm 1 or 2 runs to completion. Can this cause a problem? There is no guarantee of meeting the real-time deadlines because: (1)The algorithms can run at different rates. (2)One algorithm can overshadow the other. (3)The timing can be non- deterministic. etc.

19 Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004 Chapter 4, Slide 19 Real-time scheduling  The answer depends on the application.  If we want to process two algorithms in real-time then we have to answer the following questions:  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).  What happens if the algorithms are not synchronised?  Which algorithm has a higher priority?  Can the algorithm of lower priority be pre-empted (stopped)?

20 Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004 Chapter 4, Slide 20 Real-time scheduling  Example: Simple application.  System description:  Algorithm 1 and 2 are not synchronised.  Assume algorithm 1 has the highest priority.  Algorithm 2 can be pended. Algorithm 1 Algorithm 2 CPU processing Algorithm 1 CPU processing Algorithm 2 MISSED!  Remember: there is only one CPU and therefore only one algorithm can be processed at a time.

21 Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004 Chapter 4, Slide 21 Real-time scheduling  Example: Simple application.  Solution 1: Algorithm decomposition:  The algorithm can be decomposed into sub- functions:  When the CPU is not processing algorithm1 it can process one of the sub-functions (to completion) as shown: algorithm2 ();function1(); function2();function3(); Algorithm 1 Algorithm 2 function1function2function3

22 Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004 Chapter 4, Slide 22 Real-time scheduling  Example: Simple application.  Problems with this solution:  Difficult to write (as timing is critical).  Difficult to change (what happens if algorithm is modified or another algorithm is added).

23 Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004 Chapter 4, Slide 23 Real-time scheduling  Example: Simple application.  Solution 2: Using an operating system Advantages:  Easy to write (algorithms are written independently).  Easy to maintain or change (operating system takes care of the scheduling).  Enables fast time to market.  Which operating system? Depends on:  The processor being used.  The DSP platform (single/multi processors).

24 Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004 Chapter 4, Slide 24 Real-time scheduling: DSP/BIOS  For all TI DSPs there is a DSP/BIOS operating system which includes:  Small sized real-time library.  An API for using the library services.  Easy-to-use configuration tools.  Real-time analysis programs.  DSP/BIOS scheduling solution provides:  Fixed-priority preemptive scheduler.  Multiple thread types.

25 Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004 Chapter 4, Slide 25 Real-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. 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. 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. 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. Process: A task or thread of execution. Scheduler: System software to manage the execution of threads. Scheduling: The planning used to share a resource. Semaphore: Synchronisation system object that enables tasks to synchronise their activities. Thread: An independent function.

26 Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004 Chapter 4, Slide 26 DSP/BIOS Thread Types Priority HWI Hardware Interrupts  HWI priorities set by hardware One ISR per interrupt. HWI triggered by hardware interrupt. IDL runs as the background thread. What causes a SWI or TSK to run? SWI Software Interrupts  14 SWI priority levels Multiple SWIs at each level. TSKTasks  15 TSK priority levels Multiple TSKs at each level. IDLBackground  Multiple IDL functions Continuous loop.

27 Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004 Chapter 4, Slide 27 Triggering SWI or TSK SWI cannot pend. SWI always returns from function. SWI start end SWI_post “run to completion” TSK only returns when no longer needed, otherwise normally an infinite loop. TSK SEM_pend start end block SEM_post

28 Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004 Chapter 4, Slide 28 Considerations in Selecting Thread Types  Thread latency and data rates.  Multi-tiered response to interrupts:  HWI is fast (for sample-by-sample response time).  SWI is slower (triggered to process frame).  Priority of thread.  Stack needs:  O.K. to share system stack? then use SWI.  Need private stack? then use TSK.  Synchronization and communication methods:  SWI and TSK have different methods.  User preference or ease-of-use.

29 Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004 Chapter 4, Slide 29 Thread Preemption Example HWI SWI 2 SWI 1 IDL main() TSK 2 TSK 1 interrupt pend sem2 return interrupt interrupt pend sem1 interrupt return return post swi1 return post swi2 return post sem2 return post swi2 return post sem1 post sem2 return pend sem2 pend sem1 Events over time

30 Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004 Chapter 4, Slide 30 Laboratory Exercise  Laboratory objectives: (1)Set the internal timer 1 to generate ticks at 8kHz. (2)Set a hardware interrupt that is triggered by internal timer 1. (3)Create a software interrupt that can be posted by the hardware interrupt. (4)Create a task that can be posted by the hardware interrupt. (5)Create a semaphore that can be used by the task functions.

31 Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004 Chapter 4, Slide 31 (1) Setting Internal Timer 1 (1)Create a new project and call it “bios_lab.pjt”. (2)Add the “dsk6711.cdb” file (see slide 10) and rename it “bios_lab2.cdb”. (3)Set a timer configuration by using the “Timer Configuration Manager” and call it “timerCfg0” and set the properties: The GUI interface will generate the “bios_labcfg.c”, see \Links\bios_labcfg.pdf \Links\bios_labcfg.pdf

32 Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004 Chapter 4, Slide 32 (2) Setting the Hardware Interrupt (1)Open the CDB file. (2)Select the “HWI - Hardware Interrupt Service …”. ( 3)Select HWI_INT15 and right click to select properties. Source = Timer_1 Function = _timerIsr

33 Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004 Chapter 4, Slide 33 (2) Setting the Hardware Interrupt (4)Write the Interrupt Service Routine in C. void timerIsr (void) { /* Put your code here */ }

34 Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004 Chapter 4, Slide 34 (3) Creating a Software Interrupt (1)Open the cdb file and select the “SWI - Software Interrupt Manager” and create a new software interrupt called “SWI_for_algorithm_1”.

35 Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004 Chapter 4, Slide 35 (3) Creating a Software Interrupt (2)Change the properties of the “SWI_for_algorithm_1” to:

36 Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004 Chapter 4, Slide 36 (3) Creating a Software Interrupt (3)Create a software interrupt function in C. void algorithm_1 (void) { /* Put your code here */ }

37 Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004 Chapter 4, Slide 37 (4) Creating a Task (1)Open the cdb file and select the “TSK - Task Manager” and create a new task called “TaskOneTsk”.

38 Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004 Chapter 4, Slide 38 (4) Creating a Task (2)Change the properties to:

39 Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004 Chapter 4, Slide 39 void ProcessTask (void) { /* Put your algorithm here */ } (4) Creating a Task (3)Create a task function in C:

40 Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004 Chapter 4, Slide 40 (5) Creating a Semaphore (1)Open the cdb file and select the “SEM - Semaphore Manager” and create a new semaphore called “taskOneSem”. (2)Change the properties of the “taskOneSem” to:

41 Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004 Chapter 4, Slide 41 Posting Software Interrupts and Tasks (1)Software Interrupts The software interrupts can be posted simply by writing: (2)Tasks The task can be removed from semaphore queue and put it on the ready queue: SWI_post (&SWI_for_algorithm_1); SEM_post (&taskOneSem);

42 Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004 Chapter 4, Slide 42 More on Tasks…  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.  A task can preempt itself, e.g: void ProcessTask (void) { while (1) { SEM_pend (&taskOneSem, SYS_FOREVER); /* Insert your code here */ }}

43 Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004 Chapter 4, Slide 43 Putting it all together… void main (void) { /* Put all your setup code here */ return; /*DSP BIOS starts after the return */ } /* Hardware Interrupt */ void timerIsr (void) { /* Put your code here */ SWI_post (&SWI_for_algorithm_1); SEM_post (&taskOneSem); } /*Software Interrupt */ void algorithm_1 (void) { /* Put your code here */ } /* Task */ void ProcessTask (void) { while (1) { SEM_pend (&taskOneSem, SYS_FOREVER); /* Insert your code here */ }}

44 Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004 Chapter 4, Slide 44 Putting it all together… void main (void) { /* Put all your setup code here */ return; /*DSP BIOS starts after the return */ } /* Hardware Interrupt */ void timerIsr (void) { /* Put your code here */ SWI_post (&SWI_for_algorithm_1); SEM_post (&taskOneSem); } /*Software Interrupt */ void algorithm_1 (void) { /* Put your code here */ } /* Task */ void ProcessTask (void) { while (1) { SEM_pend (&taskOneSem, SYS_FOREVER); /* Insert your code here */ }}


Download ppt "Chapter 4 DSP/BIOS. DSP/BIOS Part 1 - Introduction."

Similar presentations


Ads by Google