1 / 41

Lecture 08

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”.

kiora
Download Presentation

Lecture 08

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Lecture 08 From MATLAB to Real Time with TI DSP

  2. Hardware and Software Requirements • MATLAB R2006b with Embedded Target for TI C6000. • Code Composer Studio (CCS) v3.1 • Texas Instruments DSK6416 hardware.

  3. Starting FDATool • Start MATLAB 7.3.0 R2006b. At the command line, type in “fdatool”. • The following screen will appear:

  4. 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.

  5. 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).

  6. Designing an FIR Filter Design • Select File -> Save Session As… • Give the filter a unique name such as “FIR_lowpass_800Hz”.

  7. Exporting the Filter To Simulink • Now for the clever part! • Select File -> Export to Simulink Model.

  8. 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.

  9. 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.

  10. 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.

  11. 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.

  12. The Highpass Filter Design • Set the “Response Type” to “Highpass”. • Notice that the “Filter Specifications” part of the screen changes.

  13. Entering the Filter Parameters • Click on the “Design Filter” box when done.

  14. Viewing the Highpass Filter Frequency Response • Click on the “Design Filter” box when done.

  15. Saving the Finished Highpass Filter Design • Select File -> Save Session As… and give it a unique name. • “FIR Highpass 800Hz Hamming Window”.

  16. Exporting to Simulink • Select File -> Export to Simulink Model. • Give the block a unique name such as “FIR Highpass Filter 800Hz”.

  17. Realizing the Filter Model • Click on the “Realize Model” button.

  18. 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”.

  19. 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”.

  20. 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.

  21. Initialize Target Preferences • When the “Initialize” window appears, click on the “Yes” box. This sets up the • correct sampling format for the DSK6416.

  22. 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.

  23. Joining the Blocks • The blocks need to be joined • We saved this model as "C6416_audio_FIR_Filter_design.mdl".

  24. Adding an ADC • Return to the “C6416 Board Support” Library. • Drag-and-drop an “ADC” block onto the model.

  25. Adding a DAC • Again go to the “C6416 Board Support” Library. • Drag-and-drop an “DAC” block onto the model.

  26. Adding a DAC

  27. ADC Settings • Double-click on the ADC block. Set up the ADC as follows:

  28. DAC Settings • Double-click on the DAC block. Set up the DAC as follows:

  29. The Final Filter Design • Join the blocks together

  30. Building the Model • Select Tools -> Real-Time Workshop -> Build Model.

  31. 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.

  32. Device Drivers White Paper DSP/BIOS Device Driver Developer's Guide

  33. 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...

  34. 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…

  35. 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 ...

  36. 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?

  37. 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

  38. 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

  39. 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

  40. 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)

  41. DSP/BIOS CommunicationsLayer SIO / PIP IOM DSK’s BSL Board Support Layer Chip Support Layer TI CSL TI Software Foundation Model

More Related