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.
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
- Huawei's Strategic Department Director Gai Gang: The cumulative installed base of open source Euler operating system exceeds 10 million sets
- Analysis of the application of several common contact parts in high-voltage connectors of new energy vehicles
- Wiring harness durability test and contact voltage drop test method
- Sn-doped CuO nanostructure-based ethanol gas sensor for real-time drunk driving detection in vehicles
- Design considerations for automotive battery wiring harness
- Do you know all the various motors commonly used in automotive electronics?
- What are the functions of the Internet of Vehicles? What are the uses and benefits of the Internet of Vehicles?
- Power Inverter - A critical safety system for electric vehicles
- Analysis of the information security mechanism of AUTOSAR, the automotive embedded software framework
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- Design of robotic arm gesture tracking and voice control system
- A new trend in home appliances, PI opens up your new life in home appliances! Download product information and answer questions to win prizes!
- Voltage acquisition circuit
- Problems with IO pin configuration when STM32 is low power
- Lei Jun: Young people should not make suggestions on strategy and business within six months of joining the company, as many of their ideas are unreliable!
- The baby was born--received a special care from the forum
- Low-level error "while(__HAL_RCC_GET_FLAG(RCC_FLAG_HSIRDY) == RESET)" infinite loop
- [Silicon Labs BG22-EK4108A Bluetooth Development Review] Part 1: Unboxing
- ZigBee TI ZStack CC2530 4.14 Broadcast Communication
- I am a DSP novice and have a few questions. I hope the experts can answer them. Thank you!