Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

drivers/at86rf215: implement Reduced Power Consumption #14960

Merged
merged 1 commit into from
Sep 7, 2020

Conversation

benpicco
Copy link
Contributor

@benpicco benpicco commented Sep 6, 2020

Contribution description

Reduced Power Consumption is available for MR-O-QPSK and MR-FSK.
In this mode the receiver will be turned off periodically, defaulting to a 50% duty cycle.

This reduces power consumption when in IDLE RX by almost 50% and is therefore enabled by default.

Reduced Power Consumption needs to be disabled during CCA.

Testing procedure

Receiving frames with MR-O-QPSK (and MR-FSK) should work as reliable as before.
MR-OFDM and legacy O-QPSK should not be affected.

Issues/PRs references

split off #12128

@benpicco benpicco added Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation Area: drivers Area: Device drivers labels Sep 6, 2020
@fjmolinas
Copy link
Contributor

@benpicco can you show some power consumption measurements?

@benpicco
Copy link
Contributor Author

benpicco commented Sep 7, 2020

Those are the numbers for one interface, for this I disabled the sub-GHz interface with DISABLE_MODULE += at86rf215_subghz.

RPC off

  • legacy O-QPSK: 32.3 mA
  • MR-O-QPSK: 33 mA

RPC on

  • legacy O-QPSK: 32.3 mA
  • MR-O-QPSK: 18.6 mA

@benpicco benpicco force-pushed the driver/at86rf215-rpc branch from d111230 to ea46f6b Compare September 7, 2020 09:09
@benpicco benpicco added the CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR label Sep 7, 2020
@fjmolinas
Copy link
Contributor

@benpicco is there any shortcoming/tradeoff of enabling this mode?

Comment on lines 238 to 243
#ifdef MODULE_NETDEV_IEEE802154_MR_FSK
if (dev->fsk_pl) {
/* MR-FSK */
at86rf215_reg_and(dev, dev->BBC->RG_FSKRPC, ~FSKRPC_EN_MASK);
return;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The minimal ON time t on equates to the minimal preamble length of the receiver which depends on the FSK symbol rate, this does not seem to be taking that into account, seems like BBCn_FSKRPCONT and BBCn_FSKRPCOFFT should be configured appropriately, same for OQPSK.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The minimal ON time t on equates to the minimal preamble length of the receiver which depends on the FSK symbol rate, this does not seem to be taking that into account, seems like BBCn_FSKRPCONT and BBCn_FSKRPCOFFT

indeed

same for OQPSK.

Fortunately not 😆

For MR-O-QPSK, the AT86RF215 supports receive operation with reduced power consumption (RPC) during RX listen.
This can be configured with sub-register OQPSKC2.RPC set to 1.
The principle of power saving is similar to the one of MR-FSK, with the exception that the OFF and ON time cannot be configured.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I already added this as part of the MR-FSK PR.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then can we remove that part from the PR? and leave it in the PR introducing the feature?

Copy link
Contributor Author

@benpicco benpicco Sep 7, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sore, dropped it from that PR and will add it back here once MR-FSK is merged.

patch
diff --git a/drivers/at86rf215/at86rf215_fsk.c b/drivers/at86rf215/at86rf215_fsk.c
index fdf21210f8..1d0b468004 100644
--- a/drivers/at86rf215/at86rf215_fsk.c
+++ b/drivers/at86rf215/at86rf215_fsk.c
@@ -383,6 +383,14 @@ static void _set_srate(at86rf215_t *dev, uint8_t srate, bool mod_idx_half)
 
     at86rf215_FSK_prepare_rx(dev);
 
+    /* t_on = t_off = t_min (time to TX minimal preamble length) */
+    uint8_t t_on = 4 * _FSKPL(srate) * 100 / at86rf215_fsk_srate_10kHz[srate];
+
+    at86rf215_reg_write(dev, dev->BBC->RG_FSKRPCONT, t_on);
+    at86rf215_reg_write(dev, dev->BBC->RG_FSKRPCOFFT, t_on);
+
+    DEBUG("[at86rf215] t_on: %d µs\n", t_on);
+
     /* set symbol rate, preamble is less than 256 so set high bits 0 */
     at86rf215_reg_write(dev, dev->BBC->RG_FSKC1, srate);
 }
@@ -454,6 +462,15 @@ int at86rf215_configure_FSK(at86rf215_t *dev, uint8_t srate, uint8_t mod_idx, ui
     /* enable direct modulation */
     at86rf215_reg_write(dev, dev->BBC->RG_FSKDM, FSKDM_EN_MASK | FSKDM_PE_MASK);
 
+    /* 16 µs base time */
+    uint8_t fskrpc = 0x5;
+
+    /* Enable / Disable Reduced Power Consumption */
+    if (dev->flags & AT86RF215_OPT_RPC) {
+        fskrpc |= FSKRPC_EN_MASK;
+    }
+    at86rf215_reg_write(dev, dev->BBC->RG_FSKRPC, fskrpc);
+
     /* set forward error correction */
     at86rf215_FSK_set_fec(dev, fec);

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh I think I wasn't very cleay hahaha, I meant removing the RPC-MR-FSK, related code from this PR(#14960) and moving it to the PR introducing MR-FSK (so #14959). I though this one would be quicker to get in.. sorry for the confusion

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I removed it here.

@benpicco
Copy link
Contributor Author

benpicco commented Sep 7, 2020

There is an errata though:

The usage of reduced power consumption mode (RPC) for MR-FSK and MR-OQPSK may cause a higher packet error rate.
Software workaround:

  • Write to the register RFn_PLL the value 9 if the AT86RF215 is in state RX and the desired channel frequency
    has been reached.
  • Write to the register RFn_PLL the value 8 prior to a change of the channel frequency or if the state RX has
    been left (including automatic state change from RX to TXPREP).

Basically toggling the (undocumented) least significant bit in RFn_PLL

@fjmolinas
Copy link
Contributor

Basically toggling the (undocumented) least significant bit in RFn_PLL

Huh... that looks like a weird work arround. Anyway, should this be a compile time configuration?

@benpicco benpicco requested a review from cgundogan as a code owner September 7, 2020 11:46
@benpicco benpicco removed the CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR label Sep 7, 2020
@fjmolinas
Copy link
Contributor

Please squash @benpicco!

@fjmolinas fjmolinas added the CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR label Sep 7, 2020
Reduced Power Consumption is available for MR-O-QPSK and
MR-FSK.
In this mode the receiver will be turned off periodically,
defaulting to a 50% duty cycle.

This reduces power consumption when in IDLE RX by almost 50%
and is therefore enabled by default.
@benpicco benpicco force-pushed the driver/at86rf215-rpc branch from 997e4ed to 634714f Compare September 7, 2020 11:49
Copy link
Contributor

@fjmolinas fjmolinas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK, trusting @benpicco testing.

@benpicco benpicco merged commit 8b3d019 into RIOT-OS:master Sep 7, 2020
@benpicco benpicco deleted the driver/at86rf215-rpc branch September 7, 2020 13:38
@benpicco
Copy link
Contributor Author

benpicco commented Sep 7, 2020

Thank you for the review!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: drivers Area: Device drivers CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants