I am trying to use a Raspberry Pi 4 model B to drive the DE enable signal of a MAX485 for half-duplex RS485 communication.
I have connected the UART0 data signals (GPIO 14 & 15) and am trying to use RTS (GPIO 17) to enable the TX section of MAX485.
I was able to enable the RTS signal by writing this device tree overlay:
Code: Select all
/dts-v1/;
/plugin/;
/{
compatible = "brcm,bcm2835";
fragment@0 {
target = <&uart0>;
__overlay__ {
pinctrl-names = "default";
pinctrl-0 = <&uart0_pins>;
status = "okay";
};
};
fragment@1 {
target = <&gpio>;
__overlay__ {
uart0_pins: uart0_pins {
brcm,pins = <14 15 17>;
brcm,function = <4 4 7>; //alt0 alt0 alt3
brcm,pull = <0 2 0>;
};
};
};
};
Using an oscilloscope, I checked the TX (CH2) and RTS signal (CH1):
As you can see, while the TX line transmits a byte, the RTS signal has a negative pulse.
The pulse is slightly longer than the transmitted data, but the actual problem is that the MAX485 (and almost all other RS485 signal translators) needs a HIGH signal to enable the TX.
Do you know if/how I can invert the RTS?
--
Francesco