PB7默认为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;
|