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

SX126x cannot wake from sleep #69

Closed
BarryPSmith opened this issue Nov 14, 2019 · 2 comments
Closed

SX126x cannot wake from sleep #69

BarryPSmith opened this issue Nov 14, 2019 · 2 comments
Labels
bug Something isn't working resolved Issue was resolved (e.g. bug fixed, or feature implemented)

Comments

@BarryPSmith
Copy link
Contributor

BarryPSmith commented Nov 14, 2019

Describe the bug
SX126x modules cannot be woken with the library, instead one must manually wake the unit with a digital write to its select pin.

It looks like in SX126x::SPItransfer, moving the line digitalWrite(_mod->getCs(), LOW); to run before the Wait for BUSY loop will fix this (first sentence in datasheet section 8.2.2) but I'm not sure if there's a reason it needs to be where it is.

To Reproduce

#include <RadioLib.h>

#define LORA_CHECK(A) { auto res = A; if(res) { Serial.print("FAILED " #A ": "); Serial.println(res); } } while(0)

#define BUSY 4
#define DIO1 2
#define DIO2 -1
#define SELECT 9
SX1262 lora = new Module(SELECT, DIO1, DIO2, BUSY);

void setup() {
  Serial.begin(9600);
  delay(10);
  LORA_CHECK(lora.begin());
  LORA_CHECK(lora.sleep());
  //digitalWrite(SELECT, LOW); //Uncomment this and everything works
  LORA_CHECK(lora.standby()); //Fails with -705
  Serial.println("Setup done. If no errors show, everything worked.");
}

void loop() {}

Expected behavior
The module can be woken from sleep by asking it to return to standby

Additional info (please complete):

  • MCU: Ardiuno Nano
  • Wireless module type: SX1262
  • Arduino IDE version: 1.8.10
  • Library version: tip of trunk as of writing. Checkin 300e7f4
@jgromes
Copy link
Owner

jgromes commented Nov 14, 2019

I was able to reproduce this, thanks.

You're right, NSS must go low before checking BUSY pin. BUSY should be held high in sleep mode, and since we wait for BUSY to go low at the start of SX126x::SPItranscation(), it will never leave the waiting loop, hence the timeout.

I'm not entirely sure why is NSS pulled low after checking BUSY pin - I think it might have been an effort to not start any SPI transactions as long as BUSY is high.

Will fix in a second.

@jgromes jgromes added the bug Something isn't working label Nov 14, 2019
@jgromes
Copy link
Owner

jgromes commented Nov 14, 2019

Fixed in 3db5134, thanks for reporting!

@jgromes jgromes closed this as completed Nov 14, 2019
@jgromes jgromes added the resolved Issue was resolved (e.g. bug fixed, or feature implemented) label Jun 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working resolved Issue was resolved (e.g. bug fixed, or feature implemented)
Projects
None yet
Development

No branches or pull requests

2 participants