1# rainbow99
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; |