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.

[参考译文] EK-TM4C123GXL:使用串行通信协议 UART 通过端口 D 引脚 PD6和 PD7时出现问题

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

https://e2e.ti.com/support/microcontrollers/arm-based-microcontrollers-group/arm-based-microcontrollers/f/arm-based-microcontrollers-forum/1078569/ek-tm4c123gxl-issue-using-serial-communication-protocol-uart-through-port-d-pins-pd6-and-pd7

部件号:EK-TM4C123GXL
“线程”中讨论的其它部件:TM4C123GH6PM

对其可能关注的人,

我尝试使用端口 D 引脚 PD6 和 PD7进行 UART 通信,但未成功。 我已经完成了适当设置 PIN 的步骤,我想了很多。 随附了一份 txt 文档,其中包含用于为 UART 设置端口 D 的代码以及 TI Launchpad (TM4C123GH6PM)的数据表。 以下是我完成的步骤。

) 通过写入 GPIOLOCK 寄存器(PG.684)解锁引脚 PD7

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// ***** 1. Pre-processor Directives Section *****
#include <stdio.h> // standard C library
//This program prompts the user to enter a g (green), b (blue), or r (red) in the command UART window and responds by turning on the approporiate LED.
//If an entry is wrong the user is prompted again.
#define RCGCUART_UART_CLOCKING (*((volatile unsigned long *)0x400FE618))//Writing to this register to control the clocking of the UART modules (PORTD)(PG.344)
#define GPIOAMSEL_GPIO_ANALOG_ENABLE_DISABLE (*((volatile unsigned long *)0x40007528))//Disabling the analog function (PG.687)
#define RCGC2_GPIO_CLOCK (*((volatile unsigned long *)0x400FE108)) //Clock enable for legacy software (PG.464) Legacy register.
#define RCGCGPIO_CLOCK_ENABLE (*((volatile unsigned long *)0x400FE608))//Enabling the clock to PORTD by writing to this register (PG.340)
#define GPIOAFSEL_ALTFUNCTION_CONTROL (*((volatile unsigned long *)0x4007420))//Setting the pins in this register to allow pins in PORTD to be controlled by an alt function (PG.671_
#define GPIOPCTL_ALTFUNCTION_SELECT (*((volatile unsigned long *)0x4000752C))//Selecting which pins your applying the alt function to(PG.688)
#define GPIODEN_DIGITAL_PIN_ENABLE (*((volatile unsigned long *)0x4000751C))//Enabling PORTD pins as digital I/O (PG.682)
#define UARTCTL_UART_ENABLE_DISABLE (*((volatile unsigned long *)0x4000E030))//Disabling the UART to setup the baud rate, serial parameters, and UART2 clock source (PG.918)
#define UARTIBRD_UART_BAUDRATE_INTEGER (*((volatile unsigned long *)0x4000E024))//Writing the appropriate value for the integer part of the baud rate UART2 (PG.914)
#define UARTFBRD_UART_BAUDRATE_FRACTIONAL (*((volatile unsigned long *)0x4000E028))//Writing the appropriate value for the fractional part of the baud rate for UART2 (PG.915)
#define UARTLCRH_SERIAL_PARAMETERS (*((volatile unsigned long *)0x4000E02C))//Setting up the serial parameter (data length, parity pits, stop bits, etc.) for UART2 (PG.916)
#define UARTCC_UART_CLOCK_SOURCE (*((volatile unsigned long *)0x4000EFC8))//Configuring the UART2 clock source (PG.939)
//The next define statements are for the LED_Config() function
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

2) 通过向 GPIOCR 寄存器(PG)写入引脚 PD7 685)

(第3条) 为向 RCGCUART 寄存器(PG)写入 UART 模块2启用时钟 344)

4) 为向 RCGCGPIO 寄存器(PG)写入 GPIO PortD 启用时钟 340)

(第5条) 通过向 GPIOAFSEL 寄存器(PG)写入数据,允许外围设备控制引脚 PD6和 PD7 671)

(第6条) 通过向 GPIOPCTL 寄存器(PG)写入数据,选择引脚 PD6和 PD7的外围模式 688)

(第7条) 通过向 GPIODEN 寄存器(PG)写入数据,为引脚 PD6和 PD7启用数字输入/输出。 682)

(第8条) 禁用 UART 模块#2,以便我可以通过写入 UARTCTL 寄存器(PG)来设置波特率和串行参数。 (918)

(第9条) 通过写入 UARTIBRD 寄存器(PG)来设置波特率的整数部分。 914)

(第10条) 通过写入 UARFBRD 寄存器(PG。 915)

(第11条) 通过向 UART 寄存器(PG. (916)

UART 模块#2具有9600bps 波特率,8位,无奇偶校验和1个停止位

12) 通过写入 UARTCC 寄存器(PG.939)设置波特时钟源

(第13条)  通过写入 UARTCTL 寄存器(PG。 (918)

(第14条) 通过向 GPIOAMSEL 寄存器(PG.687)写入数据,禁用引脚 PD6和 PD7上的模拟功能

 

我想包括数据表,但无法上传。 这是标题(TIVA TM4C123GH6PM 微控制器数据表)

谢谢你,

顿纳利米

S.E.

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

    你好,Donnalley,

    我们不支持在 E2E 论坛上使用此类直接注册编码。 我建议您使用 TiaWare 来获得一个有效的示例,然后查看用于查看如何配置寄存器的 TiaWare API。

    我们的声明关于:直接注册修改可在以下第4页查看: https://e2e.ti.com/support/f/908/695568/faq-faqs-for-tm4c-arm-cortex-m4f-microcontrollers

    此致,

    拉尔夫·雅各比