1 Reply Latest reply on Sep 28, 2018 4:57 AM by Juar_2150386 Branched to a new discussion.

    UART to RS485

    Juar_2150386

      Hi, I'm using a custom board BCM20736S.

      I use the UART (P32, P35) to communicate with a computer. This work fine with no problem.

      But now, I would like to use an UART - RS485 convert to communicate in RS485. So I need to set and clear two IO for receive and transmit data (/RE and DE IO of a ST4385EDC for example). I have try with this code (with and without delay):

       

      gpio_setPinOutput(GPIO_DE_RS485 / 16, GPIO_DE_RS485 % 16, CS_ASSERT);

      gpio_setPinOutput(GPIO_RE_RS485 / 16, GPIO_RE_RS485 % 16, CS_ASSERT);

      //bleapputils_delayUs(1000000);

      puart_write('0');

      puart_write('1');

      puart_write('2');

      puart_write('3');

      //bleapputils_delayUs(1000000);

      gpio_setPinOutput(GPIO_DE_RS485 / 16, GPIO_DE_RS485 % 16, CS_DEASSERT);

      gpio_setPinOutput(GPIO_RE_RS485 / 16, GPIO_RE_RS485 % 16, CS_DEASSERT);

       

      But my computer not receive the data....I think the write uart function is not executed in time...

      Do you have a solution for my problem?

       

      Thanks in advance

      J.A

        • 1. Re: UART to RS485
          Juar_2150386

          solved!

           

          I use static void puart_control_tx_callback(void* unused) and I do:

           

          gpio_setPinOutput(GPIO_DE_RS485 / 16, GPIO_DE_RS485 % 16, CS_DEASSERT);

          gpio_setPinOutput(GPIO_RE_RS485 / 16, GPIO_RE_RS485 % 16, CS_DEASSERT);

           

          in the callback function when all data are sent.

          1 of 1 people found this helpful