关于LM3S9B96的第89管脚PB7的使用



PB7也就是LM3S9B96的第89管脚,数据手册中说可以作为GPIO用,也可以作为NMI,但是我将其配置为GPIO输入后,给它一个高电平,在程序中采集到的却是低电平(进入调试模式后发现的);将其设置为GPIO输出后,程序中设定为输出高电平,但是在管脚上测量得到的电压却是低电平,也就是说程序中设定的没有作用,不知道什么原因造成的。
刚开始怀疑是管脚虚焊,但是检查了没有问题;怀疑是芯片本身有问题,后来拿第二块电路板试了一下还是不行,原因仍然不能查出。
是该管脚根本就不能作为GPIO来使用呢,还是我的这批芯片有问题呢?我的LM3S9B96是C3版本的,看了勘误手册也没有发现此管脚有bug啊,究竟是怎么回事呢?

  • 如果楼主能把你的代码贴上来会比较好定位原因,关于PB7的配置是需要解锁的,不知道楼主有没有这个步骤,我写了一个简单的测试代码,从PB7上输出方波,希望对楼主有用:

    #include "inc/lm3s9b96.h"

    int
    main(void)
    {
        volatile unsigned long ulLoop;

        //
        // Enable the GPIO port that is used for the on-board LED.
        //
        SYSCTL_RCGC2_R = SYSCTL_RCGC2_GPIOF;
     SYSCTL_RCGC2_R |= SYSCTL_RCGC2_GPIOB;//enable PB//////////////////////////////////////////////////////////////////

        //
        // Do a dummy read to insert a few cycles after enabling the peripheral.
        //
        ulLoop = SYSCTL_RCGC2_R;

        //
        // Enable the GPIO pin for the LED (PF3).  Set the direction as output, and
        // enable the GPIO pin for digital function.
        //
        GPIO_PORTF_DIR_R = 0x08;
        GPIO_PORTF_DEN_R = 0x08;
     ///////////////////////////////////////////////////////////////
     GPIO_PORTB_LOCK_R = 0x4C4F434B;//unlock the GPIOCR register
     GPIO_PORTB_CR_R |= 0x80;//unlock the PB7
     GPIO_PORTB_AFSEL_R &=~0x80;//setting PB7 as normal GPIO

     GPIO_PORTB_DIR_R = 0x80;//PB7 as output///////////////////////////////////////////////////////////////////////////
        GPIO_PORTB_DEN_R = 0x80;//enable PB7///////////////////////////////////////////////////////////////////////////

        //
        // Loop forever.
        //
        while(1)
        {
            //
            // Turn on the LED.
            //
            GPIO_PORTF_DATA_R |= 0x08;
      GPIO_PORTB_DATA_R |= 0x80;////////////////////////////////////////////////////////////////////////////

            //
            // Delay for a bit.
            //
            for(ulLoop = 0; ulLoop < 200000; ulLoop++)
            {
            }

            //
            // Turn off the LED.
            //
            GPIO_PORTF_DATA_R &= ~(0x08);
      GPIO_PORTB_DATA_R &= ~(0x80);///////////////////////////////////////////////////////////////////////////

            //
            // Delay for a bit.
            //
            for(ulLoop = 0; ulLoop < 200000; ulLoop++)
            {
            }
        }
    }

  • 楼主检查一下是否使能了GPIO B的时钟?