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.

RS485 implementation using TI RTOS UART drivers

Hi , Iam trying to implement RS 485 protocol in TIVA C series controllers and Iam using TI RTOS. Iam using the UART drivers of TI RTOS for writing and reading the data. Iam also using GPIO driver API's to enable the TX in RS485 drivers. 

For Transmitting data iam doing following steps -

1) Make The TXEN pin of RS485 driver high using GPIO_write API.

2) Write the data on to the serial port using UART_write()

3) Make the TXEN pin of RS485 driver low using GPIO_write API.

If I don't give proper delay after writing data to serial port , then i get nothing in RS485 output. If I give higher delay, I could see the same data coming over RS485 multiple times. I want to know when should I drive the RS485 driver TXEN low so that I get proper RS485 output.

  • Hi, Can Anyone please reply on the thread. Below is the snapshot of my code which iam using for RS485 implementation. Iam running this code in one of the task -
    RS485GateKey = GateTask_enter(gatetask);

    GPIO_write(Board_RS485, 1);

    UART_write(RS485Handle,Buffer,length);

    GPIO_write(Board_RS485, 0);

    GateTask_leave(gatetask, RS485GateKey);

    Now If i try to introduce a delay after UART_write() using Task_sleep() or a for loop, the entire program crashes. Can Anyone tell me what is wrong with the program.
  • Hi Sandeep,
    GateTask_enter() disables the Task scheduler, so you cannot call Task_sleep() within the GateTask_enter() / GateTask_leaveBlock(). Also, UART_write() will call Semaphore_pend() (in blocking mode), an that also cannot be called with Task scheduling disabled. Can you try using a semaphore to pend on instead of the GateTask_enter(), and see if that fixes the problem?
    Best regards,
    Janet
  • Hi Thanks for the reply, In the Same program now Iam reading from UART through UART_read() API of TI RTOS. Now in another task I am using CAN on Interrupt using CAN Tivaware API's.
    Now if I run the Task with CAN interrupts, my UART_read() function causes the program to terminate.

    Can anyone tell me if the Tivaware CAN API's are causing the issue. As if i stop the Task my UART_read() function works properly.
  • Hi Sandeep,
    How is your program terminating? Are you getting an exception? If so, maybe you can use ROV to see the exception.
    Thanks,
    Janet