Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hardware Flow control for serial communication #394

Closed
mayurharge opened this issue Dec 24, 2018 · 13 comments
Closed

Hardware Flow control for serial communication #394

mayurharge opened this issue Dec 24, 2018 · 13 comments
Labels
enhancement New feature or request

Comments

@mayurharge
Copy link

Hello,
I am using the STM32f103c series controller with GSM module. Sometimes Serial buffer of GSM is getting full and the communication is not happening as expected. During my search, I came across Hardware Flow control using RTS/CTS. As stm has dedicated H/W flow control pins [For UART 2 PA0:- CTS2 & PA1:-RTS2] is there any option available in board files to enable hardware flow control?
if yes please let me know how to enable it
if not then it would be really helpful if you can integrate this in next version.

Thanks

@fpistm
Copy link
Member

fpistm commented Dec 24, 2018

HW flow control is not implemented.

@mayurharge
Copy link
Author

Okay, thanks.

@mayurharge
Copy link
Author

Hey are you going to implement this feature in future, also please give me some suggestions to implement by myself

@fpistm
Copy link
Member

fpistm commented Dec 25, 2018

If I well remember it is based on how MBed implement UART. And if I well remember, flow control is also implemented on MBed side. So this could be a good starting point.

@mayurharge
Copy link
Author

Thanks i will look into it

@fpistm
Copy link
Member

fpistm commented Dec 26, 2018

@mayurharge
You could let this issue opened as a requested feature.
Do not hesitate to provide a PR if you get it up and running.

@arihantdaga
Copy link

@fpistm I saw this line in cores/arduino/stm32/uart.c

huart->Init.HwFlowCtl = UART_HWCONTROL_NONE;
. Does making the HwFlowCtl to UART_HWCONTROL_CTS or UART_HWCONTROL_RTS is all thats required ? I am not sure yet, testing it. But if it works, I'll add this configuration using macros and make it user configurable...

@fpistm
Copy link
Member

fpistm commented Dec 26, 2018

I guess you have also to init the RTS/CTS pin also.

@mayurharge mayurharge reopened this Dec 26, 2018
@fpistm
Copy link
Member

fpistm commented Dec 26, 2018

Just a quick thought if the buffer is full.
By default , the Rx and Tx buffer of the core is 64.

#if !defined(SERIAL_TX_BUFFER_SIZE)

You can redefined them by adding a new file (Tab on Arduino IDE) named build_opt.h
Then in this file put:
-DSERIAL_RX_BUFFER_SIZE=256 -DSERIAL_TX_BUFFER_SIZE=256

Increasing only one of both works also but I advise to keep them aligned.

@mayurharge
Copy link
Author

@fpistm I am already using the BUFFER_SIZE =256.
the need for me to use hardware flow control is that the slave device SIM800c is lagging behind over time
When I searched for this issue I figured out this

Flow control is very important for correct communication between the GSM engine and DTE.
For in the case such as a data or fax call, the sending device is transferring data faster than the
receiving side is ready to accept. When the receiving buffer reaches its capacity, the receiving
device should be capable to cause the sending device to pause until it catches up

This was mentioned in the datasheet of SIM800.

@fpistm fpistm added enhancement New feature or request New feature labels Jan 3, 2019
@fpistm fpistm added the Request label Mar 6, 2019
@benwaffle
Copy link
Contributor

@mayurharge you can of course use the HAL manually for now by calling HAL_GPIO_* and HAL_UART_* functions

@fpistm fpistm mentioned this issue Jun 11, 2021
4 tasks
@fpistm
Copy link
Member

fpistm commented Jun 11, 2021

Added to [U(S)ART] request list #1418

@fpistm
Copy link
Member

fpistm commented Feb 5, 2022

Done thanks #1634

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants