I'm developing a new board based upon the Maple RET6. On this board, I am bringing out USART3 to use for serial communication to/from a host controller. The question is, how many pins are used to implement the USART when declared in software? If Rx, Tx, CTS and RTS are used, is CLK pin still available for other use? What about the case where only Rx and Tx pins are used when flow control is under software? In this case, are the CTS and RTS pins available for other uses?
Using USART3.
(3 posts) (2 voices)-
Posted 2 years ago #
-
wdsim - "how many pins are used to implement the USART when declared in software?"
What exactly do you mean by "when declared in software"?If you mean, only using the libmaple objects
Serial1
,Serial2
andSerial3
or methods likeSerial2.begin(9600)
, then two pins, Rx and Tx.I haven't used USART3. However, I am 99+% certain that the CTS, RTS and CLK pins can all be used for other purposes, unless your software explicitly configures them to act as CTS, RTS or CLK.
RM0008, the manual documenting STM32F103 peripherals (downloadable from st.com), says ...
For CLK:
"27.3.9 USART synchronous mode
The synchronous mode is selected by writing the CLKEN bit in the USART_CR2 register to 1"
and the definition for the register USART_CR2:
"Bit11 CLKEN:Clock enable
This bit allows the user to enable the CK pin. 0: CK pin disabled 1: CK pin enabled"For RTS, CTS
"27.3.14 Hardware flow control
It is possible to control the serial data flow between 2 devices by using the nCTS input and the nRTS output. ...
RTS and CTS flow control can be enabled independently by writing respectively RTSE and CTSE bits to 1 (in the USART_CR3 register).""RTS flow control
If the RTS flow control is enabled (RTSE=1 ...""CTS flow control
If the CTS flow control is enabled (CTSE=1) ..."and in the definition of USART_CR3:
"Bit9 CTSE:CTS enable
0: CTS hardware flow control disabled 1: CTS mode enabled"
"Bit8 RTSE:RTS enable
0: RTS hardware flow control disabled 1: RTS interrupt enabled"So software must explicitly enable the pins in order for them to function.
By definition, CTS and RTS would not normally be used when your software is doing software flow-control, i.e. when "only Rx and Tx pins are used when flow control is under software" your software is handling the flow-control by explicitly sending 'X-OFF' and 'X-ON' control characters at appropriate points.
Your software could explicitly enable RTS and CTS (by setting those bits in USART_CR3) even when your software is also doing software flow control; there is nothing to prevent your software from doing weird things. However, if your software does not enable those pins' functions, they are just pins.
The Maple documentation only mentions Rx and Tx, and never RTS, CTS or CLK:
http://leaflabs.com/docs/lang/api/serial.html
http://leaflabs.com/docs/usart.html
So it seems reasonable to assume that only Rx and Tx are used by the libmaple software.You could test this using a Maple http://leaflabs.com/docs/hardware/maple.html#maple-usart-map
(Full disclosure: I am not a member of LeafLabs staff.)
Posted 2 years ago # -
Thanks gbulmer, this answers my question fully. What I mean by software declaration is what you said, "Serial3.begin(9600)". By explaining how to make CLK, CTS and RTS function, you've also told me how to turn them off, obviously, by setting those register bits to 0.
Cheers
Posted 2 years ago #
Reply
You must log in to post.