UART 初始化:防止 UART 将 RTS 拉高 [英] UART initialisation: Prevent UART to pull RTS high

查看:56
本文介绍了UART 初始化:防止 UART 将 RTS 拉高的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为 Linux 上的 ARM AT91SAM9260 板编写 RS485 驱动程序.

I'm writing a RS485 driver for an ARM AT91SAM9260 board on Linux.

当我初始化 UART 时,RTS 信号线变高 (1).我想这将并且应该是 RS232 操作模式下的标准行为.然而,在 RS485 模式下,这是不想要的.

When I initialise the UART, the RTS signal line gets high (1). I guess this would and should be the standard behaviour in RS232 operation mode. In RS485 mode however this is not wanted.

我正在使用 arm-arch 部分提供的标准函数来初始化 UART.因此,重要的步骤是:

I'm using the standard functions provided by the arm-arch section to initialise the UART. Therefore the significant steps are:

at91_register_uart(AT91SAM9260_ID_US2, 3, ATMEL_UART_CTS | ATMEL_UART_RTS);
//consisting of:

// >> configure/mux the pins
    at91_set_A_periph(AT91_PIN_PB10, 1);        /* TXD */
    at91_set_A_periph(AT91_PIN_PB11, 0);        /* RXD */

    if (pins & ATMEL_UART_RTS)
        at91_set_B_periph(AT91_PIN_PC8, 0);     /* RTS */
    if (pins & ATMEL_UART_CTS)
        at91_set_B_periph(AT91_PIN_PC10, 0);    /* CTS */

// >> associate the clock
axm_clock_associate("usart3_clk", &pdev->dev, "usart");

// >> et voilà

正如你所看到的

at91_set_B_periph(AT91_PIN_PC8, 0);

at91_set_B_periph(AT91_PIN_PC8, 0);

RTS 引脚上的上拉未激活.

the pull-up on the RTS pin isn't activated.

  • 为什么 UART 将 RTS 设置为高电平?只是因为这将是标准RS232 模式下的行为?

  • Why does the UART set the RTS high? Just because this would be the standard behaviour in RS232 mode?

这不是更好的标准吗?UART保持沉默直到
操作模式是否明确设置?

Wouldn't it be a better standard for the UART to keep silent till the
operation mode is explicitly set?

推荐答案

初始化后的高 RTS 信号似乎是许多平台上的标准行为.这主要取决于启动例程为接口预期哪种串行操作模式.

A high RTS signal after initialisation seems to be the standard behaviour on many platforms. It manly depends which serial operation mode the start-up routines anticipates for the interface.

为了防止在运行 Linux 的 ATMEL AT91SAM9260 板上出现 RTS 高电平,您必须在多路复用 at91_set_X_periph() 引脚并注册设备之前将 UART 置于正确模式.

To prevent RTS-high on a ATMEL AT91SAM9260 board running Linux, you have to put the UART into the right mode BEFORE muxing at91_set_X_periph() the Pins and register the device.

自 Linux 内核版本 2.6.35 起,ATMEL 串口驱动支持 RS485 模式.在此驱动程序中,在将引脚 (GPIO) 设置为角色之前正确配置了 UART.

Since Linux Kernel Version 2.6.35, the ATMEL serial driver supports the RS485 mode. In this driver the UART is properly configured before setting the Pins (GPIO) to there role.

对于运行较旧 Linux 版本的嵌入式设备,我使用以下代码行解决了问题:

For my embedded device which is running an older Linux version, I solved the problem with the following line of codes:

/* write control flags */

control |= ATMEL_US_RTSEN;
mode |= ATMEL_US_USMODE_RS485;  

  UART_PUT(uartbaseaddr, ATMEL_US_CR, control);
  UART_PUT(uartbaseaddr, ATMEL_US_MR,mode);

现在可以混合 Pins 的角色

Now the Pins can be muxed the their role

at91_set_X_periph(RTS_PIN, 0);

at91_set_X_periph(RTS_PIN, 0);

这篇关于UART 初始化:防止 UART 将 RTS 拉高的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆