The following image shows the odd way that my RTS line (blue) is working as I receive bytes (yellow). This happens for every byte I receive including the very first byte. I have prepared an example that demonstrates the problem (attached). The code essentially boils down to the following which matches the example. What do I need to change to get the RTS to work properly.
const usart_config_t FLEXCOMM1_config = {
.baudRate_Bps = 115200UL,
.syncMode = kUSART_SyncModeDisabled,
.parityMode = kUSART_ParityDisabled,
.stopBitCount = kUSART_OneStopBit,
.bitCountPerChar = kUSART_8BitsPerChar,
.loopback = false,
.txWatermark = kUSART_TxFifo0,
.rxWatermark = kUSART_RxFifo1,
.enableRx = true,
.enableTx = true,
.enableHardwareFlowControl = true,
.enableMode32k = false,
.clockPolarity = kUSART_RxSampleOnFallingEdge,
.enableContinuousSCLK = false
};
usart_handle_t FLEXCOMM1_handle;
uint8_t FLEXCOMM1_rxBuffer[FLEXCOMM1_RX_BUFFER_SIZE];
usart_transfer_t FLEXCOMM1_rxTransfer = {
.rxData = FLEXCOMM1_rxBuffer,
.dataSize = FLEXCOMM1_RX_BUFFER_SIZE
};
static void FLEXCOMM1_init(void) {
USART_Init(FLEXCOMM1_PERIPHERAL, &FLEXCOMM1_config, FLEXCOMM1_CLOCK_SOURCE);
USART_TransferCreateHandle(FLEXCOMM1_PERIPHERAL, &FLEXCOMM1_handle, NULL, NULL);
USART_TransferStartRingBuffer(FLEXCOMM1_PERIPHERAL, &FLEXCOMM1_handle, FLEXCOMM1_rxBuffer, FLEXCOMM1_RX_BUFFER_SIZE);
}
Is there anyone out there looking at this, or should I post a support ticket?
Hi,
As you know that the RTS signal is an output signal from uart, it can function as either RS485 gate control signal or flow control signal.
Pls check the peripheral register and check if the OESEL bit is cleared.
Hope it can help you
BR
XiangJun Rong
HI XiangJun,
The value of OESEL is zero. The code I provided was completely created with the config tools to create a simple as possible example. For some reason the peripheral tool did not start the ring buffer so I added the following:
USART_TransferStartRingBuffer(FLEXCOMM1_PERIPHERAL, &FLEXCOMM1_handle, FLEXCOMM1_rxBuffer, FLEXCOMM1_RX_BUFFER_SIZE);
Here is a capture of the USART1 CFG register values in case it would be helpful.
Thanks for any help you can provide
William
Hi,
Pls try to enable uart receiver FIFO and set the FIFO threshold to a non-zero value, then check if the RTS signal change or not.
If the RTS signal changes after you enable receiver FIFO, it means that the RTS signal is flow control signal.
Pls have a try
BR
XiangJun Rong
I tried changing the RXLVL in FIFOTRIG to the values 0, 1, 2, and 4 and got the same results each time shown in the photo on my initial post. I'm not sure what you mean by enabling the receiver FIFO using this value since this feature is supposed to just be the trigger point at which the interrupt is called.
I'll mention again that the data shown in the photo are the first eight bytes received after reset which indicates that the problem is already happening with the very first byte. Do you have any other ideas for how to make my flow control work properly?
Hi,
As the following Fig, I have tested on the LPCXPresso55S28 board, the Yellow signal is P1_7 signal which is FC0_RTS signal, the blue signal is FC0_TXD signal.
I tested based on usart_Polling example in SDK.
In the example, after uart receives a char from PC, it send a string.
The high interval of the RTS signal (Yellow)means it is receiving uart signal, the low interval means that the uart receiver is idle, it is able to receive char.
int main(void)
{
uint8_t ch;
usart_config_t config;
/* set BOD VBAT level to 1.65V */
POWER_SetBodVbatLevel(kPOWER_BodVbatLevel1650mv, kPOWER_BodHystLevel50mv, false);
/* attach 12 MHz clock to FLEXCOMM0 (debug console) */
CLOCK_AttachClk(BOARD_DEBUG_UART_CLK_ATTACH);
BOARD_InitBootPins();
BOARD_InitBootClocks();
BOARD_InitDebugConsole();
/*
* config.baudRate_Bps = 115200U;
* config.parityMode = kUSART_ParityDisabled;
* config.stopBitCount = kUSART_OneStopBit;
* config.loopback = false;
* config.enableTx = false;
* config.enableRx = false;
*/
USART_GetDefaultConfig(&config);
config.baudRate_Bps = BOARD_DEBUG_UART_BAUDRATE;
config.enableTx = true;
config.enableRx = true;
config.txWatermark=kUSART_TxFifo6;
config.rxWatermark=kUSART_RxFifo6;
//config.enableHardwareFlowControl=true;
USART_Init(DEMO_USART, &config, DEMO_USART_CLK_FREQ);
USART_WriteBlocking(DEMO_USART, txbuff, sizeof(txbuff) - 1);
while (1)
{
USART_ReadBlocking(DEMO_USART, &ch, 1);
// USART_WriteBlocking(DEMO_USART, &ch, 1);
USART_WriteBlocking(DEMO_USART, txbuff, sizeof(txbuff) - 1);
}
}
void BOARD_InitPins(void)
{
/* Enables the clock for the I/O controller.: Enable Clock. */
CLOCK_EnableClock(kCLOCK_Iocon);
const uint32_t port0_pin29_config = (/* Pin is configured as FC0_RXD_SDA_MOSI_DATA */
IOCON_PIO_FUNC1 |
/* No addition pin function */
IOCON_PIO_MODE_INACT |
/* Standard mode, output slew rate control is enabled */
IOCON_PIO_SLEW_STANDARD |
/* Input function is not inverted */
IOCON_PIO_INV_DI |
/* Enables digital function */
IOCON_PIO_DIGITAL_EN |
/* Open drain is disabled */
IOCON_PIO_OPENDRAIN_DI);
/* PORT0 PIN29 (coords: 92) is configured as FC0_RXD_SDA_MOSI_DATA */
IOCON_PinMuxSet(IOCON, 0U, 29U, port0_pin29_config);
const uint32_t port0_pin30_config = (/* Pin is configured as FC0_TXD_SCL_MISO_WS */
IOCON_PIO_FUNC1 |
/* No addition pin function */
IOCON_PIO_MODE_INACT |
/* Standard mode, output slew rate control is enabled */
IOCON_PIO_SLEW_STANDARD |
/* Input function is not inverted */
IOCON_PIO_INV_DI |
/* Enables digital function */
IOCON_PIO_DIGITAL_EN |
/* Open drain is disabled */
IOCON_PIO_OPENDRAIN_DI);
/* PORT0 PIN30 (coords: 94) is configured as FC0_TXD_SCL_MISO_WS */
IOCON_PinMuxSet(IOCON, 0U, 30U, port0_pin30_config);
const uint32_t port1_pin7_config = (/* Pin is configured as FC0_RTS */
IOCON_PIO_FUNC1 |
/* No addition pin function */
IOCON_PIO_MODE_INACT |
/* Standard mode, output slew rate control is enabled */
IOCON_PIO_SLEW_STANDARD |
/* Input function is not inverted */
IOCON_PIO_INV_DI |
/* Enables digital function */
IOCON_PIO_DIGITAL_EN |
/* Open drain is disabled */
IOCON_PIO_OPENDRAIN_DI);
/* PORT0 PIN30 (coords: 94) is configured as FC0_TXD_SCL_MISO_WS */
IOCON_PinMuxSet(IOCON, 1U, 7U, port1_pin7_config);
}
I connect the Yellow signal of scope to pin 7 of P18(PIO1_7) on the LPC55S28 board, connect blue signal to the FC0_TXD signal pin3 of P8 connector(FC0_USART_TXD).
so I suppose the yellow signal can be the flow control signal.
BR
XiangJun Rong
Using your code I was able to reproduce the problem on the LPCXPresso55S28. The only change I made was to use a baud rate 115200 (to match the device that is sending the data). The signal looks the same as before. I cannot understand why you would not also be seeing the problem. Could you try it at 115200 to see if you can reproduce the problem as well?
I got the device producing the incoming data to transmit at 9600 baud. So, now I am using your code essentially unaltered and I am still having the problem. I haven't received a reply to my response on Thursday. Can I please get some help with this problem? We have a product that is nearly ready to ship and only waiting on a resolution to the hardware flow control not working properly.
Hi,
This is the timing I use the scope Trigger mode to capture.
The Yellow is P1_7 pin, which is RTS signal.
The red signal is uart0_RX pin(FC0_USART_RXD, P0_29, pin2 of P8 ), the pin get char from PC side.
the blue signal is uart0_TX signal(FC0_USART_TXD, P0_30, pin 3 of P8), the pin transmits string.
Can you duplicate the timing with my code? do you think the timing is correct especially RTS signal?
I have tested both 9600 and 15200 baud rate, the result is same.
BR
Xiangjun Rong
Thank you for the scope image with the additional lines. The image actually demonstrates the problem. RTS should only go high if the microcontroller is unable to receive more bytes, usually due to the FIFO being full. In your example, when you are receiving the first byte (red), RTS (yellow) goes high while the byte is being received. I haven't seen any other microcontrollers that implement RTS in this manner and haven't been able to find any articles describing RTS being implemented in this way. I'm concerned that our product, which is designed to talk to other microcontrollers, will cause problems for customers whose microcontrollers do not allow for our RTS to work in this unusual way.
If I am mistaken, would you please direct me to the relevant standard so I can better understand the issue and get some assurance that all microcontrollers would support this implementation?
Hi,
I will consult with AE team and check if the timing of RTS flow control signal is correct or not.
BR
Xiangjun Rong
Hi,
If you observed different timing of RTS signal vs uart0_RXD and TXD, pls post on the community so that we can have a check.
This is PUTTY screenshot, which you can input char
BR
XiangJun Rong