Thread 中讨论的其他器件:EK-TM4C123GXL
大家好、
我正在尝试创建一个应用、其中 Tiva 被配置为 USB 器件、通过串行端口进行下行通信。
我已经成功通过 USB_DEV_BULK 示例测试、其中 PC 向 USB 器件发送一个字符串、该字符串由 cap 回答。
现在、我将修改此示例、以使用 UART 将通过 USB 从 PC 接收到的字符串发送到另一个器件。 使用 UART0没有问题、购买时我无法使用不同的 UART 使其运行、即使使用不同于 UART0的 UART 也会阻止 USB 通信。
这是我的 UART 配置:
//UART4 SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC); SysCtlPeripheralEnable(SYSCTL_PERIPH_UART4); GPIOPinConfigure(GPIO_PC4_U4RX); GPIOPinConfigure(GPIO_PC5_U4TX); GPIOPinTypeUART(GPIO_PORTC_BASE, GPIO_PIN_4 | GPIO_PIN_5); UARTClockSourceSet(UART4_BASE, UART_CLOCK_PIOSC); UARTStdioConfig(4, 115200, 16000000);
在 main 的后面部分,从 USB 接收后,我只需使用 UARTSend 函数:
.... UARTSend(UART4_BASE, (uint8_t*)tx_buffer, 6); .... //***************************************************************************** // // Send a string to the UART. This function sends a string of characters to a // particular UART module. // //***************************************************************************** void UARTSend(uint32_t ui32UARTBase, const uint8_t *pui8Buffer, uint32_t ui32Count) { // // Loop while there are more characters to send. // while(ui32Count--) { // // Write the next character to the UART. // MAP_UARTCharPut(ui32UARTBase, *pui8Buffer++); } }
上述代码对于 UART0来说是完美的、但对于其他 UART 则不是如此。 我认为我非常关注 GPIO、端口... 配置。
有什么想法或可能的原因?
此致