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.

[参考译文] CCS/TM4C1294NCPDT:HC - SR04测量距离问题

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

https://e2e.ti.com/support/microcontrollers/arm-based-microcontrollers-group/arm-based-microcontrollers/f/arm-based-microcontrollers-forum/749701/ccs-tm4c1294ncpdt-hc---sr04-measuring-distance-problem

已删除

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

    首先、您是否了解过 HC-SR04的输出并验证您是否正在触发它并获得正确的响应?

    (原员额更正。 测量时间是从触发到回波的时间、而不是回波信号的长度。)

    timer0中捕获的值是以 us 为单位的时间。 (16MHz、带/16预分频。) 将该数字除以58即可得到以 cm 为单位的距离。 如果需要更高的分辨率、请使用浮点值而不是整数。


    确保保护计时器输入捕捉引脚 PL4。 HC-SR04是一款5V 器件、TM4C1294N 具有3.3V I/O 一个串联的1K 欧姆电阻器应该能够充分限制电流。