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.

[参考译文] TMS570LS1224:表达式必须具有算术类型

Guru**** 2546020 points


请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/microcontrollers/arm-based-microcontrollers-group/arm-based-microcontrollers/f/arm-based-microcontrollers-forum/978469/tms570ls1224-expression-must-have-arithmetic-type

器件型号:TMS570LS1224

我在尝试编译代码时遇到此错误

struct hetSIGNAL_t duration;

float distance;



capGetSignal (hetRAM1、cap0、&duration);

distance = duration * 0.034 / 2; 

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好!

    1。  structhetSIGNAL_t  duration;  --> please remove struct

     2.距离=持续时间* 0.034 / 2; -->持续时间是一个结构,不能在该公式中使用。 请更改为持续时间.期间或持续时间.占空比。

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    我编辑了代码、但仍然有相同的错误

     hetSIGNAL_t  duration;

    floatdistance;
     capGetSignal(hetRAM1,cap0, &duration);
    distance =( duration.period * 0.034) / 2;
  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    如果 "het.h"未包含、则会出现编译错误。

    代码中没有问题