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.

[参考译文] CCS/TM4C123GE6PM:仅通过 USB 使用 UART printf (而是将 UART1用于蓝牙)

Guru**** 2387830 points
请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/microcontrollers/arm-based-microcontrollers-group/arm-based-microcontrollers/f/arm-based-microcontrollers-forum/633199/ccs-tm4c123ge6pm-using-uart-printf-beyond-just-through-usb-using-uart1-instead-for-bluetooth

器件型号:TM4C123GE6PM

工具/软件:Code Composer Studio

您好!

我使用 TI Resource Explorer 中的 UART 控制台示例尝试确定如何实现 printf 函数以将数据显示为 PuTTy。 完成代码组合后、我注意到该示例经过专门编码、可通过 USB 和 UART0运行。

我想知道、我是否可以通过某种方法来使用 UART1、而不是在蓝牙模块的连接位置。

我已将下面的示例代码附在.txt 文件中。  /cfs-file/__key/communityserver-discussions-components-files/908/uartconsole.txt

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。
    亨利

    首先、您需要将 UART1添加到"board"文件中。 我们将其填充足够多、以便所有开箱即用示例都能正常工作。 我们不会将所有外设都放入其中、因为有些外设是相互排斥的。 因此、您需要执行以下操作(假设您仍然需要使用 UART0)

    EK_TM4C1294XL.h:添加 UART1。 以了解示例
    typedef 枚举 EK_TM4C1294XL_UARTName{
    EK_TM4C1294XL_UART0 = 0、
    EK_TM4C1294XL_UART1 = 1、

    EK_TM4C1294XL_UARTCOUNT
    }EK_TM4C1294XL_UARTName;

    注意:EK_TM4C1294XL_UARTCOUNT 值会自动增大

    EK_TM4C1294XL.c:为 uartTivaHWAttrs 和 UART_CONFIG 填入索引1位置

    Board.h:如果需要、添加 Board_UART1。 我们拥有此文件、以便让我们可以在多个电路板和器件上使用示例。
    #define Board_UART0 EK_TM4C1294XL_UART0
    #define Board_UART1 EK_TM4C1294XL_UART1

    接下来、您需要更改 uartconsole.c 以使用 UART1
    freopen ("UART:1"、"w"、stdout);
    freopen ("UART:1"、"r"、stdin);

    最后更改 UARTUtils.c 以添加到第二个索引中

    #define NUM_PORTS 2.
    静态 UARTPorts 端口[NUM_PORTS]={
    {NULL、Board_UART0、0、false}
    {NULL、Board_UART1、0、false}
    };

    我刚刚注意到、UARTPorts 结构中的注释/字段名称不是最好的...

    Todd
  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。
    感谢你的帮助。

    **其他用户的备注**
    确保在 #define语句中使用特定的电路板名称。