DSP Programming Tips 2: Unveiling the Mystery of Compilers and Processor Options

Publisher:LuckyDaisyLatest update time:2014-02-09 Source: EEPWKeywords:DSP Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
  Maybe you have been using CCS for many years, but when a cl2000-related error occurs one day, you are suddenly confused; for example, if you use an old version of  CCS that does not support C2000 FPU to compile a 28335 program, cl2000 will prompt you that it is not supported and then report an error and will not run. What is Cl2000.exe?

Cl2000.exe is the compiler  that is closely related to our program compilation . The method of use is:
  cl2000 [ compiler options] [files to be compiled] [--run linker [linker options] target file]]

  The usage seems complicated, but fortunately CCS has already called it for us (or CCS is a framework, and almost all of its compilation, debugging, linking and other functions need to call some other exe to execute, so you may have experienced upgrading some library files, editor versions, etc., but the interface files do not need to be changed). These sentences will be displayed in the project properties. Of course, if you want to experience it yourself, you can also find it under toolscompilerc2000_6.1.5bin under the ccs installation directory, that is, cl2000.exe, and then run it from the command line). Here is a simple example:

  cl2000 -v28 symtab.c file.c seek.asm --run_linker --library=lnk.cmd
  --output_file=myprogram.out

  In the above example, if the files that need to be compiled, such as several .c or .asm, are not found, CCS will prompt that xxx.c or xxx.asm is not found or is undefined; or you changed the name of the target file, for example, to a.out, but when loading the program into DSP , it still uses b.out before the change. Naturally, unexpected results may occur: such a situation did occur when I helped netizens solve problems before.

  After understanding how to call the compiler , we can go a step further and unveil the mystery of the various options in the compiler. From now on, we no longer need to be afraid of the various warnings and errors prompted by the compiler.

  Specifically, the compiler options are divided into 20 categories, with more than 100 specific options. Of course, these options are divided into different levels of importance. Some are necessary, such as supporting FPU and other functions; some are not often used, such as automotive industry software reliability checks such as MISRA, which are only used when standardizing software. So let's first look at the most commonly used options, such as processor options, which are meaningful in defining the CPU mode when compiling the program. One thing to add is that the options seen in the help of cl2000 have very long names. In CCS, for the convenience of writing (because the option box is so small), aliases are generally used instead; if there is no alias, the option name is used directly.

Processor options

Aliases

meaning

--silicon_version=28

-v28

Generate target files for DSPs with C28x architecture ; if not selected, the mode is C27x mode, or C2xLP compatible mode (for example, to make C28 CPU support C24 assembly statements, there are many compatibility issues, because the search mode, CPU architecture, etc. have changed to a certain extent, and some instructions are no longer applicable to new devices). Most netizens will hardly use the latter two modes, so we generally select -v28 in our compiler options . For more detailed information, please refer to the DSP CPU Introduction and Assembly Programming Guide.

--large_memory_model

-ml

Generate code in " large memory mode " . If this option is turned on, the compiler will be forced to treat the entire address space as a complete 22- bit wide space (actually divided into 16- bit low address and high address space beyond 16 -bit width), so that the pointer used for addressing is also 22 bits (this pointer is for CPU addressing, not the pointer used in our C program), so that the search space does not have to be limited to 2 to the 16th power, that is, 64K . This mode is suitable for use in C++ programming, so that the compiled code can access storage units in address spaces with a width of more than 16 bits, so there is no 64K word space limit.

So why is it used in C++ programming? Because the current compiler does not support the C++ keyword far ; if you understand C++ keywords, it is easy to understand this pattern using the same idea.

In addition, when FPU is turned on , large memory mode must be turned on, otherwise the compiler will report an error.

When you create a new C2000 project and need to add related library files, if you see that some libraries are rts2800.lib and some are rts2800_ml.lib , you should know which one to use this time. A small suggestion is to save trouble and maintain compatibility. If you have no other concerns, just turn on this option.

--unified_memory

-mt

Generate code in " unified memory mode " . As the name implies, it defines all storage space as a whole, so that the compiler can use RPT and PREAD instructions to handle most of the memory copy memcpy calls and structure allocations during compilation (it also does not need to "worry" about a sudden break in the storage space and being unable to search continuously). For example, the following assembly instructions can be executed more efficiently:

MOVL XAR7, #Array1   ; XAR7 points to array 1

MOVL XAR2, #Array2   ; XAR2 points to array 2

RPT #(N-1) ; Repeat the next instruction N times

||PREAD *XAR2++,*XAR7 ;Array2[i]=Array1[i],i++

We can write such an assembly code manually; if you have a C code for a for loop , take a look at the assembly code generated by the compiler, are they almost exactly the same?

--cla_support[=cla0]

none

--cla_support is a feature available only in the Piccolo series after the C2833x series . It is called a control law accelerator, which means that some codes closely related to the performance of the control system are put into CLA to run independently without taking up CPU time. In this way, the running speed of the entire control software is greatly improved, thus ensuring real-time performance.

--float_support={fpu32|softlib|fpu64}

none

It can only be used when -v28 and -ml are enabled ; it means enabling software processing (such as calling some optimized library functions) and 32- bit or 64 -bit FPU coprocessors for floating-point operations, thereby supporting related assembly instructions.

This sub-option cannot be used at the same time, that is, the usage is:

--float_support=fpu32

Or --float_support=fpu64 etc.

It should be added that the 64 -bit floating-point operation here refers to the data type of long double . In fact, the FPU in DSPs such as 28335 currently only supports 32 -bit FPU operations in hardware . 64- bit floating-point operations must be converted by the CPU and then sent to the FPU for processing. Therefore, if it is not necessary, try not to use operations such as FPU64 .

--vcu_support[=vcu0]

none

VCU is a function available on high-end chips such as F2837xD . It refers to Viterbi and complex unit (VCU II) accelerators , which means that motor failures can be better predicted by performing vibration analysis using viterbi  complex unit  (VCU II) accelerators. The source of the vibration signal is an acceleration sensor or vibration sensor, etc., and popular MEMS can be used , which can be attached to the motor housing, encoder, etc. If you need to use this function, you need to turn it on in the compiler options.


Keywords:DSP Reference address:DSP Programming Tips 2: Unveiling the Mystery of Compilers and Processor Options

Previous article:DSP Programming Skills 1: Let’s talk about the compilation process
Next article:DSP Programming Skills 3: Unveiling the Mystery of Compilers - Program Optimization

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号