Skip to main content
Visitor II
January 21, 2009
Question

Connecting UART2 to RS485 (Delivery Enable problem)

  • January 21, 2009
  • 2 replies
  • 746 views
Posted on January 21, 2009 at 03:50

Connecting UART2 to RS485 (Delivery Enable problem)

    This topic has been closed for replies.

    2 replies

    avneraAuthor
    Visitor II
    May 17, 2011
    Posted on May 17, 2011 at 09:57

    Hi,

    I'm having problems controlling the delivery-enable output while using UART2 with RS485 (working with FreeRTOS)

    since the RS485 is half duplex, i have to control the DE status. when i finish transmitting i turn back the DE to allow reception.

    i have to check when the bytes are actually TXed before i reset the output.

    i tried using the following code to check when the FIFO is not busy, this busy-waiting is causing problems with the FreeRTOS

    portENTER_CRITICAL();

    {

    while (UART2->FR&0x0008);

    }

    portEXIT_CRITICAL();

    i also tried:

    while (UART_GetFlagStatus(UART2, UART_FLAG_Busy)==RESET);

    UART_ClearFlag(UART2);

    and even tried using xSemaphoreHandle in the UART2_IRQHandler upon any TXed byte but that did not work.

    any ideas?

    Thanks in advanced.

    Avner.

    avneraAuthor
    Visitor II
    May 17, 2011
    Posted on May 17, 2011 at 09:57

    i'm in the process of implementing the loop-back method mentioned by paul smitton and verified by Mark.

    one important issue about this - you must disable the FIFO otherwise you will get the ''incoming'' bytes in delay.

    any comments?