Skip to content

Commit 7912676

Browse files
committed
app: Change CTS pull-down to pull-up
Previously CTS was pulled up, this prevented hosts without hardware flow control from using the default Serial Modem build. Changing CTS to pull-down allows Serial Modem to send even when the CTS and RTS pins float. This relies in DTR as main mechanism for UART control. The host must first enable its own UART before it enables Serial Modem UART with DTR. - With hardware flow control, this means that host drives it's RTS pin, so there is no difference in operation. Host should also have a pull-up for it's CTS pin, so when SM starts driving it's RTS, the host knows that SM is ready to receive. - Without hardware flow control, the Serial Modem is able to send (TX) to host. However, the timing with DTR and when SM is able to receive needs to be taken into account as host cannot observe it's CTS. Instead host must monitor the RI signal, which is de-asserted when SM UART is ready. Or alternatively, have a sufficient timeout between host asserting DTR and host's first TX operation. Important: It is highly recommended to use hardware flow control with Serial Modem. Signed-off-by: Markus Lassila <markus.lassila@nordicsemi.no>
1 parent 1ca70e7 commit 7912676

3 files changed

Lines changed: 70 additions & 6 deletions

File tree

app/boards/nrf9151dk_nrf9151_ns.overlay

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@
2222
ri-gpios = <&gpio0 0 GPIO_ACTIVE_LOW>;
2323
status = "okay";
2424
};
25+
pinctrl-0 = <&uart0_default_alt>;
26+
pinctrl-1 = <&uart0_sleep_alt>;
27+
pinctrl-names = "default", "sleep";
28+
2529
};
2630

2731
&gpio0 {
@@ -30,6 +34,34 @@
3034
sense-edge-mask = <0x00000100>;
3135
};
3236

37+
38+
&pinctrl {
39+
uart0_default_alt: uart0_default_alt {
40+
group1 {
41+
psels = <NRF_PSEL(UART_RX, 0, 26)>;
42+
bias-pull-up;
43+
};
44+
group2 {
45+
psels = <NRF_PSEL(UART_CTS, 0, 15)>;
46+
bias-pull-down;
47+
};
48+
group3 {
49+
psels = <NRF_PSEL(UART_TX, 0, 27)>,
50+
<NRF_PSEL(UART_RTS, 0, 14)>;
51+
};
52+
};
53+
54+
uart0_sleep_alt: uart0_sleep_alt {
55+
group1 {
56+
psels = <NRF_PSEL(UART_TX, 0, 27)>,
57+
<NRF_PSEL(UART_RX, 0, 26)>,
58+
<NRF_PSEL(UART_RTS, 0, 14)>,
59+
<NRF_PSEL(UART_CTS, 0, 15)>;
60+
low-power-enable;
61+
};
62+
};
63+
};
64+
3365
/* Disable I2C2.
3466
* - Enabling IO expander causes ~20uA to be consumed while DTR is deasserted.
3567
* - We use P0.31 and P0.30 pins for DTR and RI signals with external MCU.

app/overlay-external-mcu.overlay

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,14 @@
4545
&pinctrl {
4646
uart2_default_alt: uart2_default_alt {
4747
group1 {
48-
psels = <NRF_PSEL(UART_RX, 0, 3)>,
49-
<NRF_PSEL(UART_CTS, 0, 7)>;
48+
psels = <NRF_PSEL(UART_RX, 0, 3)>;
5049
bias-pull-up;
5150
};
5251
group2 {
52+
psels = <NRF_PSEL(UART_CTS, 0, 7)>;
53+
bias-pull-down;
54+
};
55+
group3 {
5356
psels = <NRF_PSEL(UART_TX, 0, 2)>,
5457
<NRF_PSEL(UART_RTS, 0, 6)>;
5558
};

doc/uart_configuration.rst

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,11 @@ The following tables shows how to connect the UART pins to the corresponding pin
7171
* - TX
7272
- P0.27
7373
* - RX
74-
- P0.26
74+
- P0.26 (pull-up)
7575
* - RTS
7676
- P0.14
7777
* - CTS
78-
- P0.15
78+
- P0.15 (pull-down)
7979
* - DTR
8080
- P0.08 (Button 1, pull-up, active high)
8181
* - RI
@@ -103,11 +103,11 @@ The following tables shows how to connect the UART pins to the corresponding pin
103103
* - TX
104104
- P0.02
105105
* - RX
106-
- P0.03
106+
- P0.03 (pull-up)
107107
* - RTS
108108
- P0.06
109109
* - CTS
110-
- P0.07
110+
- P0.07 (pull-down)
111111
* - DTR
112112
- P0.31 (active low, pull-up)
113113
* - RI
@@ -278,6 +278,13 @@ Once the host UART is ready and DTR is asserted, the nRF91 enables its UART inte
278278
The RI signal remains active throughout this process and only returns to inactive once the nRF91 UART is active.
279279
This coordinated wake-up ensures both ends of the communication link are ready before data transmission begins.
280280

281+
**With hardware flow control:** The host can observe its CTS pin (connected to Serial Modem's RTS) to know when Serial Modem is ready to receive data.
282+
When Serial Modem starts driving its RTS pin, the host knows that Serial Modem is ready to receive.
283+
The host should also have a pull-up on its CTS pin.
284+
285+
**Without hardware flow control:** The host must monitor the **RI signal**, which is de-asserted when the Serial Modem UART becomes ready to receive data.
286+
Alternatively, the host can implement a sufficient timeout between asserting DTR and initiating its first TX operation.
287+
281288
Host-initiated wake-up
282289
======================
283290

@@ -289,6 +296,28 @@ The modem detects the DTR assertion and powers up its UART interface, allowing c
289296

290297
Sequence diagram showing host-initiated wake-up of the modem
291298

299+
.. _uart_without_flow_control:
300+
301+
Operating without hardware flow control
302+
========================================
303+
304+
.. important::
305+
**It is highly recommended to use hardware flow control with Serial Modem** to ensure reliable communication and avoid timing-related issues.
306+
Serial Modem has not been optimized for operation without hardware flow control.
307+
308+
Serial Modem's CTS pin is configured with pull-down, allowing Serial Modem to transmit when CTS and RTS pins are left floating.
309+
The host can operate without connecting the hardware flow control signals (CTS/RTS).
310+
311+
**Key requirements:**
312+
313+
* The host must enable its own UART before asserting DTR
314+
* To detect when Serial Modem is ready to receive, monitor the RI signal (de-asserted when ready) or use a sufficient timeout after DTR assertion
315+
* See `Incoming data wake-up`_ for detailed timing information
316+
317+
**Buffer configuration:**
318+
319+
Increase ``CONFIG_SM_UART_RX_BUF_SIZE`` and possibly ``CONFIG_SM_UART_RX_BUF_COUNT`` to provide sufficient buffer space for your use case.
320+
292321
Automatic UART power management using Zephyr's Cellular Modem driver
293322
====================================================================
294323

0 commit comments

Comments
 (0)