RS485 hardware connection and software for MCXN family

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

RS485 hardware connection and software for MCXN family

RS485 hardware connection and software for MCXN family

1. RS485 hardware connection

RS-485 is a multiple drop communication protocol in which the LPUART transceiver's driver is three-stated unless LPUART is driving. The transmitter can uses the RTS_B signal to enable the driver of a transceiver. The polarity of RTS_B can be configured by firmware to match with the polarity of the transceiver's driver enabling signal.

The following figure shows the receiver enabling signal asserted. This connection can also connect RTS_B to both DE and RE_B. The transceiver's receiver is disabled when the uart transmitter is sending char. A pullup can pull RXD to a non-floating value during this time. You can refine this option further by operating LPUART in Single-Wire mode, freeing the RXD pin for other uses.

 

xiangjun_rong_0-1730685793982.png

 

When the uart transmits character via TXD pin, the RTS_b signal is asserted automatically, after the RS-485 transceiver, the urat transmitter can drive the differential signals Y/Z. When the uart dose not transmit character, the RTS_b signal is unasserted, so the RS-485 transceiver is in tr-state, the differential signal Y/Z is NOT driven by this RS-485 transceiver. For receiver part of the RS-485 transceiver, if the RTS_b sigbal is connected to the RE_b pin of receiver of RS-485 transceiver directly or via an inverter depending on the required logic of the RS-485 transceiver , when the uart transmits character, the receiver of  RS-485 transceiver is disabled, the RO pin of the RS485 is in tri-state, so a pull-up resistor is required on the RO pin and the RXD pin of LPUart can not receive any character from it’s own transmitter.

 The RTS_B signal can function as hardware flow control, but note the application uses RTS_b signal to control RS485 enabling instead of hardware flow control.

)

 

2. RTS_b pin assigmnet.

 

For the uart module of MCXN family, the FCx_P0 is RXD pin of UARTx module, the FCx_P1 is TXD pin of UARTx module, the FCx_P2 is RTS_b of UARTx module.

xiangjun_rong_1-1730686061880.png

For MCXN94x family, the P1_8 pin can function as FC4_P0 or RXD pin of UART4; the P1_9 pin can function as FC4_P1 or TXD pin of UART4; the P1_22 pin can function as FC4_P2 or RTS_b pin of UART4 with setting up PORT1_PCR22[MUX] bits as decimal 3;

xiangjun_rong_2-1730686303719.png

 

3)software

3.1 pin assignment

void BOARD_InitPins(void)

{

    /* Enables the clock for PORT1: Enables clock */

    CLOCK_EnableClock(kCLOCK_Port1);

 

    const port_pin_config_t port1_8_pinA1_config = {/* Internal pull-up/down resistor is disabled */

                                                    kPORT_PullDisable,

                                                    /* Low internal pull resistor value is selected. */

                                                    kPORT_LowPullResistor,

                                                    /* Fast slew rate is configured */

                                                    kPORT_FastSlewRate,

                                                    /* Passive input filter is disabled */

                                                    kPORT_PassiveFilterDisable,

                                                    /* Open drain output is disabled */

                                                    kPORT_OpenDrainDisable,

                                                    /* Low drive strength is configured */

                                                    kPORT_LowDriveStrength,

                                                    /* Pin is configured as FC4_P0 */

                                                    kPORT_MuxAlt2,

                                                    /* Digital input enabled */

                                                    kPORT_InputBufferEnable,

                                                    /* Digital input is not inverted */

                                                    kPORT_InputNormal,

                                                    /* Pin Control Register fields [15:0] are not locked */

                                                    kPORT_UnlockRegister};

    /* PORT1_8 (pin A1) is configured as FC4_P0 */

    PORT_SetPinConfig(PORT1, 8U, &port1_8_pinA1_config);

 

    const port_pin_config_t port1_9_pinB1_config = {/* Internal pull-up/down resistor is disabled */

                                                    kPORT_PullDisable,

                                                    /* Low internal pull resistor value is selected. */

                                                    kPORT_LowPullResistor,

                                                    /* Fast slew rate is configured */

                                                    kPORT_FastSlewRate,

                                                    /* Passive input filter is disabled */

                                                    kPORT_PassiveFilterDisable,

                                                    /* Open drain output is disabled */

                                                    kPORT_OpenDrainDisable,

                                                    /* Low drive strength is configured */

                                                    kPORT_LowDriveStrength,

                                                    /* Pin is configured as FC4_P1 */

                                                    kPORT_MuxAlt2,

                                                    /* Digital input enabled */

                                                    kPORT_InputBufferEnable,

                                                    /* Digital input is not inverted */

                                                    kPORT_InputNormal,

                                                    /* Pin Control Register fields [15:0] are not locked */

                                                    kPORT_UnlockRegister};

    /* PORT1_9 (pin B1) is configured as FC4_P1 */

    PORT_SetPinConfig(PORT1, 9U, &port1_9_pinB1_config);

 

    //* PORT1_22 (pin L4) is configured as FC4_P2 with ALT3*/

 

    const port_pin_config_t port1_22_pinC3_config = {/* Internal pull-up/down resistor is disabled */

                                                       kPORT_PullDisable,

                                                       /* Low internal pull resistor value is selected. */

                                                       kPORT_LowPullResistor,

                                                       /* Fast slew rate is configured */

                                                       kPORT_FastSlewRate,

                                                       /* Passive input filter is disabled */

                                                       kPORT_PassiveFilterDisable,

                                                       /* Open drain output is disabled */

                                                       kPORT_OpenDrainDisable,

                                                       /* Low drive strength is configured */

                                                       kPORT_LowDriveStrength,

                                                       /* Pin is configured as FC4_P1 */

                                                       kPORT_MuxAlt3,

                                                       /* Digital input enabled */

                                                       kPORT_InputBufferEnable,

                                                       /* Digital input is not inverted */

                                                       kPORT_InputNormal,

                                                       /* Pin Control Register fields [15:0] are not locked */

                                                       kPORT_UnlockRegister};

       /* PORT1_9 (pin B1) is configured as FC4_P1 */

       PORT_SetPinConfig(PORT1, 22U, &port1_22_pinC3_config);

}

 

The

 

//P1_22 function as RTS_b signal

void RTS_b_init(LPUART_Type *base)

{

 base->MODIR |=LPUART_MODIR_TXRTSE(1); //                   (((uint32_t)(((uint32_t)(x)) << LPUART_MODIR_TXRTSE_SHIFT)) & LPUART_MODIR_TXRTSE_MASK)

 

}

 

4)uart timing tested by scope

xiangjun_rong_3-1730686359583.png

 

Conclusion:

From the above scope screen shot, you can see that when the uart transmitter sends char, the RTS_b signal becomes low, so it can function as RS485 transceiver enabling signal.

 

无评分
版本历史
最后更新:
‎11-03-2024 07:47 PM
更新人: