This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

请教个问题



 为什么TI所有的电机控制的库的算法,都是通过宏定义#define XXXX  的形式写的,

 想请教一下,宏写的算法,比用一般函数写的算法,有什么优势么?

  • 木有函数调用,省去出入栈的时间。就是所谓的 宏函数,这是C语言的一种技巧。这种方法使程序顺序执行,没有函数调用引发的跳转和出入堆栈。优势就是省时间,电机控制时间非常宝贵,贵在实时性。

    但是不建议滥用这种方法,不利于维护。核心驱动代码建议这样做。