I'm trying to enable RTS/CTS handshaking (flow control) on the Serial2 port for a reliable connection with a Bluegiga WT12 module, which requires flow control at high baud rates to prevent internal buffer overflow conditions. I am not having any apparent luck. Has anyone been able to do this before, or could anyone provide some assistance?
I got far enough through the SAM3X8E datasheet to try adding the US_MR_USART_MODE_HW_HANDSHAKING flag to the US_MR configuration on lines 48-50 of USARTClass.cpp in \hardware\arduino\sam\cores\arduino:
// Configure mode
_pUsart->US_MR = US_MR_USART_MODE_NORMAL | US_MR_USCLKS_MCK | US_MR_CHRL_8_BIT | US_MR_PAR_NO |
US_MR_NBSTOP_1_BIT | US_MR_CHMODE_NORMAL | US_MR_USART_MODE_HW_HANDSHAKING;
...but this doesn't work. Based on the datasheet, USART1 (Serial2) with flow control should use the following pins:
- A.12 (D17) is RX2
- A.13 (D16) is TX2
- A.14 (D23) is RTS2
- A.15 (D24) is CTS2
What I'm seeing is that I have to manually connect the RTS2 pin to GND in order to bring the signal low. It should automatically go low if the buffer isn't full, but it's always high. Am I missing something about setting up buffers or something of that nature?