DSP debugging method using Matlab

Source: Internet
Author: User

This paper introduces the debugging method of DSP Application Based on MATLAB based on specific examples.

MATLAB has powerful analysis, computing and visualization functions, using dozens of professional toolboxes provided by MATLAB, algorithm Analysis and Simulation for automatic control, signal processing, and communication systems can be conveniently and flexibly implemented. It is an indispensable software tool for algorithm designers and engineering technicians.
As a dedicated programmable chip, digital signal processor (DSP) is an important technical tool in the practical process of digital signal processing theory. It has been widely used in speech processing, image processing and other technical fields. However, for algorithm designers, developing DSP functions using assembly or C language is not conducive to algorithm verification and quick product development because of its long cycle and low efficiency.
MATLAB link for CCS development tools (ccslink for short) jointly developed by Mathworks and Ti is a brand new toolbox added in the release 13 of the Matlab 6.5 version, it provides interfaces for Matlab, CCS, and DSP target boards. This tool can be used to operate the memory and registers of DSP devices like MATLAB variables, this allows developers to complete DSP operations in the MATLAB environment, greatly improving the development process of DSP application systems.

1 ccslink preliminary
The ccslink tool connects MATLAB, CCS, and DSP target boards through two-way connections, allowing developers to use MATLAB's powerful visualization, data processing, and analysis functions to analyze and process data from CCS, this greatly simplifies the analysis, debugging, and verification processes of ti dsp software. The relationship between the three elements is 1.

Figure 1 ccslink connection
The main features of ccslink are: debugging, data transmission and verification of DSP devices in the MATLAB environment; real-time data transmission between MATLAB and DSP; Support for xds510 and xds560 simulators; provides embedded objects to access C/C ++ variables, and extends the debugging capabilities of MATLAB and expressdsp tools.
Matlab 6.5 integrates the ccslink1.0 tool and supports CCS to recognize all boards and hardware DSPs, includes the tic2000, C5000, C6000 DSP and EVM boards, DSK boards, simulator and any user boards and third-party boards that comply with the standards. In addition to MATLAB and Its Signal Processing Toolbox, ccslink also needs Ti compilers (compiler), compilers (linker), CCS ide2.1, and CCS Configuration tool letters to other software tools.
Enter commands in the MATLAB environment
Help ccslink
If the ccslink is correctly installed, the product information and list of functions for CCS and rtdx operations are displayed:
MATLAB link for Code Composer Studio (TM)
Version 1.0 (R13) 28-jun-2002.
If MATLAB does not return information, it indicates that ccslink is not installed successfully and needs to be re-installed.

2. Create a ccslink object
Before performing operations on the DSP, you should first establish a DSP target. Ccslink provides two tools for users who have configured Multiple DSP Systems: ccsboardinfo function and boardprosel graphical user interface. Users can select corresponding objects based on their return values and requirements. Taking the graphic user interface as an example, if xds510 emulator and c5416 simulator are configured to run the [boardnum, procnum] = boardprocsel DSP system, Matlab automatically detects the CCS configuration, the target selection page shown in Figure 2 is displayed. This article selects the hardware simulator c54xxxds510emulator as needed
Click Done to return the card number and processor Number:
Boardnum = 1, procnum = 0.

Figure 2 ccslink object selection
The ccsdsp function can be used to establish a DSP object. Ccsdsp takes the card number and processor number as parameters, and returns other attributes, such as the processor model and processor name, after the link object is created. For example, run cc = ccsdsp ('boardnum', boardnum, 'procnum', procnum) to create a CC ide object handle. Therefore, CC can be used to operate CCS and control DSP chips in MATLAB.

3. ccslink: DSP code debugging example
After establishing the MATLAB link, you can use CCS to generate executable code for the DSP target and compile, debug, and analyze the code. In the following introduction, we will take the engineering files that come with Matlab as an example.
3.1 load DSP target board
Run the following code in the MATLAB environment:
Projfile = fullfile (maid, 'toolbox', 'ccslink', 'ccsdemos', 'ccstutorial ', 'ccstut _ 54xx. pjt') % select a project file
Projpath = fileparts (projfile) % specifies the project file path
Open (CC, projfile) % open the project file
Visible (CC, 1) % make the CCS ide foreground visible
CD (CC, projpath) % change the MATLAB working path
Build (CC, 'all', 60) % compile the project
Load (CC, 'ccstut _ 54xx. out', 30) % load the executable file
As shown in the code comment, the project file is fully loaded and compiled in the MATLAB environment, and the executable file is generated and loaded to the DSP target board. Switch to the CCS interface with the mouse operation. You can see that various operations on CCS have been completed under MATLAB, as shown in 3.

Figure 3 ccslink: DSP code debugging example
3.2 access DSP Memory through ccslink connection debugging
After compiling and loading the. Out file, ccslink can directly read the target symbol table and obtain the address of the variable in DSP Memory. If you enter dData = dec2hex (address (CC, 'ddat '), the address and page of the variable ddat are returned:
23ac, 0000.
In Matlab, you can control the display of programs and the addition and deletion of breakpoints in the ccs ide, control the execution and suspension of program code, and read and write the memory variables of the DSP. For example, run the following program:
Open (CC, 'ccstut. C', 'text') % open the ccstut. c file in CCS
Open (CC, 'ccstut _ 54xx. cmd', 'text') % open the ccstut_54xx.cmd file in CCS
Activate (CC, 'ccstut. C', 'text') % uses ccstut. C as the current active file
Insert (CC, 'ccstut. C', 64) % Add a breakpoint to row 64th
Halt (CC) % pause CPU
Restart (CC) % keep in touch with CCS
Run (CC, 'runtohalt', 20) % DSP program executed to breakpoint
Ddatv = read (CC, address (CC, 'ddat '), 'single', 4) % (1) read C code initialization data ddat
Idatv = read (CC, address (CC, 'idat '), 'int16', 4) % (2) read C code to initialize idat data
Write (CC, address (CC, 'ddat '), single ([Pi, 12.3, exp (-1), sin (PI/4)]) % (3) modify ddat in DSP Memory
Write (CC, address (CC, 'idat '), int16 ([]) % (4) Modify idat data in DSP Memory
Run (CC, 'runtohalt', 20) % continue from the breakpoint
Ddatv = read (CC, address (CC, 'ddat '), 'single', 4) % (5) read the modified data ddat
Idatv = read (CC, address (CC, 'idat '), 'int16', 4) % (6) read the modified data idat
Read this project file and we can see that in the C code, the variable initialization value is ddat = [16.3,-2.13, 5.1, 11.8], idat = [1,508,647,700 0]. Execute the preceding (1) and (2) Statements and obtain the values of the two variables ddatv and idatv in MATLAB. After the statements (3) and (4) are modified, ddat and idat are changed to the new values ddat = [3.1416, 12.3, 0.3679, 0.7071] And idat =, 3, 4]. This modification can be verified from the execution of the (5) and (6) Statements in MATLAB, and can also be confirmed by the Variable Observer in the ccs ide.
In Matlab, you can also use regread and regwrite to read and write CPU registers. For example
Reg = regread (CC, 'al', '2scomp ') % read al by binary Complement
Regread (CC, 'trn', 'binary ') % read TRN by Unsigned binary
Regwrite (CC, 'Ah', 'ffffff', 'binary ') % reads and writes by Unsigned binary number ah
3.3 Access DSP Memory through ccslink embedded object debugging
Using MATLAB's object-oriented programming technology and cslink, you can create an embedded object for all the C symbols in the target program and operate the C symbol through the object.
For example, reset the DSP and create an embedded object:
Restart (CC) % reset the program so that the PC points to the program entrance
Goto (CC, 'main') % locates the PC at the C main program Portal
CVaR = createobj (CC, 'idat ') % (7) create a MATLAB object for the idat operation embedded object
CVaR
Statement (7) creates a MATLAB object pointing to the C symbol in the DSP, so that all or part of the object can be read and modified in the MATLAB environment.
Read (CVaR) % (8) read the embedded array into the MATLAB Workspace
Read (CVaR, 2) % read only 2nd Elements
Write (CVaR, 4th) % (9) Change 7001 elements
Set (CVaR, 'SIZE', [2]) % (10) reduces the object to two elements
Statement (8) reads the embedded array CVaR pointing to idat into MATLAB and modifies the 4th elements in statement (9) the array size is changed.
Through ccslink, you can not only create objects for Array variables, but also create objects for struct variables and perform corresponding operations, such:
CVaR = createobj (CC, 'mystruct ') % create a MATLAB object pointing to a C struct
Write (CVaR, 'iz ', 'simulink') % modify the string iz field of the struct
Cstring = getmember (CVaR, 'iz ') % read this field to MATLAB
Write (cstring, 1,'s ') % the first character of the string to be written
Readnumeric (cstring) % read the string by Numerical Value
The preceding five statements use the object CVaR In the MATLAB environment to read, write, and modify the struct variable mystruct In the dsp c language program, which is very convenient.
Through ccslink, both the connection object and the embedded object of ccs ide can be operated in the MATLAB environment to read, write, and modify various internal variables of DSP, and the relevant debugging process is very convenient. The results of all operations in the preceding example can be observed and verified in the MATLAB and CCS ide environments.

4 Conclusion
This paper briefly discusses the DSP program debugging method based on MATLAB, describes the basic concepts of ccslink and ccs ide, introduces the process of establishing CCS objects, and takes the actual engineering files provided by Matlab as an example, it demonstrates the actual process of using ccslink to connect to and operate C variables on embedded objects, and briefly explains the execution process and results.
It should be noted that MATLAB provides a large number of DSP program debugging functions, this article only involves a very small part. To make full use of the powerful functions of MATLAB for deeper DSP program debugging, we should refer to the technical materials provided by Mathworks MATLAB link for Code Composer Studio development tools.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.