420 likes | 655 Views
Lecture 08. From MATLAB to Real Time with TI DSP. Hardware and Software Requirements. MATLAB R2006b with Embedded Target for TI C6000. Code Composer Studio (CCS) v3.1 Texas Instruments DSK6416 hardware. Starting FDATool. Start MATLAB 7.3.0 R2006b. At the command line, type in “fdatool”.
E N D
Lecture 08 From MATLAB to Real Time with TI DSP
Hardware and Software Requirements • MATLAB R2006b with Embedded Target for TI C6000. • Code Composer Studio (CCS) v3.1 • Texas Instruments DSK6416 hardware.
Starting FDATool • Start MATLAB 7.3.0 R2006b. At the command line, type in “fdatool”. • The following screen will appear:
Designing an FIR Filter Design • From the “Design Method” part of the screen, click on the “FIR” box and select “Window”. • Setting the Filter Coefficients • Click on the “Design Filter” box when done.
Designing an FIR Filter Design • The frequency response curve of the filter will appear • It can be seen that for frequencies above 4 kHz, the output amplitude is reduced by more than 40 dB (100 times).
Designing an FIR Filter Design • Select File -> Save Session As… • Give the filter a unique name such as “FIR_lowpass_800Hz”.
Exporting the Filter To Simulink • Now for the clever part! • Select File -> Export to Simulink Model.
Exporting the Filter To Simulink • Realizing the Model: • Give the block a unique name such as “FIR Lowpass Filter 800 Hz”. • Click the “Realize Model” box.
The New Simulink Model • The filter we designed using FDATool has been converted to a Simulink block. • It has been automatically dropped onto a new Simulink model.
Filter Block Parameters • Double-click on the “Digital Filter” block. The “Numerator coefficients” have been supplied in “floating-point” format. • This makes them compatible with the Texas Instruments C6000 DSP.
Designing a High Pass Filter • The next step is to design a highpass filter. • At the FDATool window, Select File -> New Session to start the new design.
The Highpass Filter Design • Set the “Response Type” to “Highpass”. • Notice that the “Filter Specifications” part of the screen changes.
Entering the Filter Parameters • Click on the “Design Filter” box when done.
Viewing the Highpass Filter Frequency Response • Click on the “Design Filter” box when done.
Saving the Finished Highpass Filter Design • Select File -> Save Session As… and give it a unique name. • “FIR Highpass 800Hz Hamming Window”.
Exporting to Simulink • Select File -> Export to Simulink Model. • Give the block a unique name such as “FIR Highpass Filter 800Hz”.
Realizing the Filter Model • Click on the “Realize Model” button.
The Updated Model • Return to Simulink. • The second “Digital Filter” block has been added to the model. • Save the model using a unique name such as “C6416_Audio_FIR_Filter_Design”.
Highpass Filter Settings • Double-click on the “FIR Highpass Filter 800 Hz” block. • Again, the “Numerator coefficients” are in “floating-point” form. • Click on “OK”.
C6000 Target Preferences • Select View -> Library Browser. • Select Embedded Target for TI C6000 DSP. • Highlight “C6000 Target Preferences”. • Drag-and-drop the “C6416DSK” block onto the model.
Initialize Target Preferences • When the “Initialize” window appears, click on the “Yes” box. This sets up the • correct sampling format for the DSK6416.
Adding a Demultipexer/Multiplexer • The input from the ADC is in stereo, that is, it contains both left and right audio inputs. In order to separate the two inputs, a demultiplexer is required. • In the Simulink Library Browser Select "Simulink -> Commonly Used Blocks". • Drag-and-drop a “Demux” block onto the model. • The two mono filter outputs are mono. This is different to the stereo input to the DAC. In order to make the signals compatible, a multiplexer is required. • In the Simulink Library Browser, select the "Simulink/Commonly Used Blocks", • and drag-and-drop a “Mux” block onto the model.
Joining the Blocks • The blocks need to be joined • We saved this model as "C6416_audio_FIR_Filter_design.mdl".
Adding an ADC • Return to the “C6416 Board Support” Library. • Drag-and-drop an “ADC” block onto the model.
Adding a DAC • Again go to the “C6416 Board Support” Library. • Drag-and-drop an “DAC” block onto the model.
ADC Settings • Double-click on the ADC block. Set up the ADC as follows:
DAC Settings • Double-click on the DAC block. Set up the DAC as follows:
The Final Filter Design • Join the blocks together
Building the Model • Select Tools -> Real-Time Workshop -> Build Model.
The Completed Model Running on Code Composer Studio • Go to Code Composer Studio. • From the folders in the left window, select the source code for the project.
Device Drivers White Paper DSP/BIOS Device Driver Developer's Guide
DSP BIOS Consists Of: • Real-time analysis tools Allows application to rununinterrupted while displayingdebug data • Real-time scheduler Preemptive thread mgmtkernel • Real-time I/O (Drivers) Allows two-way communication between threads or between threads and hardware Life before drivers...
DSK6416_AIC23_ App Codec McBSP Directly Accessing Hardware void audioLoopBack() { DSK6416_AIC23_CodecHandle hCodec; short buf[64]; int N; DSK6416_init(); /* Start the codec */ hCodec = DSK6416_AIC23_openCodec(0, &config); while () { for (N = 0; N < 64; N++) { while (!DSK6416_AIC23_read(hCodec, buf[N])); while (!DSK6416_AIC23_write(hCodec, buf[N])); } } } • App writes to hardware directly using the the specific target’s BSL functions • Every application needs to be customized to hardware: You must change each instance of DSK6416_xxx to another function call every time you port the code • Portability suffers Using drivers…
IOM App SWI or TSK Codec McBSP SIO or PIP Abstracting Hardware with Drivers • Device Drivers standardize the interface between the Application and the H/W • Application programmer only has to know PIP or SIO (no matter what H/W is connected) • The H/W can be changed without changing the Application (only need to change IOM included in project) • Therefore, Drivers (SIO/PIP with IOM) insulate the Application from the hardware’s details CSL, BSL, and IOM make up ...
Using DSP/BIOS PIP Driver void audioLoopBack() { // get the full buffer from the receive PIP PIP_get(&pipRx); // get the empty buffer from the transmit PIP PIP_alloc(&pipTx); // Put the transmit buffer; Free the receive buffer PIP_put(&pipTx); PIP_free(&pipRx); • Think of PIP (pipe) as a buffer manager with built-in signaling: • The ‘reader’ gets signaled when data is available • The ‘writer’ gets signaled when the buffer is emptied • Use it from SWI SWI or between SWI hardware • A common interface for all C5000 & C6000 DSP’s • Bottom Line: Application Code never changes even if you change H/W How about a SIO example?
Using SIO Drivers // Run forever looping-back buffersfor (;;){ // Reclaim full buffer from the input streamSIO_reclaim(inStream, (Ptr *)&inbuf, NULL)) // Reclaim empty buffer from output stream and reissueSIO_reclaim(outStream, (Ptr *)&outbuf, NULL)SIO_issue(outStream, inbuf, nmadus, NULL) // Issue an empty buffer to the input streamSIO_issue(inStream, inbuf, SIO_bufsize(inStream), NULL) } • SIO (Stream I/O) is another DSP/BIOS device driver methodology • Think of issuing and reclaiming buffers from a stream • BottomLine: Application Code doesn’t change even if hardware does
TSK or SWI SWI DSP/BIOS Thread Types SIO PIP DSP/BIOS provided Class Drivers Any mini-driver (IOM) can be used with any DSP/BIOS I/O model Mini-Driver(IOM) BIOS I/O Models • Application Programmer chooses the preferred class driver • Interface is consistent regardless of which device (mini-driver) connected • Software interface doesn’t change, even if you change the IOM device
Driver Developer Kit (DDK) Support DDK v1.0 DDK v1.1 DDK v1.2 (3Q03) * We have only included C6000 systems in this table • Provided Royalty Free • Requires CCS v2.2 or greater • Search for “DDK” on the TI website to download
Mini-Driver Interface (IOM) • Maximum Reuse and Portability • One I/O mini-driver (IOM) interface to support all TI Class drivers. • IOM Interface Consists Of: Functions: • init function • IOM_mdBindDev • IOM_mdUnBindDev • IOM_mdControlChan • IOM_mdCreateChan • IOM_mdDeleteChan • IOM_mdSubmitChan • interrupt routine (isr) Data Structures: • BIOS Device Table • IOM function table • Dev param’s • Global Data Pointer (device inst. obj.) • Channel Params • Channel Instance Obj. • IOM_Packet (aka IOP)
DSP/BIOS CommunicationsLayer SIO / PIP IOM DSK’s BSL Board Support Layer Chip Support Layer TI CSL TI Software Foundation Model