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.

[参考译文] TM4C123GH6PM:HC-SR04超声波模块

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

https://e2e.ti.com/support/microcontrollers/arm-based-microcontrollers-group/arm-based-microcontrollers/f/arm-based-microcontrollers-forum/1253633/tm4c123gh6pm-hc-sr04-ultrasonic-module

器件型号:TM4C123GH6PM

大家好、

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
volatile uint32_t time = 0;
volatile uint32_t Distance = 0;
void HC_SR04_Init(void)
{
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
//enable GPIO_B
GPIOPinTypeGPIOInput(GPIO_PORTB_BASE, GPIO_PIN_4);
GPIOPinTypeGPIOOutput(GPIO_PORTB_BASE, GPIO_PIN_5);
GPIOPinWrite(GPIO_PORTB_BASE ,GPIO_PIN_5 ,0);
}
void Timer0A_Handler(void) {
static uint32_t time_count=0;
//Read Timer Interrupt Status
uint32_t status=TimerIntStatus( TIMER0_BASE, true);
//Clear interrupt flag bit
TimerIntClear( TIMER0_BASE, status);
time ++;
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

使用上述方法的超声波读数始终返回0。  您可以帮助 检查是否需要修改任何内容吗?  谢谢。

此致、

切里

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

    您好、Cherry:

     如果你在计时器 ISR 中放置一个断点、处理器会在这里停止吗?

     另外、在第29行、将时间变量清零、GPIOB4为低电平。 如果时间为零、那么需要计算到零的距离、对吧? 因此可以在示波器上检查引脚输入状态。  

    A 抬头、我在办公室外、直到8/3。