2161 views|1 replies

2015

Posts

0

Resources
The OP
 

Ti's DSP program is programmed in C++ [Copy link]

In embedded development, older developers are more accustomed to using C language; and young people are also taught in C language when they are learning. In fact, using C++ for embedded development is also a very good choice, and it may be a trend in embedded programming in the future. The following lists some ways to use C++ in embedded development, mainly in the development environment of Ti's CCS5 and above. The use of inline functions For short function calls, they are generally declared as inline functions in the header file. When the code that calls the inline function is compiled, the execution code of the inline function will be directly inserted without the occurrence of function calls. Although macro substitution can also achieve the function and performance of inline, the compiler performs strict type checking on inline functions, thereby reducing errors in the program. For example: Encapsulate simple statements to simplify the writing of calling code. /** * Enable global interrupt*/ inline void eint(){ asm(" clrc INTM"); } /** * Disable global interrupt*/ inline void dint(){ asm(" setc INTM"); } /** * Enable global real-time interrupt* Usually called after eint()*/ inline void ertm(){ asm(" clrc DBGM"); } Encapsulate the parameters of the function call to make the function clear at a glance. inline void enableInt1(){ enableInt(0); } inline void enableInt2(){ enableInt(1); } inline void enableInt3(){ enableInt(2); } inline void enableInt4(){ enableInt(3); } inline void enableInt5(){ enableInt(4); } inline void enableInt6(){ enableInt(5); } inline void enableInt7(){ enableInt(6); } inline void enableInt8(){ enableInt(7); } inline void enableInt9(){ enableInt(8); } inline void enableInt10(){ enableInt(9); } inline void enableInt11(){ enableInt(10); } inline void enableInt12(){ enableInt(11); } Using constants It is often necessary to define some system constants in a program, and they are generally defined as constants. Similarly, macro definitions can also define constants, but the compiler does not perform type checking on macros. Function parameters use references. Memory is often an important resource in embedded systems. During program writing, try to minimize memory usage. inline void set( const int& i ){ m_set |= (0x0001<

If C language is basically sufficient, there is no need to use C++. Embedded systems do not have any special requirements for the language.

Ti's DSP program is programmed in C++
This post is from Microcontroller MCU

Latest reply

If C language is basically sufficient, there is no need to use C++. Embedded systems do not have any special requirements for the language.   Details Published on 2024-5-22 09:50
 

277

Posts

0

Resources
2
 

If C language is basically sufficient, there is no need to use C++. Embedded systems do not have any special requirements for the language.

This post is from Microcontroller MCU
 
 

Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list