This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
大家好、当我在 TM4C129ENCPDT 的数据表中阅读 GPIO 寄存器说明时、我对位的含义感到困惑。 例如 GPIOAFSEL 寄存器、7:0位是 GPIO 备用功能选择。 例如、我会选择 UART0作为 GPIO 端口 A、我如何知道应该选择哪些位? 7:0位包含256个变量、我猜这些变量是针对引脚编号进行配置的吗? 我尝试阅读数据表时无法了解如何选择这些7:0位来在 GPIO 中配置 UART0 (引脚33、34)?
关于 GPIO 端口控制寄存器(GPIOPCTL)、描述再次令人困惑。 例如端口复用控制0:该域控制 GPIO 管脚0的配置。 这个"引脚0"不是"物理引脚0"。 该寄存器中 GPIO 引脚0-7的定义/含义是什么?
非常感谢您的友好帮助!
您好 Bin、
GPIOAFSEL 将寄存器的8个位映射到8个 GPIO 引脚。 每个引脚为0或1。 如果该引脚为0、则该引脚用作 GPIO。 如果它为1、则该引脚由另一个外设使用。
例如、将 UART0与端口 A 一起使用、寄存器应读取0x03、因为位0和位1应设置为"1"、以指示端口 A0和 A1将被另一个外设(UART)使用。
表29-5。 应参考 GPIO 引脚和备用功能。
或者、您可以跳过所有这些详细信息、只需使用提供的 TivaWare API、这些 API 会为您处理所有这些内容、如下例所示:
/* Enable GPIO port A which is used for UART0 pins. */ SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA); /* Configure the pin muxing for UART0 functions on port A0 and A1. */ GPIOPinConfigure(GPIO_PA0_U0RX); GPIOPinConfigure(GPIO_PA1_U0TX); /* Select the alternate (UART) function for these pins. */ GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);
此致、
Ralph Jacobi
您好、Ralph、
非常感谢您的友好解释。
BR、Bin