1
\$\begingroup\$

I'm communicating data from my microcontroller (Teensy) to my Bluetooth module (nRFx) which is also a microcontroller that I can program. I use UART to communicate the data I want to send over Bluetooth from the Teensy to the nRF, but nRF sends Bluetooth data slower than the transmission of data from the Teensy (UART speed faster than Bluetooth speed). Because of this I need to implement hardware flow control so the nRF buffer doesn't overflow.

I have RTS and CTS pins on both microcontrollers and I'm currently writing in Arduino (this might change to nordic's SDK for the nRF). My question is, can I just connect the RTS and CTS pins and "activate" the flow control somehow and it just works? Or do I need to program them my self?

Teensy

nRF

\$\endgroup\$
2
\$\begingroup\$

If the bluetooth module supports control flow, you should just enable it and then it will work automatically on the module's side. If not, tough luck - you can't use flow control.

On the micrcontroller side, you must handle RTS/CTS manually with GPIO (or perhaps some magic UART library will do it for you).

EDIT: Apparently your particular MCU Kinetis K20 supports flow control as part of the UART hardware, so you can have the MCU do it automatically in this case.

Another alternative might be to have the module echo each character sent back to the MCU. This makes everything slower but can perhaps be used as poor man's flow control.

\$\endgroup\$
  • \$\begingroup\$ Thank you! One question comes to mind, why would I need to use RTS/CTS pins if I have to program them? What different functionality does a RTS/CTS pin in my microcontroller have that I couldn't have just programmed another IO pin to do? \$\endgroup\$ – Marius Gulbrandsen Apr 18 at 9:25
  • 1
    \$\begingroup\$ @MariusGulbrandsen Ah, turns out this particular MCU actually does support flow control through hardware. That isn't traditionally the case with Freescale MCUs, but there you go then. Answer updated. \$\endgroup\$ – Lundin Apr 18 at 10:56
  • \$\begingroup\$ Thanks! I was not sure how HWFC worked so this clarified my question. \$\endgroup\$ – Marius Gulbrandsen Apr 18 at 10:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.