DSP debugging method based on MATLAB

Publisher:VelvetSoulLatest update time:2010-06-22 Source: 测控技术Keywords:MATLAB Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

MATLAB has powerful analysis, calculation and visualization capabilities. Using the dozens of professional toolboxes provided by MATLAB, you can easily and flexibly implement algorithm analysis and simulation of automatic control, signal processing, communication systems, etc. It is an indispensable software tool for algorithm designers and engineering technicians.

As a programmable special chip, the digital signal processor (DSP) is an important technical tool for the practical application of digital signal processing theory, and has been widely used in technical fields such as speech processing and image processing. However, for algorithm designers, using assembly language or C language to develop DSP functions has the disadvantages of long cycle and low efficiency, which is not conducive to algorithm verification and rapid product development.

MATLAB Link for CCS Development Tools (CCSLink for short), jointly developed by MathWorks and TI, is a new toolbox added to MATLAB6.5 (Release13). It provides an interface between MATLAB, CCS and DSP target board. This tool can be used to operate the memory and registers of DSP devices like MATLAB variables, allowing developers to complete DSP operations in the MATLAB environment, thereby greatly improving the development process of DSP application systems.

1 CCSLink Preliminary

The CCSLink tool connects MATLAB, CCS, and DSP target boards through a bidirectional connection, allowing developers to use MATLAB's powerful visualization, data processing, and analysis functions to analyze and process data from CCS, greatly simplifying the analysis, debugging, and verification process of TI's DSP software. The relationship between the three is shown in Figure 1.


Figure 1 CCSLink connection relationship

The main features of CCSLink are: debugging, data transfer and verification of DSP devices in the MATLAB environment; real-time data transfer between MATLAB and DSP; support for XDS510 and XDS560 simulators; providing embedded objects that can access C/C++ variables; and expanding the debugging capabilities of MATLAB and eXpressDSP tools.

MATLAB 6.5 integrates CCSLink1.0 tools, supporting all boards and hardware DSPs that CCS can identify, including TIC2000, C5000, C6000 DSP and EVM boards, DSK boards, simulators, and any standard user boards and third-party boards. In addition to MATLAB and its signal processing toolbox, CCSLink also requires TI's compiler, assembler, linker, CCS IDE2.1, CCS configuration tools, and other software tools for normal operation.

Enter the command in the MATLAB environment

help ccslink

If CCSLink has been installed correctly, product information and a list of functions for performing CCS and RTDX operations will be displayed:

MATLAB Link for Code Composer Studio(tm)
Version 1.0 (R13) 28-Jun-2002.

If MATLAB cannot return information, it means that CCSLink has not been installed successfully and needs to be reinstalled.

2. CCSLink Object Creation

Before operating the DSP, you should first establish a DSP target. For users who have configured multiple DSP systems, CCSLink provides two tools for selecting DSP targets: ccsboardinfo function and boardprosel graphical user interface. Users can select the corresponding object according to the return value and their own needs. Taking the graphical user interface as an example, if two DSP systems, XDS510 Emulator and C5416 Simulator, are configured, and [boardNum,procNum] = boardprocsel is run, MATLAB will automatically detect the CCS configuration and the target selection interface shown in Figure 2 will appear. In this article, select the hardware emulator C54xxXDS510Emulator as needed and click Done, which will return the board 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 board number and processor number as parameters, and returns other properties after establishing the link object, such as the processor model and processor name. For example, running cc=ccsdsp('boardnum',boardNum, 'procnum', procNum) will establish a handle cc of the CCS IDE object. Thus, through cc, CCS operations can be implemented in MATLAB and DSP chips can be controlled.

3 CCSLink Debugging DSP Code Example

After establishing the MATLAB link, you can use CCS to generate executable code for the DSP target and compile, debug and analyze it. In the following introduction, the project files provided by MATLAB are used as examples.

3.1 Loading DSP target board

Execute the following code in the MATLAB environment:

projfile = fullfile( matlabroot, 'toolbox', 'ccslink', 'ccsdemos', 'ccstutorial','ccstut_54xx.pjt')%Select the project file
projpath = fileparts(projfile) %Specify the project file path
open(cc,projfile)%Open the project file
visible(cc,1)%Make CCS IDE visible in the foreground
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 comments, the project files are loaded and compiled in the MATLAB environment, and the executable files are generated and loaded into the DSP target board. Use the mouse to switch to the CCS interface, and you can see that various operations of CCS have been completed in MATLAB, as shown in Figure 3.


Figure 3 CCSLink debugging DSP code example

3.2 Using CCSLink to debug and access DSP memory

After compiling and loading the .out file, you can directly read the target symbol table through CCSLink and get the address of the variable in the DSP memory. For example, if you input ddatA = dec2hex(address(cc,'ddat')), the address and page of the variable ddat will be returned:
23AC, 0000.

In MATLAB, you can control the display of the program in CCS IDE, add and delete breakpoints, control the execution and pause of program code, and read and write DSP memory variables. For example, execute the following program:

open(cc,'ccstut.c','text')%Open the ccstut.c file in CCSopen
(cc,'ccstut_54xx.cmd','text')%Open the ccstut_54xx.cmd file in CCSactivate
(cc,'ccstut.c','text')%Use ccstut.c as the current active fileinsert
(cc,'ccstut.c',64)%Add a breakpoint at line 64halt
(cc)%Pause the CPUrestart
(cc)%Continue to maintain contact with CCSrun
(cc,'runtohalt',20)%DSP program executes to the breakpointddatV
= read(cc,address(cc,'ddat'),'single',4)%(1)Read the C code initialization dataddatidatV
= read(cc,address(cc,'idat'),'int16',4)%(2)Read the C code initialization dataidat
write(cc,address(cc,'ddat'),single([pi, 12.3, exp(-1), sin(pi/4)])) % (3) Modify the data ddat in DSP memory
write(cc,address(cc,'idat'),int16([1:4])) % (4) Modify the data idat in DSP memory
run(cc,'runtohalt',20) % Continue execution 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

Reading the project file of this example, we can see that in the C code, the variable initialization values ​​are ddat=[16.3,-2.13,5.1,11.8] and idat=[1,508,647,7000]. By executing the above two statements (1) and (2), the values ​​of these two variables ddatV and idatV are obtained in MATLAB. After the modification of the two statements (3) and (4), ddat and idat are changed to the new values ​​ddat=[3.1416,12.3,0.3679,0.7071] and idat=[1,2,3,4] respectively. This modification can be verified in MATLAB by executing the two statements (5) and (6), and can also be confirmed by the variable observer in CCS IDE.

In MATLAB, you can also use regread and regwrite to read and write CPU registers.

tReg = regread(cc,'AL','2scomp') % Read AL as two's complement
regread(cc,'TRN','binary') % Read TRN as unsigned binary
regwrite(cc,'AH','FFFF','binary') % Read and write AH as unsigned binary

3.3 Accessing DSP Memory Using CCSLink Embedded Object Debug

Using MATLAB's object-oriented programming technology and CSLink, you can create embedded objects for all C symbols in the target program and operate the C symbols through objects.

Still taking the above program as an example, first reset the DSP and create an embedded object:

restart(cc) % Reset the program and make the PC point to the program entry
goto(cc,'main') % Position the PC to the C main program entry cvar = createobj(cc,'idat') % (7) Create MATLAB object cvar
for operating the embedded object idat

Statement (7) creates a MATLAB object pointing to the C symbol in the DSP, so that all or part of it 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 the second element
write(cvar,4,7001)%(9) Change the fourth element to 7001
set(cvar,'size',[2])%(10) Reduce the object to 2 elements

Statement (8) reads the embedded array cvar pointing to idat into MATLAB, its 4th element is modified in statement (9), and the size of the array is changed in statement (10).

Through CCSLink, you can not only create objects for array variables, but also create objects for structure variables and perform corresponding operations, such as:
cvar = createobj(cc,'myStruct') %Create a MATLAB object pointing to the C structure
write(cvar,'iz', 'Simulink') %Modify the string iz field of the structure to Simulink
cstring = getmember(cvar,'iz') %Read the field to MATLAB
write(cstring,1,'s') %The first character of the write string
readnumeric(cstring) %Read the string numerically

The above five statements all use the object cvar in the MATLAB environment to implement the read, write and modify operations on the structure variable myStruct in the DSP C language program, which is very convenient.

Through CCSlink, no matter whether the connection object or embedded object is established in CCS IDE, it can be operated in MATLAB environment, so as to read, write and modify various variables inside DSP, and carry out related debugging process, which is very convenient. For all the operation execution results of the above examples, they can be observed and verified in MATLAB and CCS IDE environment.

4 Conclusion

This paper briefly discusses the MATLAB-based DSP program debugging method, describes the basic concepts of CCSLink and CCS IDE, introduces the process of establishing CCS objects, and takes the actual project files provided by MATLAB as an example to demonstrate the actual process of using CCSLink connections and embedded objects to operate C variables, and briefly explains its execution process and results.

It should be noted that MATLAB provides a large number of functions for DSP program debugging, and this article only covers a small part of them. To fully utilize the powerful functions of MATLAB for deeper DSP program debugging, you should further refer to the technical information MATLAB Link for Code Composer Studio Development Tools provided by MathWorks.

Keywords:MATLAB Reference address:DSP debugging method based on MATLAB

Previous article:Research on the Implementation Method of High-Speed ​​Serial Switching Module Based on FPGA
Next article:Design of Fiber Bragg Grating Demodulation System Based on DSP

Recommended ReadingLatest update time:2024-11-16 20:48

Design of serial communication system based on touch screen and DSP
  In modern industrial control, the most commonly used human-machine interface is still a combination of keyboard and LCD. There are still some problems in replacing the previous human-machine interface with a touch screen. In practical applications, touch screens are generally designed for programmable controllers
[Embedded]
Design of serial communication system based on touch screen and DSP
Design of an Online Reconfigurable Digital Image Parallel Processing System Based on Multiple DSPs
  With the rapid development of multimedia image processing applications, embedded digital image processing systems with small size, light weight, flexible structure and strong processing capability are increasingly in demand in industry, medicine and other fields. High real-time performance, complex calculations
[Embedded]
Design of an Online Reconfigurable Digital Image Parallel Processing System Based on Multiple DSPs
Simulation of uniform plane electromagnetic waves based on Matlab
"Electromagnetic Fields and Electromagnetic Waves" is a compulsory professional basic course for undergraduate students majoring in electronics and communications. The content covered by the course is an important part of the knowledge structure that students majoring in electronics and communications should possess a
[Power Management]
Simulation of uniform plane electromagnetic waves based on Matlab
A Design of Digital Switching Power Supply Based on DSP Control
1 Introduction Digitally controlled switching power supplies have been popular in the market since around 2005. The reason is that at that time many power supply manufacturers and semiconductor manufacturers began to put power supply modules and control industrial ICs on the market. By using DSP or dedicated
[Power Management]
A Design of Digital Switching Power Supply Based on DSP Control
Doppler measurement system constructed by using DSP and FPGA
As FPGA performance and capacity improve, it is becoming more common to use FPGAs to perform DSP functions. In many cases, processors and FPGAs are used together in the same application, using a co-processing architecture to let the FPGA perform pre-processing or post-processing operations to speed up processing. This
[Test Measurement]
Doppler measurement system constructed by using DSP and FPGA
Design of various solutions for communication between DSP and microcontroller
Combining the DSP and the microcontroller to form a dual-CPU processor platform can make full use of the DSP's processing capabilities for large-capacity data and complex algorithms, as well as the control capabilities of the microcontroller interface. The fast and correct communication between DSP and microcontroller
[Embedded]
Implementation of H.324 Terminal Based on DSP
At present, two methods are generally used in the research and development of H.324 systems: one is to develop a pure software H.324 system, that is, a PC-based system; the other is to use a programmable video signal processor to implement the functions of the H.324 system. The latter method has great flexibility an
[Embedded]
Implementation of H.324 Terminal Based on DSP
How to choose a DSP?
The selection of DSP can be determined based on the following aspects:  1) Speed: DSP speed is generally expressed in MIPS or FLOPS, that is, millions of times per second. Choose the appropriate device according to your requirements for processing speed. Generally, the processing speed should not be too high. A DSP w
[Embedded]
Latest Embedded Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号