Hi, I think I know the reason. It is a misinterpretation of the pin number to be passed to GPIODirModeGet(port, pin) . Refer to the user's guide. As you can see, for GPIODirModeGet, it is expecting a numerical pin number, not a bit-packed representation of the pins . Therefore, for PA1, you would need to input 0x1, not GPIO_PIN_1 because GPIO_PIN_1 is actually 0x00000002 as defined in gpio.h. When I input 0x1 for PA1, it works. GPIOPinConfigure(GPIO_PA1_U0TX); GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_1); tmp = GPIODirModeGet(GPIO_PORTA_BASE, 0x1 ); if (tmp != GPIO_DIR_MODE_HW) { while (1); } GPIOPinTypeGPIOOutput(GPIO_PORTA_BASE, GPIO_PIN_1); tmp = GPIODirModeGet(GPIO_PORTA_BASE, 0x1 ); if (tmp != GPIO_DIR_MODE_OUT) { while (1); }
↧