Usart flow control (rts/cts) in stm32f1xx

ChibiOS public support forum for all topics not covered by a specific support forum.

Moderators: RoccoMarco, lbednarz, tfAteba

ucasano
Posts: 57
Joined: Mon Aug 06, 2012 1:05 pm
Has thanked: 1 time

Usart flow control (rts/cts) in stm32f1xx

Post by ucasano »

Hello, i Was wondering if rts/cts flow control is supported by chibios for stm32f1xx ucontrollers.
If yes, were could i find a code snippet of such configuration, showing also how to receive and transmit?

I tried using cr1, cr2 and cr3 in uartconfig structure while configuring; but I Saw no rts/cts handling by uc,
Expecially in receiving stage.

Thanks
-g
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: Usart flow control (rts/cts) in stm32f1xx

Post by Giovanni »

Hi,

HW flow control is not explicitly implemented in the driver but is should be pretty much automatic when enabled in control registers, at least this is what I read in the reference manual in section 27.3.14. Make sure that CTS/RTS pins are configured correctly, outputs should be alternate functions on the F1.

Giovanni
ucasano
Posts: 57
Joined: Mon Aug 06, 2012 1:05 pm
Has thanked: 1 time

Re: Usart flow control (rts/cts) in stm32f1xx

Post by ucasano »

Hi Giovanni, I have done what you wrote, which is the same I did before, and receiver does not work.

The reason is RTS stays always UP, and never gets down.

So I am wondering, do I have to explicitly call the uartStartReceive function after each send?

Bye
-g
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: Usart flow control (rts/cts) in stm32f1xx

Post by Giovanni »

Hi,

Is RTS programmed as alternate output?

A question, are you sure you need the "UART" driver? it is possible the "Serial" driver is better in your case, what are your requirements? note that the UART driver is unbuffered (the Serial driver is buffered instead) and you have to restart the transfers after each callback.

Giovanni
ucasano
Posts: 57
Joined: Mon Aug 06, 2012 1:05 pm
Has thanked: 1 time

Re: Usart flow control (rts/cts) in stm32f1xx

Post by ucasano »

Hi Giovanni, RTS is alternate output.

But I just read the errata sheet of my stm32f103 (http://www.st.com/internet/com/TECHNICA ... 197763.pdf) and seems that in my case
there is a conflict with CAN:

" the CAN must be remapped to either another IO configuration when the CAN is used, or to the unused configuration (CAN_REMAP[1:0] set to “01”) when the CAN is not used."

How do I remap can to unused configuration?

I am using usart to interface with a gprs modem: is using the uart device the right thing to do?
Another question: does serial peripherals support cts/rts flow control?

Thanks.
-g
ucasano
Posts: 57
Joined: Mon Aug 06, 2012 1:05 pm
Has thanked: 1 time

Re: Usart flow control (rts/cts) in stm32f1xx

Post by ucasano »

Hello all, I did it.

It depended on the errata sheet I reported in my previous post.

Definitely, now, it seems to works fine.

Just a few seconds for last question: which driver should I use to talk to a gprs modem? usart or serial?

Thanks for your time and consideration.
bye
-g
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: Usart flow control (rts/cts) in stm32f1xx

Post by Giovanni »

Hi,

Both can be used but Serial is probably easier to use, it does not require callbacks and supports communication timeouts natively, the UART driver is mostly meant for packet-oriented applications at very high rates.

Giovanni
ucasano
Posts: 57
Joined: Mon Aug 06, 2012 1:05 pm
Has thanked: 1 time

Re: Usart flow control (rts/cts) in stm32f1xx

Post by ucasano »

So uart driver has to be used for implementing lwip over ppp: is'nt it?
P
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: Usart flow control (rts/cts) in stm32f1xx

Post by Giovanni »

It can be used in any application but Serial is easier most of times.

Could be used for ppp or for an RS485 network for example, anywhere data is organized in packets rather than streams.

Giovanni
ucasano
Posts: 57
Joined: Mon Aug 06, 2012 1:05 pm
Has thanked: 1 time

Re: Usart flow control (rts/cts) in stm32f1xx

Post by ucasano »

Looks good... What about udp streams? Would you use serial or uart driver? In this case, we have streams of datas,
inside udp packets...

-g
Post Reply