-->
Page 2 of 4

Re: Hardware flow control

PostPosted: Wed Mar 20, 2019 11:27 am
by HowardHo
This is an older post but I'm having problems with this.

const int CTSPin = 13; // GPIO13 for CTS input
pinMode(CTSPin, FUNCTION_4); // make pin U0CTS
U0C0 |= UCTXHFE; //add this sentense to add a tx flow control via MTCK( CTS )

Isn't the correct program line:
U0C0 |= 2^UCTXHFE; //add this sentense to add a tx flow control via MTCK( CTS )

Since the bit needs to be set? UCTXHFE is 15 which is the correct bit in the register. Otherwise bits 0, 1, 2, 3 are set, I believe. Where am I going wrong?

Thanks,
Howard

Re: Hardware flow control

PostPosted: Thu Mar 21, 2019 12:25 pm
by JimDrew
I could never get this to work so I used a different method of polling a pin.

I believe you could be correct though! U0C0|=value. I thought UCTXHFE was a value, not a bit. If it is in fact a bit (15) then yes, this would be OR'ing %0000000000001111 as the value, not %1000000000000000 as intended. I am not much of a 'C' guy though, so I was surprised you could even do |= as an operator.

I might go back and look at this again. Let me know if you try using 2^UCTXHFE and it works. :)

Re: Hardware flow control

PostPosted: Fri Mar 22, 2019 4:31 am
by btidey
This is the espressif UART guide which gives a good explanation of flow control both RTS and CTS

http://bienonline.magix.net/public/esp8 ... N_v0.2.pdf

Re: Hardware flow control

PostPosted: Fri Mar 22, 2019 4:43 am
by JimDrew
Thanks for the link. It seems that there are separate Tx and Rx flow control enable bits.

It would be nice to have some example setup code for the Arduino IDE. The Espressif datasheet is for their normal C environment.

By the way, it seems that pin 12 is U0CTS and pin 13 is U0RTS. I don't think that these can be changed from these assigned pins based on the pinout map. Your example above is trying to use pin 13 for CTS.