UART Initialization: UART Deny High RTS

I am writing an RS485 driver for an ARM AT91SAM9260 board on Linux.

When I initialize the UART, the RTS signal line becomes high (1). I assume that this will and should be standard behavior in RS232 mode. However, in RS485 mode this is not required.

I use the standard functions provided by the arm-arch section to initialize UART. Therefore, the important 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Γ  

As you can see with

at91_set_B_periph (AT91_PIN_PC8,0);

pull-up on the RTS pin is not activated.

  • Why did UART set RTS to high? Just because it will be standard behavior in RS232 mode?

  • Isn't it the best standard for UART to keep silent until the operating mode is explicitly set?

+4
source share
1 answer

A high RTS signal after initialization appears to be standard behavior on many platforms. This courageously depends on which sequential mode runs the startup routines for the interface.

To prevent the RTS high level on an ATMEL AT91SAM9260 board running Linux, you must put the UART in the correct mode before multiplexing at91_set_X_periph () and register the device.

Since Linux Kernel is version 2.6.35, the ATMEL serial driver supports RS485 mode. In this driver, UART is configured correctly before installing roles (GPIO) on it.

For my embedded device on which an older version of Linux is installed, 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 can now multiplex their role

at91_set_X_periph (RTS_PIN, 0);

+3
source

Source: https://habr.com/ru/post/1339175/


All Articles