To take evkbimxrt1050_freertos_lpuart for example, the flow control is disable by default. Using MAX485 for RS-485 circuit design, it need to enable the hardware flow control for transfer direction (TX, RX).
Can you show me how to enable hardware flow control for RS-485 usage in this example?
Hello, i have the same issue, i'm using 3 uart (3,4,5) and i need to use rts to controll the flow but is the same, i can receive because the rts pin is low, when i transmit i see the data on tx pin but the rts remains low!
i don't use the cts, only rts.
this is my code:
lpuart_config_t config2;
LPUART_GetDefaultConfig(&config2);
config2.baudRate_Bps = sys.MB_baud[0];
config2.enableTx = true;
config2.enableRx = true;
config2.enableRxRTS = true;
LPUART_Init(MB1, &config2, MB_CLK_FREQ);
LPUART_EnableInterrupts(MB1, kLPUART_RxDataRegFullInterruptEnable);
EnableIRQ(MB1_IRQn);
PRINTF("-MB1: enabled\r\n");
Hi Felix:
What you need to do is
1. initialize CTS/RTS pin in pin_mux.c/h. By default, the two pins is not initialized.
2. enable CTS/RTS function in devices/mimxrt1052/drviers/fsl_lpuart.c, please see below red lines
void LPUART_GetDefaultConfig(lpuart_config_t *config)
{
assert(NULL != config);
/* Initializes the configure structure to zero. */
(void)memset(config, 0, sizeof(*config));
config->baudRate_Bps = 115200U;
config->parityMode = kLPUART_ParityDisabled;
config->dataBitsCount = kLPUART_EightDataBits;
config->isMsb = false;
#if defined(FSL_FEATURE_LPUART_HAS_STOP_BIT_CONFIG_SUPPORT) && FSL_FEATURE_LPUART_HAS_STOP_BIT_CONFIG_SUPPORT
config->stopBitCount = kLPUART_OneStopBit;
#endif
#if defined(FSL_FEATURE_LPUART_HAS_FIFO) && FSL_FEATURE_LPUART_HAS_FIFO
config->txFifoWatermark = 0;
config->rxFifoWatermark = 0;
#endif
#if defined(FSL_FEATURE_LPUART_HAS_MODEM_SUPPORT) && FSL_FEATURE_LPUART_HAS_MODEM_SUPPORT
config->enableRxRTS = true; // enable RXRTS
config->enableTxCTS = true; //enable RXRTS
config->txCtsConfig = kLPUART_CtsSampleAtStart;
config->txCtsSource = kLPUART_CtsSourcePin;
#endif
config->rxIdleType = kLPUART_IdleTypeStartBit;
config->rxIdleConfig = kLPUART_IdleCharacter1;
config->enableTx = false;
config->enableRx = false;
}
Regards
Daniel
1) I enable the RTS, but disable the CTS, the RTS (Tx, Rx direction pin) is from high to low too early, so I can not send the "all" data to the rs-485 master.