UART to RS485

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Juar_2150386
Level 4
Level 4
5 likes given First like received First like given

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

0 Likes
1 Solution
Juar_2150386
Level 4
Level 4
5 likes given First like received First like given

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.

View solution in original post

1 Reply
Juar_2150386
Level 4
Level 4
5 likes given First like received First like given

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.