Presentation is loading. Please wait.

Presentation is loading. Please wait.

DSP C5000 Chapter 7 DSP BIOS Copyright © 2003 Texas Instruments. All rights reserved.

Similar presentations


Presentation on theme: "DSP C5000 Chapter 7 DSP BIOS Copyright © 2003 Texas Instruments. All rights reserved."— Presentation transcript:

1 DSP C5000 Chapter 7 DSP BIOS Copyright © 2003 Texas Instruments. All rights reserved.

2 ESIEE, Slide 2 Copyright © 2003 Texas Instruments. All rights reserved. Real-time scheduler Real-time scheduler Real-time scheduler Real-time scheduler Preemptive thread management kernel Real-time analysis tools Real-time analysis tools Real-time analysis tools Real-time analysis tools Allows application to run uninterrupted while displaying debug data Real-time data exchange (RTDX) Real-time data exchange (RTDX) Real-time data exchange (RTDX) Real-time data exchange (RTDX) Allows two-way communication (target host) while target is running Programming of DSP peripherals Programming of DSP peripherals Programming of DSP peripherals Programming of DSP peripherals Graphical input to peripheral initialization through Chip Support Library (CSL) DSP BIOS Offers the Following:

3 ESIEE, Slide 3 Copyright © 2003 Texas Instruments. All rights reserved. DSP/BIOS Configuration Tool Configures System Configures System Creates and defines objects (ex. IDL) Creates and defines objects (ex. IDL) Configure hardware interrupts and creates interrupt vectors Configure hardware interrupts and creates interrupt vectors Configures memory and creates linker command file Configures memory and creates linker command file Calculates estimated data and minimum stack size needed Calculates estimated data and minimum stack size needed Creating a New Configuration File

4 ESIEE, Slide 4 Copyright © 2003 Texas Instruments. All rights reserved. Files Generated by the Configuration Tool program.cdb programcfg.h## programcfg.s## programcfg.cmd Configuration database file Save Allocated at link time programcfg_c.c programcfg.h

5 ESIEE, Slide 5 Copyright © 2003 Texas Instruments. All rights reserved. File Extensions prog.c Compiler/Assembler progcfg.h##progcfg.s##progcfg.cmd prog.hprog.cmd(optional) progcfg.obj mod.h Linker prog.asm prog.obj prog.cdb user.lib *.lib prog.out

6 ESIEE, Slide 6 Copyright © 2003 Texas Instruments. All rights reserved. Startup Sequence interrupt enable bits OFF other initialization BIOS_reset() interrupt flag bits OFF vector table pointer initialized BIOS_init() do hardware initialization enable individual interrupts returnmain() HWI_startup() enables HWI start DSP/BIOS scheduler BIOS_start() interrupt enables interrupt flags global int enable IMR IFR INTMC5000 system code user code

7 ESIEE, Slide 7 Copyright © 2003 Texas Instruments. All rights reserved. Startup Sequence Initialize the DSP and the hardware Initialize the DSP and the hardware The software stack pointer, memory wait states, memory configuration registers The software stack pointer, memory wait states, memory configuration registers This is part of the boot.c file that is part of the DSP/BIOS library This is part of the boot.c file that is part of the DSP/BIOS library BIOS_init( ) is called automatically BIOS_init( ) is called automatically Initializes DSP/BIOS modules Initializes DSP/BIOS modules main() main() System initialization that needs to be performed System initialization that needs to be performed Enable selected interrupts before interrupts are enabled globally Enable selected interrupts before interrupts are enabled globally Must return to complete the program initialization!!!! Must return to complete the program initialization!!!! BIOS_start( ) is called automatically BIOS_start( ) is called automatically Start DSP/BIOS Start DSP/BIOS Enables interrupts globally Enables interrupts globally Drops into the DSP/BIOS background loop Drops into the DSP/BIOS background loop Initializes communication with the host for real-time analysis Initializes communication with the host for real-time analysis

8 ESIEE, Slide 8 Copyright © 2003 Texas Instruments. All rights reserved. Real-time Systems Systems that respond in a correct and timely way to events Systems that respond in a correct and timely way to events Events are occurrences that cause a non- sequential change in the software flow of control Events are occurrences that cause a non- sequential change in the software flow of control Driven by hardware and software events Driven by hardware and software events Interrupt signals Interrupt signals IF-THEN and CASE statements IF-THEN and CASE statements Real-time System inputsoutputs

9 ESIEE, Slide 9 Copyright © 2003 Texas Instruments. All rights reserved. Real-time Systems attributes Events driven: Events driven: Synchronous (end of internal timer counting). Synchronous (end of internal timer counting). Asynchronous (ADC or DAC interrupt). Asynchronous (ADC or DAC interrupt). Time constrained: Time constrained: Hard (Critical deadlines, catastrophic). Hard (Critical deadlines, catastrophic). Soft (Non-critical deadlines, non-catastrophic). Soft (Non-critical deadlines, non-catastrophic). Concurrency: Concurrency: Processing more than one event apparently simultaneously to meet deadlines Processing more than one event apparently simultaneously to meet deadlines Means: Preemption & multi-tasking. Means: Preemption & multi-tasking. Deterministic & reliable: Deterministic & reliable: Will always have the same behaviour within a known response time. Will always have the same behaviour within a known response time.

10 ESIEE, Slide 10 Copyright © 2003 Texas Instruments. All rights reserved. Audio Example For this system to function properly, the filter needs to calculate the correct output before the next sample arrives For this system to function properly, the filter needs to calculate the correct output before the next sample arrives What events drive this system? What events drive this system? Receive and Transmit Interrupts Receive and Transmit Interrupts Asynchronous Event - could happen at different points in code Asynchronous Event - could happen at different points in code Polling of Receive and Transmit conditions Polling of Receive and Transmit conditions Synchronous Event - always happens at the same place in code Synchronous Event - always happens at the same place in code Audio Filter SampleSample

11 ESIEE, Slide 11 Copyright © 2003 Texas Instruments. All rights reserved. TI DSP Real-time System Requirements Filter Arunningidle Time PeriodComputeCPU Usage Routine A:22 s11 s(50%) Period = 1/f s Deadline!

12 ESIEE, Slide 12 Copyright © 2003 Texas Instruments. All rights reserved. TI DSP Adding new function (new task) DTMF Filter Previous Requirement DSP filters audio signal DSP filters audio signal New Requirement Add DTMF function Add DTMF function DTMF is independent of filter DTMF is independent of filter Issues: Issues: Do we have enough bandwidth (MIPS)? Do we have enough bandwidth (MIPS)? Will one routine conflict with the other? Will one routine conflict with the other? How do we create the compound system? How do we create the compound system?

13 ESIEE, Slide 13 Copyright © 2003 Texas Instruments. All rights reserved. System Implementation Considerations DTMF Filter main{while(1){}} One method: put each algo into an endless loop under main One method: put each algo into an endless loop under main Problems: Problems: What if algorithms run at differing rates? (eg: our filter runs ~ 44 KHz and the DTMF algo ~ 8 KHz) What if algorithms run at differing rates? (eg: our filter runs ~ 44 KHz and the DTMF algo ~ 8 KHz) What if one algorithm overshadows another, starving it for recognition or delaying its response beyond the limits of the system? What if one algorithm overshadows another, starving it for recognition or delaying its response beyond the limits of the system?

14 ESIEE, Slide 14 Copyright © 2003 Texas Instruments. All rights reserved. TI DSP Interrupt Driven System - Problem PeriodComputeCPU Usage Routine A:22 s11 s(50%) Routine B:125 s33 s(26%) 76%Time B A running idle y1y1y1y1 y2y2y2y2 y3y3y3y3 y4y4y4y4 Missed ! main{while(1);}Timer1_ISR{}Timer2_ISR{} B A There are two elements of CPU loading: average & instantaneous Only one can run at a time...

15 ESIEE, Slide 15 Copyright © 2003 Texas Instruments. All rights reserved. A running idle Time DSP/BIOS Scheduling B A main{return;}Timer1_ISR{ start A; start A;}Timer2_ISR{ start B; start B;} B DSP/BIOS provides scheduling: Tasks are marked to be run by event processing or other task. Tasks are marked to be run by event processing or other task. Scheduler supervises task running depending on status (mark to be run), priority, … Scheduler supervises task running depending on status (mark to be run), priority, … Modules written independently Easier to maintain - Module interaction minimized Built-in Scheduling - Managed by DSP/BIOS DSP/BIOS DSP/BIOS B suspended

16 ESIEE, Slide 16 Copyright © 2003 Texas Instruments. All rights reserved. DSP/BIOS Preemptive Scheduler Hardware Interrupts Software Interrupts Idle Foreground Background Hard Real-time Soft Real-time 2nd-TIER RESPONSE Frame-by-frame processing Frame-by-frame processing Millisecond duty cycles Millisecond duty cycles 2nd-TIER RESPONSE Frame-by-frame processing Frame-by-frame processing Millisecond duty cycles Millisecond duty cycles 1st-TIER RESPONSE Sample-by-sample processing Sample-by-sample processing Microsecond duty cycles Microsecond duty cycles 1st-TIER RESPONSE Sample-by-sample processing Sample-by-sample processing Microsecond duty cycles Microsecond duty cycles Best Effort

17 ESIEE, Slide 17 Copyright © 2003 Texas Instruments. All rights reserved.Preemption The act of changing the flow of control from one process to another based on priority The act of changing the flow of control from one process to another based on priority Higher priority always runs Higher priority always runs Allows one process to asynchronously interrupt the execution of the currently executing process Allows one process to asynchronously interrupt the execution of the currently executing process Concurrent processing Concurrent processing PreemptedCompletedPosted Started InactiveReady Running Resume

18 ESIEE, Slide 18 Copyright © 2003 Texas Instruments. All rights reserved. DSP BIOS Scheduler Fast response to interrupts Fast response to interrupts Minimal context switching Minimal context switching High priority for CPU High priority for CPU Can post SWI Can post SWI Danger of missing an interrupt while executing ISR Danger of missing an interrupt while executing ISR Latency in response time Latency in response time Context switch performed Context switch performed Selectable priority levels Selectable priority levels Can post another SWI Can post another SWI Execution managed by scheduler Execution managed by scheduler DMAC2 INT HWI_enter h/w real-time code Post s/w interrupt (SWI) HWI_exit SWI: filter code SWI Pending The Scheduler provides both h/w and s/w interrupt management The Scheduler provides both h/w and s/w interrupt management HWI SWI Lets look at a scheduling example...

19 ESIEE, Slide 19 Copyright © 2003 Texas Instruments. All rights reserved. Priority Based Thread Scheduling HWI 2 HWI 1 SWI 3 SWI 2 SWI 1 MAINIDLE int1 rtn post2rtn int2 post3rtn post1 rtn rtn rtn User sets the priority...BIOS does the scheduling subroutine subroutine ISR ISR function function A thread may be a: How do you set the priorities ? (highest) (lowest)

20 ESIEE, Slide 20 Copyright © 2003 Texas Instruments. All rights reserved. Interrupts that Post SWI isrisr p = 2 p = 1 IdleIdle Use HWI_enter and HWI_exit assembly macros Use HWI_enter and HWI_exit assembly macros APIs that may affect scheduling: APIs that may affect scheduling: SWI_andn, SWI_dec, SWI_inc, SWI_or, SWI_post, PIP_alloc, PIP_free, PIP_get, PIP_put, PRD_tick, SEM_post time Running Ready post HWI_exitHWI_enter

21 ESIEE, Slide 21 Copyright © 2003 Texas Instruments. All rights reserved. HWI_enter and HWI_exit HWI_enter HWI_enter Saves selected registers Saves selected registers Sets interrupt mask to disable/enable nested interrupts Sets interrupt mask to disable/enable nested interrupts Informs scheduler to delay running newly posted SWI Informs scheduler to delay running newly posted SWI HWI_exit HWI_exit Restores selected registers Restores selected registers Restores interrupt mask Restores interrupt mask Returns from interrupt Returns from interrupt These APIs can only be called from assembly.

22 ESIEE, Slide 22 Copyright © 2003 Texas Instruments. All rights reserved. Writing an ISR in Assembly (C54x).def isr1.def isr1isr1: ;save context (PUSHM) ;save context (PUSHM) ;ISR code ;ISR code ;restore context (POPM) ;restore context (POPM) ;return from interrupt ;return from interrupt Template ISR with no scheduling APIs called.include hwi.h54.include hwi.h54.include swi.h54.include swi.h54.def isr1.def isr1isr1: HWI_enter MASK,IMRDISABLEMASK HWI_enter MASK,IMRDISABLEMASK SWI_post SWI_post ;other ISR code ;other ISR code HWI_exit MASKS,IMRRESTOREMASK HWI_exit MASKS,IMRRESTOREMASK SWI_post example Pros/Cons of HWI_enter and HWI_exit Pros/Cons of HWI_enter and HWI_exit Easy way to save/restore registers Easy way to save/restore registers Able to call scheduling APIs Able to call scheduling APIs Allows for nested interrupts (preemption) Allows for nested interrupts (preemption) Execution overhead Execution overhead Callable only from Assembly Callable only from Assembly

23 ESIEE, Slide 23 Copyright © 2003 Texas Instruments. All rights reserved. HWI_enter and HWI_exit (C54x) MASK - registers to save/restore IMRDISABLEMASK, IMRRESTOREMASK - IMR bits to mask (1s) or restore (1s) HWI_enter MASK IMRDISABLEMASK HWI_exit MASK IMRRESTOREMASK.include c54.h54 ; mask constants.include hwi.h54 ; HWI module definitions HWI_enter C54_A|C54_B,0x0008 Saves the A and B accumulators, disables TINT0, all other INTs nested Saves the A and B accumulators, disables TINT0, all other INTs nested HWI_enter C54_CNOTPRESERVED,0xFFFF Saves C Save on Call registers, disables all nested interrupts Saves C Save on Call registers, disables all nested interrupts

24 ESIEE, Slide 24 Copyright © 2003 Texas Instruments. All rights reserved. Hardware Interrupt Dispatcher Automatically includes HWI_enter and exit via a stub function Automatically includes HWI_enter and exit via a stub function Can be used with ISRs written in C Can be used with ISRs written in C

25 ESIEE, Slide 25 Copyright © 2003 Texas Instruments. All rights reserved. Int i; /*global var*/ {HWI_enter(MASKS) i++; i++; SWI_post(&swiAudio) SWI_post(&swiAudio)HWI_exit(MASKS)} void isr1(void) Writing an ISR in C ISR can be purely in C if no scheduling APIs are called ISR can be purely in C if no scheduling APIs are called Declare as interrupt void isr1(void) Declare as interrupt void isr1(void) Dont use interrupt keyword if calling with HWI_enter and HWI_exit ISR! Dont use interrupt keyword if calling with HWI_enter and HWI_exit ISR! HWI_exit does a return from interrupt HWI_exit does a return from interrupt

26 ESIEE, Slide 26 Copyright © 2003 Texas Instruments. All rights reserved. HARDWARE INTERRUPT IDLE minpri maxpri 15 XXXX DSP/BIOS (SWI) Software Interrupts Defer hardware interrupt service routines to software interrupts Defer hardware interrupt service routines to software interrupts Preemptive Preemptive Priority 0-14 Priority 0-14 Context Switch Context Switch Automatic for SWI Automatic for SWI Single stack model (Application Stack) Single stack model (Application Stack) Adding priority levels will increase stack size requirements Adding priority levels will increase stack size requirements

27 ESIEE, Slide 27 Copyright © 2003 Texas Instruments. All rights reserved. fxn arg0 arg1 priority mailbox fxn arg0 arg1 priority mailbox fxn arg0 arg1 priority mailbox FIR FFT C func ASM func SWI_obj SWI_obj SWI_obj Common.stack Software Interrupt Objects SWI_Obj (example) SWI_Obj (example) Pointer to a function Pointer to a function Arg0 and Arg1 Arg0 and Arg1 Priority Priority Initial Bit/Count value Initial Bit/Count value Will cover later Will cover later All interrupts run on a common stack All interrupts run on a common stack Stores local variables Stores local variables Nested function calls Nested function calls

28 ESIEE, Slide 28 Copyright © 2003 Texas Instruments. All rights reserved. Scheduling Rules and SWI API isrisr p = 1 IdleIdle p = 2 time Highest Priority Lowest Priority Running Ready post post SWI_post() SWI_post() Unconditionally post a software interrupt Unconditionally post a software interrupt Software interrupt is posted in the ready state Software interrupt is posted in the ready state

29 ESIEE, Slide 29 Copyright © 2003 Texas Instruments. All rights reserved. DSP/BIOS Software Interrupt Mailbox Used to conditionally or unconditionally post software interrupt Used to conditionally or unconditionally post software interrupt Can be used as a counter or a bit field Can be used as a counter or a bit field Set a bit to notify how SWI was posted Set a bit to notify how SWI was posted Allows multiple conditions to be met before a SWI can run Allows multiple conditions to be met before a SWI can run Allows to monitor missed SWI Allows to monitor missed SWI Mailbox is an int value (16 bits for C5000) Mailbox is an int value (16 bits for C5000) SWI_inc increments the mailbox and posts SWI C SWI_inc increments the mailbox and posts SWI C The Mailbox is reset when SWI C runs The Mailbox is reset when SWI C runs Use SWI_getmbox() to get previous mailbox value Use SWI_getmbox() to get previous mailbox value (must be 1)

30 ESIEE, Slide 30 Copyright © 2003 Texas Instruments. All rights reserved. Calling DSP/BIOS API from Assembly (C54x).include swi.h54 ; SWI module definitions ; Setup preconditions and save context stm _swiAudio,ar2 ; argument to SWI_post SWI_post ret ; return Example: Void SWI_post(SWI_Obj *swi); Example: Void SWI_post(SWI_Obj *swi); Preconditions: cpl = ovm = c16 = frct = cmpt = 0 dp = GBL_A_SYSPAGE ar2 = address of SWI Object intm = 0 (if outside an ISR) Preconditions: cpl = ovm = c16 = frct = cmpt = 0 dp = GBL_A_SYSPAGE ar2 = address of SWI Object intm = 0 (if outside an ISR) Post conditions: none Post conditions: none Modifies: ag, ah, al, ar0, ar2, ar3, ar4, ar5, bg, bh, bl, c, dp, t, tc Modifies: ag, ah, al, ar0, ar2, ar3, ar4, ar5, bg, bh, bl, c, dp, t, tc

31 ESIEE, Slide 31 Copyright © 2003 Texas Instruments. All rights reserved. Counting Events: SWI_dec() HWI SPBuffer SWI_dec(&SWI) SWI B SWI_dec() decrements the mailbox value SWI_dec() decrements the mailbox value SWI is posted if mailbox = 0 SWI is posted if mailbox = 0 Set the initial mailbox value in the SWIs properties Set the initial mailbox value in the SWIs properties Mailbox is resets to initial value when SWI runs Mailbox is resets to initial value when SWI runs 11Mailbox

32 ESIEE, Slide 32 Copyright © 2003 Texas Instruments. All rights reserved. Who Called: SWI_or SWI A SWI B SWI C SWI D SWI SUB switch(mailbox) {case 1: {do this} case 2: {do this} case 4: {do this} case 8: {do this}} SWI_or() sets a bit in the mailbox and posts the SWI SWI_or() sets a bit in the mailbox and posts the SWI Use SWI_getmbox() to read the mailbox and determine which routine posted the instance of the SWI Use SWI_getmbox() to read the mailbox and determine which routine posted the instance of the SWI Mailbox is reset when SWI runs Mailbox is reset when SWI runs SWI_or(1) SWI_or(2) SWI_or(4) SWI_or(8) Int mailbox; mailbox = SWI_getmbox();

33 ESIEE, Slide 33 Copyright © 2003 Texas Instruments. All rights reserved. Handling Conditions: SWI_andn Adaptive Filter swiGetData swiAdapt swiFilter Mailbox 11 SWI_andn(1)0 SWI_andn(2) 0 Note: SWI_andn => mailbox AND ( NOT MASK ) SWI_andn() clears a bit in the mailbox value SWI_andn() clears a bit in the mailbox value SWI is posted if mailbox = 0 SWI is posted if mailbox = 0 Set the initial mailbox value in the SWIs properties Set the initial mailbox value in the SWIs properties Mailbox is resets to initial value when SWI runs Mailbox is resets to initial value when SWI runs

34 ESIEE, Slide 34 Copyright © 2003 Texas Instruments. All rights reserved. Posting SWIs - A Summary Always post SWI_orSWI_inc Post if mailbox = 0 SWI_andnSWI_dec SWI_post Mailbox is a bitmask Mailbox is a counter N/A Use SWI_getmbox() to read the mailbox Use SWI_getmbox() to read the mailbox Set initial value of the mailbox in the SWIs properties Set initial value of the mailbox in the SWIs properties Mailbox is reset when SWI runs Mailbox is reset when SWI runs

35 ESIEE, Slide 35 Copyright © 2003 Texas Instruments. All rights reserved. Clock Manager Timer Services CPU clock rate 4 Hi-res Clock N Low-res Clock max clock rate timer counter timer period System Tick interrupt The Clock Manager configures: The Clock Manager configures: Period of the system tick - Timer Period Period of the system tick - Timer Period Functions that run as part of the timer ISR - CLK_Objects Functions that run as part of the timer ISR - CLK_Objects DSP/BIOS configures a CLK Object, PRD_clock, to manage DSP/BIOS configures a CLK Object, PRD_clock, to manage A low and a high resolution time stamp A low and a high resolution time stamp Periodic Functions Periodic Functions

36 ESIEE, Slide 36 Copyright © 2003 Texas Instruments. All rights reserved. f1(t)P1P2 P3 P4 f2(t) f3(t) f4(t) Timer Interrupt DSP/BIOSPRD_tick() PRD_clock PRD_swi / P Periodic Function Manager PRD_clock will conditionally trigger the DSP/BIOS central dispatcher via PRD_tick PRD_clock will conditionally trigger the DSP/BIOS central dispatcher via PRD_tick DSP/BIOS central dispatcher runs a software interrupt called PRD_swi DSP/BIOS central dispatcher runs a software interrupt called PRD_swi PRD_swi contains a list of periodic processes in a table PRD_swi contains a list of periodic processes in a table PRD_swi will select the periodic functions to run based on the period PRD_swi will select the periodic functions to run based on the period Run at the same priority - FIFO Run at the same priority - FIFO

37 ESIEE, Slide 37 Copyright © 2003 Texas Instruments. All rights reserved. Periodic Objects Period is the # of system ticks in which objects function will run Period is the # of system ticks in which objects function will run Function is the routine you want to executed Function is the routine you want to executed Type defines the nature of the periodic function Type defines the nature of the periodic function Continuous vs. One-shot Continuous vs. One-shot Timer Interrupt DSP/BIOSPRD_tick() PRD_swi / P PRD_clock prdFunc1 Period4 Functionfunc1() Typecontinuous prdFunc2 Period9 Functionfunc2() Typecontinuous

38 ESIEE, Slide 38 Copyright © 2003 Texas Instruments. All rights reserved. Continuous Periodic Functions Call the function every N ticks Call the function every N ticks Triggered by the system tick Triggered by the system tick Timer interrupt or Timer interrupt or Periodic interrupt that calls PRD_tick() Periodic interrupt that calls PRD_tick() func1() tick func1()func2() prdFunc1 Period4 Functionfunc1() Typecontinuous prdFunc2 Period9 Functionfunc2() Typecontinuous Execution timeline

39 ESIEE, Slide 39 Copyright © 2003 Texas Instruments. All rights reserved. Communication Techniques Global variables Global variables Can corrupt global data while preempted Can corrupt global data while preempted Queues (linked list) Queues (linked list) Useful for first-in, first-out sequencing Useful for first-in, first-out sequencing Buffering of data using shared memory Buffering of data using shared memory Time-relative buffering Time-relative buffering Useful for time-relative data transferred or for slow data Useful for time-relative data transferred or for slow data Double or ping-pong buffering Double or ping-pong buffering Ring or circular buffering Ring or circular buffering Use queues to pass pointers to arrays of data buffers in memory Use queues to pass pointers to arrays of data buffers in memory Process 0 Process 1

40 ESIEE, Slide 40 Copyright © 2003 Texas Instruments. All rights reserved.Queue Simple data structure for basic communication Simple data structure for basic communication Useful for first-in, first-out processing Useful for first-in, first-out processing Manages a linked list of elements Manages a linked list of elements Includes atomic and non-atomic APIs Includes atomic and non-atomic APIs Allows insertion and deletion anywhere in the Queue Allows insertion and deletion anywhere in the Queue Elements can be any data structure Elements can be any data structure Must include QUE_Elem Must include QUE_Elem

41 ESIEE, Slide 41 Copyright © 2003 Texas Instruments. All rights reserved. Data Pipes I/O building blocks between processes (and interrupts) I/O building blocks between processes (and interrupts) A pipe object has 2 sides - writer and reader A pipe object has 2 sides - writer and reader Built-in notify functions are used to synchronize Built-in notify functions are used to synchronize Queued data buffers are allocated at link time Queued data buffers are allocated at link time Divided into a fixed number of frames of a particular size Divided into a fixed number of frames of a particular size nframes nframes framesize framesize Software Interrupt PIP buffers Software Interrupt

42 ESIEE, Slide 42 Copyright © 2003 Texas Instruments. All rights reserved.Multitasking Hardware Interrupts Software Interrupts Multitasking Idle Foreground Background Hard Real-time Soft Real-time

43 ESIEE, Slide 43 Copyright © 2003 Texas Instruments. All rights reserved. READY RUNNING BLOCKED TERMINATED Task suspendsTask exits Task is readied Task is deleted Preemption Task Control Block Model TSK_exit() TSK_delete() TSK_sleep() TSK_tick() TSK_delete() TSK_yield() DSP/BIOS Startup SEM_post() SEM_pend() TSK_setpri()

44 ESIEE, Slide 44 Copyright © 2003 Texas Instruments. All rights reserved. Not dependent on A Semaphores and Priority BB AA Both B and C depend on A Both B and C depend on A B pends on the semaphore first, then C B pends on the semaphore first, then C When A posts, B runs first because it pended first When A posts, B runs first because it pended first Semaphores use a FIFO Queue for pending tasks! Semaphores use a FIFO Queue for pending tasks! SEM_ pend(semObj) block! SEM_post (semObj) preempted! preempted! Precondition for B and C Depends on A Priority=1 Priority=1 time CC SEM_ pend(semObj) block! Priority=2 interrupt

45 ESIEE, Slide 45 Copyright © 2003 Texas Instruments. All rights reserved. MBX_postMBX_pend task0 task1 task2 task3 task4 Mailbox API MBX_post MBX_post Copies a message into a buffer Copies a message into a buffer Block if mailbox is full or if another writer is waiting Block if mailbox is full or if another writer is waiting MBX_pend MBX_pend Copies a message out of a buffer Copies a message out of a buffer Block if mailbox is empty or if another reader is waiting Block if mailbox is empty or if another reader is waiting

46 ESIEE, Slide 46 Copyright © 2003 Texas Instruments. All rights reserved. Interfacing to Mailboxes Void writer(Int id){ MsgObj msg; MsgObj msg; Int i; Int i; for (i=0; ; i++) { for (i=0; ; i++) { msg.id = id; msg.id = id; msg.val = i % NUMMSGS + (Int)('a'); msg.val = i % NUMMSGS + (Int)('a'); if ( MBX_post(&mbx, &msg, TIMEOUT) == 0 ){ if ( MBX_post(&mbx, &msg, TIMEOUT) == 0 ){ SYS_abort("timeout %s, TSK_getname()); SYS_abort("timeout %s, TSK_getname());}}} typedef struct MsgObj { Int id; Int id; Charval; Charval;}; Void reader(Void){ MsgObj msg; MsgObj msg; Int i; Int i; for (i=0; ;i++) { for (i=0; ;i++) { if (MBX_pend(&mbx, &msg, TIMEOUT) == 0) { if (MBX_pend(&mbx, &msg, TIMEOUT) == 0) { SYS_abort("timeout %s, TSK_getname()); SYS_abort("timeout %s, TSK_getname()); } LOG_printf(&logTrace,"%c from (%d)", msg.val, msg.id); LOG_printf(&logTrace,"%c from (%d)", msg.val, msg.id);}}

47 ESIEE, Slide 47 Copyright © 2003 Texas Instruments. All rights reserved. SWI vs. TSK User Name, Error Number, Environment Pointer NoYes Stack Configuration Uses the System Stack Each Task has its own Stack Blocking & Suspending NoYes Deleted Prior to Completion by other Threads NoYes SWITSK API Interface Assembly and C C

48 ESIEE, Slide 48 Copyright © 2003 Texas Instruments. All rights reserved. Disabling and Enabling Interrupts Hardware interrupts Hardware interrupts Atomic Functions Atomic Functions Scheduler Scheduler Can be nested Can be nested SWI_disable(); `critical section` SWI_enable();SWI_disable(); SWI_enable(); oldCSR = HWI_disable(); `critical section` HWI_restore(oldCSR); oldCSR = HWI_disable(); `critical section` HWI_restore(oldCSR); TSK_disable(); TSK_enable();TSK_disable(); TSK_enable();

49 ESIEE, Slide 49 Copyright © 2003 Texas Instruments. All rights reserved. Built-in Real-Time Analysis Tools What is Real-Time ? What is Real-Time ? Gather data on target (3-10 CPU cycles) Gather data on target (3-10 CPU cycles) Send data during BIOS IDLE (100s of cycles) Send data during BIOS IDLE (100s of cycles) Format data on host (1000s of cycles) Format data on host (1000s of cycles) Data gathering does NOT stop target CPU Data gathering does NOT stop target CPU Software Logic Analyzer Software Logic Analyzer Debug Scheduling Debug Scheduling Tick: specified time period based on hardware timer Tick: specified time period based on hardware timer Execution Graph Analyze time NOT spent in IDLE Analyze time NOT spent in IDLE CPU Load Graph

50 ESIEE, Slide 50 Copyright © 2003 Texas Instruments. All rights reserved. Built-in Real-Time Analysis Tools Profile routines without halting the CPU Profile routines without halting the CPU Statistics View Send debug msgs to host Send debug msgs to host Std printf requires: - 27K bytes - 30K CPU cycles Std printf requires: - 27K bytes - 30K CPU cycles LOG_printf requires: - 32 bytes - 30 CPU cycles LOG_printf requires: - 32 bytes - 30 CPU cycles Message LOG LOG_printf (&trace, Loopback enabled);

51 ESIEE, Slide 51 Copyright © 2003 Texas Instruments. All rights reserved. ? DSP/BIOS Modules DSP/BIOS Library APPLICATION PROGRAM INTERFACE LOG CLKHSTHWIIDLTRC PIPPRDRTDXSWISTS LOG STS USER FUNCTIONS func1 { } func2 { } #include #include func2 { STS_set(…); } #include #include func1 { LOG_printf(...); }

52 ESIEE, Slide 52 Copyright © 2003 Texas Instruments. All rights reserved. Creating and Reference Instances Instances are created in the Configuration Tool Instances are created in the Configuration Tool Code that creates them is in audiocfg.s## Code that creates them is in audiocfg.s## Object declaration is in mod.h (i.e. log.h) Object declaration is in mod.h (i.e. log.h) Function #include #include extern far LOG_Obj logTrace1; extern far LOG_Obj logTrace2; func(){ LOG_printf( &logTrace1, … ); LOG_printf( &logTrace2, … ); } Instances must be referenced (extern) by files that use them Instances must be referenced (extern) by files that use them Header file is needed for the declaration of the type Header file is needed for the declaration of the type

53 ESIEE, Slide 53 Copyright © 2003 Texas Instruments. All rights reserved. Interface to Statistics Accumulators Count the number of occurrences of an event Count the number of occurrences of an event Track the maximum and average for a variable Track the maximum and average for a variable Tracking minimum value of a variable Tracking minimum value of a variable Timing events or monitoring incremental differences in a value Timing events or monitoring incremental differences in a value STS_add(&stsObj); /* count an event */ STS_add(&stsObj, value); /* track the maximum and average */ /* track the minimum */ STS_add(&stsObj, -value); /* track the minimum */ STS_set(&stsObj, CLK_gethtime()); STS_delta(&stsObj, CLK_gethtime()); /* algorithm OR event */ STS_set(&stsObj, CLK_gethtime()); STS_delta(&stsObj, CLK_gethtime()); /* algorithm OR event */

54 ESIEE, Slide 54 Copyright © 2003 Texas Instruments. All rights reserved. STS API Effect on STS Object Fields STS_add(x) Count Total Max Previous* STS_set(y)STS_delta(z)STS_reset +1 +x replaced if x > Max yz +1 +(z-Previous) replaced if (z-Previous) > Max 0 0 largestnegativenumber *Previous field is set using Config tool, STS_set, or STS_delta

55 ESIEE, Slide 55 Copyright © 2003 Texas Instruments. All rights reserved. Clock Interface CLK_getltime() CLK_getltime() Returns the number of timer interrupts that have occurred Returns the number of timer interrupts that have occurred CLK_gethtime() CLK_gethtime() Returns the number of high resolution clock cycles that have occurred Returns the number of high resolution clock cycles that have occurred CLK_countspms() CLK_countspms() Returns the number of timer register ticks per millisecond Returns the number of timer register ticks per millisecond

56 ESIEE, Slide 56 Copyright © 2003 Texas Instruments. All rights reserved. Trace Control Allows the user to enable and disable instrumentation on the target Allows the user to enable and disable instrumentation on the target Limit the effects of instrumentation on program execution Limit the effects of instrumentation on program execution Two interfaces Two interfaces Host interface Host interface RTA Control Panel User Program User Program TRC API

57 ESIEE, Slide 57 Copyright © 2003 Texas Instruments. All rights reserved. Target Trace Control Masks Trace Control Mask - declared in trc.h TRC_LOGCLKLOG timer interrupts TRC_LOGPRDLOG periodic ticks and PRD functions TRC_LOGSWILOG software interrupt events TRC_LOGTSKTSK events TRC_STSHWIGather statistics on HWI TRC_STSPIPCount number of frames in data pipes TRC_STSPRDGather statistics on PRD function execution TRC_STSSWIGather statistics on SWI execution TRC_STSTSKGather statistics on TSK execution TRC_USER0 User defined TRC_USER1 User defined TRC_USER2 User defined TRC_GBLTARG Global target TRC_GBLHOST Global host Trace Control Mask - declared in trc.h TRC_LOGCLKLOG timer interrupts TRC_LOGPRDLOG periodic ticks and PRD functions TRC_LOGSWILOG software interrupt events TRC_LOGTSKTSK events TRC_STSHWIGather statistics on HWI TRC_STSPIPCount number of frames in data pipes TRC_STSPRDGather statistics on PRD function execution TRC_STSSWIGather statistics on SWI execution TRC_STSTSKGather statistics on TSK execution TRC_USER0 User defined TRC_USER1 User defined TRC_USER2 User defined TRC_GBLTARG Global target TRC_GBLHOST Global host

58 ESIEE, Slide 58 Copyright © 2003 Texas Instruments. All rights reserved. RTDX: Real-Time Data Exchange PC TMS320 DSP JTAG E M U R T D X USER CODE Third Party Display CCS RTDX enables non-obtrusive two-way communication between the host PC and the DSP (during IDLE) RTDX enables non-obtrusive two-way communication between the host PC and the DSP (during IDLE) Transfer speed limited by JTAG bandwidth (~10 MHz serial), connection type (parallel vs. XDS) and DSP activity level Transfer speed limited by JTAG bandwidth (~10 MHz serial), connection type (parallel vs. XDS) and DSP activity level Transfers made via RTDX calls in DSP application code Transfers made via RTDX calls in DSP application code Display User User TI TI 3rd Party 3rd Party

59 ESIEE, Slide 59 Copyright © 2003 Texas Instruments. All rights reserved. RTDX Target APIs #include #include RTDX_CreateInputChannel(writeload);RTDX_CreateOutputChannel(readload); Declarations Declarations RTDX_enableInput(&writeload);RTDX_enableOutput(&readload); in main() in main() if(!RTDX_channelBusy(&writeload)) { RTDX_readNB(&writeload, &loadVal, sizeof(loadVal)); } Read from channel Read from channel RTDX_write(&readload, &loadVal, sizeof(loadVal)); Write to channel Write to channel

60 ESIEE, Slide 60 Copyright © 2003 Texas Instruments. All rights reserved. Host Side RTDX (VB code) set r = CreateObject(RTDX) status = r.open(readload, R) Open read channel Open read channel set w = CreateObject(RTDX) status = w.open(writeload, W) Open write channel Open write channel status = r.ReadI4(data) Read 32-bit integer Read 32-bit integer status = w.WriteI4(value,bufferstate) Write 32-bit integer Write 32-bit integer

61 ESIEE, Slide 61 Copyright © 2003 Texas Instruments. All rights reserved. Sequence Diagram Get handle for RTDX channel RTDX handle Send some control commands to DSP rtdxToDSP.write RTDX: Get control commands RTDX: Create Input Channel Initialization VB or OLE application Code Composer DSP Create RTDX Connection Send RTDX commands to DSP rtdxCommandHandler rtdxCommandHandler RTDX: Create Output Channel

62 ESIEE, Slide 62 Copyright © 2003 Texas Instruments. All rights reserved. Why CSL? Why do we need a Chip Support Library (CSL)? Why do we need a Chip Support Library (CSL)? To support increasingly complex on-chip peripherals and applications To support increasingly complex on-chip peripherals and applications Frees the user from necessity of defining and maintaining code for peripheral configuration and control Frees the user from necessity of defining and maintaining code for peripheral configuration and control Provide standard method for accessing and controlling peripherals Provide standard method for accessing and controlling peripherals

63 ESIEE, Slide 63 Copyright © 2003 Texas Instruments. All rights reserved. CSL Introduction CSL – Chip Support Library CSL – Chip Support Library Runtime library designed to configure, control, and manage on-chip peripherals Runtime library designed to configure, control, and manage on-chip peripherals Adapted for both C6000 and C5000 DSP platforms Adapted for both C6000 and C5000 DSP platforms Written mostly in C, optimized for code size and speed Written mostly in C, optimized for code size and speed Partitioned into scalable/expandable API modules Partitioned into scalable/expandable API modules Module granularity is structured such that each peripheral is covered by a single API Module granularity is structured such that each peripheral is covered by a single API

64 ESIEE, Slide 64 Copyright © 2003 Texas Instruments. All rights reserved. CSL: On-Chip Peripherals C55x DSP Modules ADC CHIP DAT DMA EMIF GPIO IRQ I2C MCBSP PLL PWR RTC USB WDTIM C54x DSP Modules CHIP DAA DAT DMA EBUS GPIO HPI IRQ MCBSP PLL PWR UART WDTIM

65 ESIEE, Slide 65 Copyright © 2003 Texas Instruments. All rights reserved. CSL Features Standard protocol for programming on- chip peripherals: set of APIs (functions, data types, macros) Standard protocol for programming on- chip peripherals: set of APIs (functions, data types, macros) Symbolic peripheral description (hardware abstraction) set of macros for accessing and building register and field values Symbolic peripheral description (hardware abstraction) set of macros for accessing and building register and field values Basic resource management for multi- resource peripherals Basic resource management for multi- resource peripherals Integrated into DSP/BIOS build: CSL Graphic User Interface Integrated into DSP/BIOS build: CSL Graphic User Interface Peripheral ease-of-use: shortened development time, portability Peripheral ease-of-use: shortened development time, portability

66 ESIEE, Slide 66 Copyright © 2003 Texas Instruments. All rights reserved. TI Foundation Software Target Board DSP CODEC DIP Switches Chip Support Library is Dedicated to the On-Chip Peripherals Timer CSL DSP/BIOS Kernel/Scheduler Dsplib Imglib Drivers User Application McBSP EMIF CPU

67 ESIEE, Slide 67 Copyright © 2003 Texas Instruments. All rights reserved. CSL Naming Conventions All data structures, functions and macros begin with the capitalized 3–4 letter module/peripheral name followed by an underscore, PER_. (e.g. MCBSP_xxx, DMA_xxx) All data structures, functions and macros begin with the capitalized 3–4 letter module/peripheral name followed by an underscore, PER_. (e.g. MCBSP_xxx, DMA_xxx) All data structures begin with a capital letter in the word immediately following the underscore, PER_Xxxx (e.g. DMA_Config, I2C_Init) All data structures begin with a capital letter in the word immediately following the underscore, PER_Xxxx (e.g. DMA_Config, I2C_Init) All functions begin with lowercase letter in the word immediately following the underscore, PER_xxx (e.g. DMA_open, MCBSP_config) All functions begin with lowercase letter in the word immediately following the underscore, PER_xxx (e.g. DMA_open, MCBSP_config) All macros are in upper case, PER_XXX (e.g. MCBSP_RGETH(…), DMA_ADDRH(…)) All macros are in upper case, PER_XXX (e.g. MCBSP_RGETH(…), DMA_ADDRH(…))

68 ESIEE, Slide 68 Copyright © 2003 Texas Instruments. All rights reserved. CSL Resource Management Data Types and Functions CSL handle data type CSL handle data type PER_Handle: pointer to data structure returned from call to PER_open() for multi- resource modules (e.g. McBSP, DMA, etc.) PER_Handle: pointer to data structure returned from call to PER_open() for multi- resource modules (e.g. McBSP, DMA, etc.) CSL functions CSL functions Handle = PER_open(): allocation of a multi- resource peripheral device. Returns handle associated to the allocated resource (e.g. McBSP port or DMA channel) Handle = PER_open(): allocation of a multi- resource peripheral device. Returns handle associated to the allocated resource (e.g. McBSP port or DMA channel) Ex: hDma = DMA_open(DMA_CHA2,DMA_OPEN_RESET); PER_close(Handle): de-allocation of a previously opened multi-resource device PER_close(Handle): de-allocation of a previously opened multi-resource device Ex: DMA_close(hDma);

69 ESIEE, Slide 69 Copyright © 2003 Texas Instruments. All rights reserved. CSL Configuration Register-based configuration Register-based configuration PER_Config: data structure containing values for all control registers needed to configure the peripheral PER_Config: data structure containing values for all control registers needed to configure the peripheral PER_config([handle], PER_Config *config): configure the peripheral by setting the full values of memory-map registers. PER_config([handle], PER_Config *config): configure the peripheral by setting the full values of memory-map registers. Ex: EMIF_config(&myconfig); DMA_config(hDma,&myconfig); DMA_config(hDma,&myconfig); Parameter-based configuration Parameter-based configuration PER_Init: data structure containing functional parameters needed to configure the peripheral PER_Init: data structure containing functional parameters needed to configure the peripheral PER_init(PER_Init *init) configure the peripheral via a set of parameters. PER_init(PER_Init *init) configure the peripheral via a set of parameters. Ex: I2C_init(&myParams);

70 ESIEE, Slide 70 Copyright © 2003 Texas Instruments. All rights reserved. Sample CSL Configuration Structure typedef struct { Uint16 dmacsdp; Uint16 dmacsdp; Uint16 dmaccr; Uint16 dmaccr; Uint16 dmacicr; Uint16 dmacicr; DMA_AdrPtr dmacssal; DMA_AdrPtr dmacssal; Uint16 dmacssau; Uint16 dmacssau; DMA_AdrPtr dmacdsal; DMA_AdrPtr dmacdsal; Uint16 dmacdsau; Uint16 dmacdsau; Uint16 dmacen; Uint16 dmacen; Uint16 dmacfn; Uint16 dmacfn; Uint16 dmacfi; Uint16 dmacfi; Uint16 dmacei; Uint16 dmacei; } DMA_Config;

71 ESIEE, Slide 71 Copyright © 2003 Texas Instruments. All rights reserved. Initializing CSL Config Structures Creating register masks Creating register masks User generated User generated Use PER_REG_RMK macros provided by CSL Use PER_REG_RMK macros provided by CSL DMA_DMAGCR_RMK(0,0,1) DMA_DMAGCR_RMK(0,0,1) Use other pre-defined CSL macros such as PER_FMK(reg,field,val) to create mask Use other pre-defined CSL macros such as PER_FMK(reg,field,val) to create mask DMA_FMK(DMAGCR,FREE,1) DMA_FMK(DMAGCR,FREE,1)

72 ESIEE, Slide 72 Copyright © 2003 Texas Instruments. All rights reserved. CSL Coding Checklist 1.Include the appropriate CSL API headers (csl.h, csl_per.h) 2.Declare and initialize CSL configuration data structures and handles (DMA_Config myDmaCfg = {…}; DMA_Handle hDma0;) 3.Call CSL_init() prior to calling or using any other CSL API function 4.For multi-resource peripherals such as McBSP and DMA, call PER_open() function to reserve resource (MCBSP_open(), DMA_open()…) 5.Call PER_config() to configure peripheral 6.Call PER_start() to begin peripheral operation 7.Call PER_close() to free resources of multi- resource peripherals

73 ESIEE, Slide 73 Copyright © 2003 Texas Instruments. All rights reserved. CSL Example (DMA) #include DMA_Handle hDma0; DMA_Config dmaCfg0 = { …}; void main() { CSL_init(); hDma0 = DMA_open(DMA_CHA0, DMA_OPEN_RESET); DMA_config(hDma0,&dmaCfg0); DMA_start(hDma0); while(!(DMA_FGETH(hDma0,DMACSR,FRAME)); // Process data DMA_close(hDma0); } 4. Open DMA Channel (returns DMA_Handle to hDma0) 5. Configure Channel (note use of hDma0) 6. Start Transfer 7. Close/Free DMA Channel 3. Initialize Library 2. Declare CSL Data Objects 1. Include Headers

74 ESIEE, Slide 74 Copyright © 2003 Texas Instruments. All rights reserved. CSL Compile/Link CheckList 1.Use –dCHIP_XXXX to select the correct target device. (e.g. CHIP_5510PG1_0) cl55 –dCHIP_5510PG1_0 myFile.c cl55 –dCHIP_5510PG1_0 myFile.c 2.For C5000 DSPs, in a linker command file always include.csldata in the SECTIONS directive of the linker command file. The.csldata section should be linked into data RAM 3.Include the correct library, cslXXXX.lib, (e.g. csl5510PG1_0.lib)

75 ESIEE, Slide 75 Copyright © 2003 Texas Instruments. All rights reserved. 1. Select A Default Configuration Database Seed Using the CSL GUI

76 ESIEE, Slide 76 Copyright © 2003 Texas Instruments. All rights reserved. These are the only two elements needed for CSL configuration

77 ESIEE, Slide 77 Copyright © 2003 Texas Instruments. All rights reserved. 2. Select target

78 ESIEE, Slide 78 Copyright © 2003 Texas Instruments. All rights reserved. Peripheral Configuration Peripheral Resource Management 3. Expand CSL Tree

79 ESIEE, Slide 79 Copyright © 2003 Texas Instruments. All rights reserved. 4. Use Configuration Manager to insert a new configuration object

80 ESIEE, Slide 80 Copyright © 2003 Texas Instruments. All rights reserved. Inserted DMA Configuration Object

81 ESIEE, Slide 81 Copyright © 2003 Texas Instruments. All rights reserved. DATA TYPE has pull-down menu Number of Elements uses input box

82 ESIEE, Slide 82 Copyright © 2003 Texas Instruments. All rights reserved. 5. Use Properties pages to set/change configuration parameters

83 ESIEE, Slide 83 Copyright © 2003 Texas Instruments. All rights reserved. Scroll bar indicates more information available User may choose to set register values manually

84 ESIEE, Slide 84 Copyright © 2003 Texas Instruments. All rights reserved. Resource Object Properties 6. Select resource object and set its properties

85 ESIEE, Slide 85 Copyright © 2003 Texas Instruments. All rights reserved. The pull-down menu displays all DMA configuration objects currently defined

86 ESIEE, Slide 86 Copyright © 2003 Texas Instruments. All rights reserved. 8. Save the new configuration file. (Note:The base name of the saved configuration database file determines the name of the generated files)

87 ESIEE, Slide 87 Copyright © 2003 Texas Instruments. All rights reserved. Generated Files myproject.cdb – updated configuration database containing all inserted objects and all current property settings myproject.cdb – updated configuration database containing all inserted objects and all current property settings myprojectcfg.h – extern declaration of all created objects, definition of CHIP_XXXX, plus #include of CSL module headers myprojectcfg.h – extern declaration of all created objects, definition of CHIP_XXXX, plus #include of CSL module headers myprojectcfg_c.c – definition and initialization of created objects. Contains function calls to PER_open,PER_config/PER_init() for pre- opened/ pre-initialized objects myprojectcfg_c.c – definition and initialization of created objects. Contains function calls to PER_open,PER_config/PER_init() for pre- opened/ pre-initialized objects myprojectcfg.sXX – defines which DSP/BIOS elements are present and provides initialization for those elements myprojectcfg.sXX – defines which DSP/BIOS elements are present and provides initialization for those elements myprojectcfg.cmd – linker command file, includes CSL library and.csldata placement myprojectcfg.cmd – linker command file, includes CSL library and.csldata placement

88 ESIEE, Slide 88 Copyright © 2003 Texas Instruments. All rights reserved. myprojectcfg.h #include #include extern DMA_Config dmaCfg0; extern DMA_Handle hDma0; extern void CSL_cfgInit();

89 ESIEE, Slide 89 Copyright © 2003 Texas Instruments. All rights reserved. myprojectcfg_c.c DMA_Config dmaCfg0 = { 0x0205, /* (CSDP) */ 0x0205, /* (CSDP) */ 0x5060, /* (CCR) */ 0x5060, /* (CCR) */ 0x0008, /* (CICR) */ 0x0008, /* (CICR) */ (DMA_AdrPtr)&src, /* (CSSA_L) */ (DMA_AdrPtr)&src, /* (CSSA_L) */ NULL, /* (CSSA_U) */ NULL, /* (CSSA_U) */ (DMA_AdrPtr)&dst, /* (CSDA_L) */ (DMA_AdrPtr)&dst, /* (CSDA_L) */ NULL, /* (CSDA_U) */ NULL, /* (CSDA_U) */ 0x0080, /* (CEN) */ 0x0080, /* (CEN) */ 0x0001, /* (CFN) */ 0x0001, /* (CFN) */ 0x0000, /* (CFI) */ 0x0000, /* (CFI) */ 0x0000 /* (CEI) */ 0x0000 /* (CEI) */}; DMA_Handle hDma0;

90 ESIEE, Slide 90 Copyright © 2003 Texas Instruments. All rights reserved.CSL_cfgInit() void CSL_cfgInit() { … hDma0 = DMA_open(DMA_CHA0,DMA_OPEN_RESET); hDma0 = DMA_open(DMA_CHA0,DMA_OPEN_RESET); DMA_config(hDma0, &dmaCfg0); DMA_config(hDma0, &dmaCfg0);} Choosing Pre-Open in CSL GUI results in code generated to call PER_open function Choosing Pre-Initialization in CSL GUI results in code to call PER_config function

91 ESIEE, Slide 91 Copyright © 2003 Texas Instruments. All rights reserved. C Source Using GUI-Generated Files #include myprojectcfg.h" #define N128 Uint16 src[N]; Uint16 dst[N]; void main(void) { DMA_start(hDma0); DMA_start(hDma0); while while (!DMA_FGETH(hDma0,DMACSR,FRAME)); (!DMA_FGETH(hDma0,DMACSR,FRAME)); DMA_close(hDma0); DMA_close(hDma0);} Start DMA Free Resource Include generated C header file

92 ESIEE, Slide 92 Copyright © 2003 Texas Instruments. All rights reserved. CSL Macros PER_ADDR(reg) Gets the memory address of the specified peripheral register reg PER_RGET(reg) Returns the value of the specified peripheral register reg PER_RSET(reg,val) Writes the value val to the peripheral register reg PER_FGET(reg,field) Returns the value of the specified field of the register PER_FSET(reg,field,va l) Writes the value val to the specified field of the register Macros for accessing field and register values Macros for building field and register values PER_REG_RMK( fieldmsb,…, fieldlsb ) Creates a register value to store in the register PER_FMK(reg, field, val() Creates a shifted version of the fieldvalue could be used by PER_REG _RMK() Note: Handle-based macros are also available.

93 ESIEE, Slide 93 Copyright © 2003 Texas Instruments. All rights reserved.Literature System Software TMS320C54X SPRU328Code Composer Studio User's Guide SPRU328Code Composer Studio User's Guide SPRU423 TMS320 DSP/BIOS User's Guide SPRU423 TMS320 DSP/BIOS User's Guide SPRU404 TMS320C5000 DSP/BIOS API Reference Guide SPRU404 TMS320C5000 DSP/BIOS API Reference Guide SPRU420TMS320C54x Chip Support Library API Users Guide SPRU420TMS320C54x Chip Support Library API Users Guide SPRU433TMS320C55x Chip Support Library API Users Guide SPRU433TMS320C55x Chip Support Library API Users Guide Refer to Digital Library on this CD.

94 ESIEE, Slide 94 Copyright © 2003 Texas Instruments. All rights reserved. DSP/BIOS Application Notes SPRA697How to Get Started with DSP/BIOS II SPRA646 DSP/BIOS II Technical Overview SPRA648 Understanding the Functional Enhancements of DSP/BIOS II and their Utilization in Real-Time DSP Applications SPRA640 Programming and Debugging Tips for DSP/BIOS SPRA660 Building DSP/BIOS Programs in UNIX SPRA653 Understanding Basic DSP/BIOS Features SPRA663 Benchmarking DSP/BIOS II on the TMS320C54x SPRA692DSP/BIOS II Sizing Guidelines for the TMS320C54x DSP SPRA689 Using DSP/BIOS I/O in Multichannel Systems SPRA700 Writing Flexible Device Drivers for DSP/BIOS SPRA599DSP/BIOS and TMS320C54X Extended Addressing SPRA695 Real-Time DSP Software Design for a Portable MP3 Player Using DSP/BIOS SPRA598 An Audio Example Using DSP/BIOS SPRA591 DSP/BIOS by Degrees: Using DSP/BIOS in an existing application


Download ppt "DSP C5000 Chapter 7 DSP BIOS Copyright © 2003 Texas Instruments. All rights reserved."

Similar presentations


Ads by Google