430 likes | 822 Views
Code Composer Studio & DSP/BIOS. It's Real!. It's Time!. Time To Market Performance Reliability. Integrated Develop Environment Real Time Scheduling, Debug & Analysis. Programming With DSP/BIOS. Code Composer Studio. . kernel headers. program sources. CONFIGURATION. . c .asm.
E N D
Code Composer Studio & DSP/BIOS It's Real! It's Time! Time To Market Performance Reliability Integrated Develop Environment Real Time Scheduling, Debug & Analysis
Programming With DSP/BIOS Code Composer Studio kernel headers program sources CONFIGURATION .c .asm .h BUILD .exe executable image VISUALIZATION DEBUG RTDX EMULATION SERVER JTAG HOST DEVELOPMENT COMPUTER • C- and ASM-callable functions • interactive configuration tool • kernel-aware debug support • on-the-fly program analysis kernel modules .lib target application program DSP/BIOS Kernel Interface real-time capture TARGET TMS320 DSP HARDWARE
Software Modules • DSP/BIOS™ contains a collection of modules • Each module is a coherent software package • Module viewed from two perspectives • interface — related set of constants, types, andfunctions visible to client programs • body — algorithms and data structures chosen to implement functionality of the interface
Mix-and-Match Modules SUM XXXX XXXX COUNT XXXX XXXX MAX XXXX XXXX post() get() put() streams dynamic wall-clock time allocation pend() static fast slow periodic functions messages post() 0000 RAM data port timer FFFF DSP/BIOS Kernel Interface • REAL-TIME CAPTURE • software event logs • statistics accumulators • host cmd/data channels • HARDWARE ABSTRACTION • real-time clock services • device-independent I/O • logical memory segments • MULTIPLE THREADS • HW+SW interrupts • synchronized tasks • background routines real-time host link TARGET TMS320 DSP HARDWARE
LOG - Event Log Manager • Logs reside in target memory • Fixed or circular buffer • Logs passed to host during idle • Set up with Config tool
Standard C function I/O printf Function - data collection - I/O - data format & display 5,100+ cycles (200 cycles per char) 10,400 words
DSP/BIOS I/O LOGprintf Function THREAD - data collection 28 cycles (C54x) 16 words BIOS IDLE - I/O approx 100 cycles HOST - data format & display >1,000 cycles
Mix-and-Match Modules SUM XXXX XXXX COUNT XXXX XXXX MAX XXXX XXXX post() get() put() streams dynamic wall-clock time allocation pend() static fast slow periodic functions messages post() 0000 RAM data port timer FFFF DSP/BIOS Kernel Interface • REAL-TIME CAPTURE • software event logs • statistics accumulators • host cmd/data channels • HARDWARE ABSTRACTION • real-time clock services • device-independent I/O • logical memory segments • MULTIPLE THREADS • HW+SW interrupts • synchronized tasks • background routines real-time host link TARGET TMS320 DSP HARDWARE
STS - Statistics Manager Capture Count, Maximum, and Total values for any variables in Real Time HWI, SWI, PRD, and PIP captured automatically STS statistics APIs for explicit statistics objects in your target program
Trace Manager • Real-time analysis: Turns on/off traces Use only what you need Target can start/stop acquiring data when anomaly discovered with fixed log: Store 1st n events since enabled Store last n events until disabled
Mix-and-Match Modules SUM XXXX XXXX COUNT XXXX XXXX MAX XXXX XXXX post() get() put() streams dynamic wall-clock time allocation pend() static fast slow periodic functions messages post() 0000 RAM data port timer FFFF DSP/BIOS Kernel Interface • REAL-TIME CAPTURE • software event logs • statistics accumulators • host cmd/data channels • HARDWARE ABSTRACTION • real-time clock services • device-independent I/O • logical memory segments • MULTIPLE THREADS • HW+SW interrupts • synchronized tasks • background routines real-time host link TARGET TMS320 DSP HARDWARE
HST - Host Channel Manager Real-time file I/O Audio SWI frame 1 frame 2 Host Channels PIPE buffers frame 2 frame 1 Host Computer
Mix-and-Match Modules SUM XXXX XXXX COUNT XXXX XXXX MAX XXXX XXXX post() get() put() streams dynamic wall-clock time allocation pend() static fast slow periodic functions messages post() 0000 RAM data port timer FFFF DSP/BIOS Kernel Interface • REAL-TIME CAPTURE • software event logs • statistics accumulators • host cmd/data channels • HARDWARE ABSTRACTION • real-time clock services • device-independent I/O • logical memory segments • MULTIPLE THREADS • HW+SW interrupts • synchronized tasks • background routines real-time host link TARGET TMS320 DSP HARDWARE
CLK Manager /4 ex: PRD = 49999 CPU Clock Timer Register Timer Interrupt ex: 200 MHz • Calls PRD_Tick • Calls any CLK • HWI functions • User sets • us/interrupt • Tool sets • PRD register
PRD - Periodic Function Manager • Use CLK Manager to drive PRD Timer Interrupt Call PRD_Tick Executes all ready PRDs Posts PRD_SWI Low Resolution ‘tick rate’ ex: 1 ms ex: loadPRD every 16 ms (16 ticks) or Call PRD_tick yourself
PIP - Buffered Pipe Manager Example: audio demo Writer Reader Audio SWI frame 1 frame 2 Audio in/out PIPE buffers Codec ISR frame 2 frame 1 Writer Reader
MEM - Memory Manager • Specify memory segments and locate code and data sections • DSP/BIOS generates linker.cmd file Examples:
Mix-and-Match Modules SUM XXXX XXXX COUNT XXXX XXXX MAX XXXX XXXX post() get() put() streams dynamic wall-clock time allocation pend() static fast slow periodic functions messages post() 0000 RAM data port timer FFFF DSP/BIOS Kernel Interface • REAL-TIME CAPTURE • software event logs • statistics accumulators • host cmd/data channels • HARDWARE ABSTRACTION • real-time clock services • device-independent I/O • logical memory segments • MULTIPLE THREADS • HW+SW interrupts • synchronized tasks • background routines real-time host link TARGET TMS320 DSP HARDWARE
Principal Software Requirements • Event Driven synchronous & asynchronous • Time Constrained hard & soft real time • Require Concurrency preemption multi-tasking Real Time System attributes... JWL - TISB - 2/08/00
The Historical Problem _IO_isr: ssbx intm stm #0, imr pshm st0 …. popm st0 rsbx intm rete Hardware Only Scheduling !! • Interrupts Disabled • Unmanaged Interrupt Context Switch C main background functions !! void main(void) { /* enable end–of–frame interrupt */ DMA0_SCNTL = SCNTL_ENABLE; while (*ping_rx_flag != 0) { /* ping_flag starts 1, toggles every int */ if(ping_rx_flag == 1) ping_rx_flag = 0; else ping_rx_flag = 1; } • No Guarantee of Concurrency • Non-deterministic timing • No Software Preemption • Ad Hoc Analysis
The Need for Preemption - Single Task running idle 4 5 6 7 A running B idle Headroom CPU Usage Time Task A 100% Max 100% 0 1 2 3 Task B -- Actual 50% Task A: period 2 ms, compute 1 ms (50%) DR - TISB - 1/24/00
Cyclic Scheduling - Two Tasks running idle 1 2 3 4 5 6 7 A running B idle Headroom CPU Usage Time Task A 0% Max 57% 0 Task B 0% Actual 57% Task A: period 2 ms, compute 1 ms (50%) Task B: period 30 ms, compute 2 ms (6.67%) DR - TISB - 1/24/00
Preemptive Scheduling - Two Tasks running idle 4 5 6 7 A running B idle Headroom CPU Usage Time Task A 87% Max 100% 0 1 1 2 2 3 3 Task B 650% Actual 57% Task A: period 2 ms, compute 1 ms (50%) Task B: period 30 ms, compute 2 ms (6.67%) DR - TISB - 1/24/00
The DSP/BIOS Solution Foreground Level Scheduling !! _IO_isr: HWI_enter pshm st0 pshm st1 …. popm st1 popm st0 HWI_exit HW Interrupt Scheduling SW Interrupt Scheduling predictable thread control Real Time Analysis low overhead logging and statistics void main(void) { /* enable end–of–frame interrupt */ DMA0_SCNTL = SCNTL_ENABLE; /* post SW interrupt swiProcessBuffer */ SWI_post(&swiProcessBuffer); /* ping_flag starts 1, toggles every int */ if(ping_rx_flag == 1) ping_rx_flag = 0; else ping_rx_flag = 1; LOG_printf (&message, “Buffer 1 Avail”); • Managed Context Switch • Preemptive SW Scheduling • Time Determinism • Very Low Overhead
Real-time Multi-threaded Systems Fundamental mechanism needed for an application to control and react to multiple, discrete real world events to produce a correct result within a specified time Independent Control Traditional Super-loop (Cyclically Scheduled) • Multi-thread Approach: • shoulder() { • for(;;) { • wait for event; • moveshoulder() • } • wrist() { • for(;;) { • wait for event; • movewrist() • } • Single-thread Approach: • arm() { • for (;;) { • if (shoulder needs moving) • moveshoulder(); • if (wrist needs moving) • movewrist(); • .....
Cyclically Scheduled Systems Are Problematic CPU Load? Time-Out? INTs INTs fxn 4 fxn 3 fxn 2 fxn 1 main() Time ... hence the need for preemptiveReal Time Scheduling
Thread Scheduling - HWI & Idle/ Background INT 5 INT 4 INT 3 INT 2 INT 1 main() idle Time JWL - TISB - 2/4/00
HWI - Hardware ISR Manager • Respond to external asynchronous events • HWIs run uninterrupted to completion • If posted multiple times, runs only once • Need to minimize time and code in Interrupt Service Routine • Move large processing needs by posting a SWI • HWI time is ‘Other Threads’ on Execution Graph • Set up with Config Tool
Priority Based Scheduling - DSP/BIOS Run Post Ready (post) Run HWIs Preempted SWI 4 SWI 3 SWI 2 SWI 1 main () idle Time JWL - TISB - 1/24/00
DSP/BIOS - Round Robin & Periodic Examples INT 1 Round robin Scheduling SWI 5 SWI 3 SWI 4 Priority based Scheduling SWI 2 Periodic Scheduling SWI 1 main () idle Time
DSP/BIOS - SW Interrupt Scheduling INT 1 SWI 5 SWI 3 SWI 4 SWI 2 SWI 1 • DSP/BIOS Software Interrupt threads use an ‘Interrupt Service’ scheduling model. • DSP/BIOS SWI threads are preemptable, and run to completion. • DSP/BIOS SWI threads cannot be suspended (blocked) and therefore must have required resources ready before they run. • DSP/BIOS SWI threads are an excellent scheduling mechanism for very low overhead, deterministic, ‘Hard Real Time’ systems. JWL - TISB - 2/08/00
DSP/BIOS II - Beyond SW Interrupts _IO_isr: ssbx intm stm #0, imr pshm st0 …. popm st0 rsbx intm rete What if our new design requires concurrent real time operation? But there is... void main(void) { /* enable end–of–frame interrupt */ DMA0_SCNTL = SCNTL_ENABLE; /* post SW interrupt swiProcessBuffer */ SWI_post(&swiProcessBuffer); /* ping_flag starts 1, toggles every int */ if(ping_rx_flag == 1) ping_rx_flag = 0; else ping_rx_flag = 1; LOG_printf (&message, “Buffer 1 Avail”); • A need for Dynamic Prioritization • No Guarantee of Resource Availability JWL - TISB - 2/08/00
The DSP/BIOS II Solution Then we need Synchronized Task Scheduling !! (Multi-Tasking) (SPOX) _IO_isr: HWI_enter pshm st0 pshm st1 …. popm st1 popm st0 HWI_exit HW Interrupt Scheduling SW Interrupt Scheduling TASK Scheduling blocking semaphores dynamic prioritization dynamic creation & termination Real Time Analysis low overhead log & statistics Void main() {TSK_create((ProcessBuffer)task,1); } /* ======== task ======== */ Void task(Int id) { SEM_pend(ping_rx_flag = 1); } LOG_printf(&trace, ”Buffer 1 Avail"); } • RTOS style Concurrency • Dynamic Scheduling • Dynamic Resource Sharing • Low Overhead JWL - TISB - 2/08/00
DSP/BIOS II Task Scheduling Ready (post) Run INT 1 Preempted Blocked SWI 1 blocked Terminated TSK 2 TSK 1 preempted idle • DSP/BIOS II adds “Multi-Tasking” scheduling to the “Interrupt Service” scheduling model. • DSP/BIOS Tasks are dynamic, preemptable, and can be suspended (blocked) to wait for data or other tasks. • DSP/BIOS Tasks are an excellent scheduling mechanism for dynamic, shared resource, ‘Hard & Soft Real Time’ systems.
IDL - Idle Function Manager Program • Insert functions to execute within idle • Lowest priority SWI thread • Set up with Config Tool • Continuous loop - round robin • Real-time analysis plug-ins updated DSP BIOS API H/W Interrupts SWI • Background • Host data pump • Idle CPU load • Your function C main ()
Real-Time Analysis • Determine whether the system is: Operating within its design specifications Meeting its performance targets Showing any subtle timing problems • Analyze real-time operation: Software logic analyzer CPU load Thread timing and count statistics
How do I ‘BIOS-ize’ my Code? • Start a new project • Set up objects with Configuration Tool • Migrate interrupt vector table to the HWI module • Migrate memory sections from linker.cmd file to MEM module • Save and Add the .cdb file to your project • Edit C source for #include headers and declare variables • Change C functions within your program • to DSP/BIOS APIs. • Build the new project Also… try the CC Studio Tutorial examples …and study the DSP/BIOS by Degrees app note - SPRA591 … also Audio Example - DSP/BIOS app note - SPRA598
Starting New Projects C New Project (xxx.mak) Add source files Add linker command file Add Run-Time library BIOS New Project (xxx.mak) Setup new configuration Add configuration file (xxx.cbd) Add source files Add linker command file
Set Up System Easily with Configuration tool • Easy to visually configure run-time objects • Set global run-time parameters • Statically configures objects • Detect errors early by validating • properties before execution • Calculate estimated data and minimal • stack size • Minimize target memory footprint by • eliminating run-time code • Saves time by getting you started quickly • Adds basic Run Time services • Add interrupt vector definitions • Add memory section definitions • Optionally add thread scheduling • Optionally add low overhead instrumentation objects • Visually create run-time objects bound to the executable program
Summary - DSP/BIOS Modules Where do these fit? RT Capture, H/W Abstraction, or Multiple Threads • ATM - Atomic Functions • CLK - Clock Manager • DEV - Device Driver Interface • GBL - Global Properties • HST - Host Channel Manager • HWI - HW Interrupt Manager • IDL - Idle Manager • LCK - Resource Lock Manager • LOG - Log Event Manager • MBX - Mailbox Manager • MEM - Memory Manager • PIP - Pipe Manager • PRD - Periodic Function Manager • QUE - Queue Function Manager • RTDX - Real Time Data Exchange • SEM - Semaphores • SIO - Stream I/O • STS - Statistics Accumulator • SWI - SW Interrupt Manager • SYS - System Services • TRC - Trace State • TSK - Multi-Tasking
Sales and Support Where will customers go for support on Code Composer Studio? TI Product Information Center Recommended literature & source info? Code Composer Studio demo, tutorial, & docs: http://www.ti.com/sc/docs/tools Get your own copy! 30 Day free Software Trial Code Composer Studio 1.11 release CD Order through the TI Web or your local Distribution Representative