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.

关于TM4C123G引脚检测电平



我使用TM4C123G,设置PC4~Rx   PC5~Tx   为串口引脚读陀螺仪,使能PWM0模块使用PB4/5/6/7输出PWM,  超声波测距PA4-------triq  PA5-------ecno。然后其它口都没用,然后想用其它的口读到一个高电平就亮灯并输出PWM。结果发现程序运行后,陀螺仪等都是正常的,但是GPIO口就是读不出电平,导致下面的程序不运行。反复尝试了几乎所有的口,就只有PB3可以用,程序都一样。为什么会这样?难道是引脚还能被占用?

SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);

GPIOPinTypeGPIOInput(GPIO_PORTB_BASE, GPIO_PIN_3);//ROM

if(GPIOPinRead(GPIO_PORTA_BASE, GPIO_PIN_3))
     {
      GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_2, GPIO_PIN_2);   //测试
       while(1)
                                  {
                                       PWMPulseWidthSet(PWM0_BASE, PWM_OUT_0, 1562); //PB6
                                  PWMPulseWidthSet(PWM0_BASE, PWM_OUT_1, 1562); //PB7
                                  PWMPulseWidthSet(PWM0_BASE, PWM_OUT_2, 1562); //PB4
                                  PWMPulseWidthSet(PWM0_BASE, PWM_OUT_3, 1562); //PB5
                                  }
     }