LM3S5B91 PB7无法输出高电平,求助?



LM3S5B91 PB7无法输出高电平,仿真时,寄存器是有变化的,但输出的电平始终是低电平。

  • B7默认为NMI特殊功能管脚,要想配置为普通IO口需要特殊操作,数据手册里有说明

       //

       // Convert the PB7/NMI pin into a GPIO pin. This requires the use of the

       // GPIO lock since changing the state of the pin is otherwise disabled.

       //

       HWREG(GPIO_PORTB_BASE + GPIO_O_LOCK) = GPIO_LOCK_KEY_DD;

       HWREG(GPIO_PORTB_BASE + GPIO_O_CR) = 0x80;

       //

       // Make PB7 an output.

       //

       GPIODirModeSet(GPIO_PORTB_BASE, GPIO_PIN_7, GPIO_DIR_MODE_OUT);

       GPIOPadConfigSet(GPIO_PORTB_BASE, GPIO_PIN_7, GPIO_STRENGTH_8MA,

       GPIO_PIN_TYPE_STD);

       //

       // Clear the commit register, effectively locking access to registers

       // controlling the PB7 configuration.

       //

       HWREG(GPIO_PORTB_BASE + GPIO_O_LOCK) = GPIO_LOCK_KEY_DD;

       HWREG(GPIO_PORTB_BASE + GPIO_O_CR) = 0x00;

  • 谢谢,问题解决了!!!