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

nRF52840 with RFM69 errors #162

Closed
DTronixs opened this issue Jul 7, 2020 · 16 comments
Closed

nRF52840 with RFM69 errors #162

DTronixs opened this issue Jul 7, 2020 · 16 comments
Labels
bug Something isn't working question Generic question about code or usage resolved Issue was resolved (e.g. bug fixed, or feature implemented)

Comments

@DTronixs
Copy link

DTronixs commented Jul 7, 2020

Setup:
Feather nRF52840 Express
FeatherWing RFM69HCW 900MHz
RadioLib 3.7.0
Arduino 1.8.12

I trying to get the example RF69_Transmit.ino to run and I get the following error message:

"[RF69] Initializing ... failed, code -16"

The RFM69HCW wiring is as per Adafruit's guide (CS = 5, IRQ = 10, RST = 6) and has been visually checked and continutity checked. Code has been modified as follows:

RF69 rf = new Module(5, 10, 6);

Any suggestions for what could be wrong?

Are there any options to enable further debugging?

Tony

@jgromes
Copy link
Owner

jgromes commented Jul 7, 2020

Are there any options to enable further debugging?

Only for those who use the issue templates and/or read the wiki :P See https://github.com/jgromes/RadioLib/wiki/Debug-mode

-16 is SPI write fail - real value of some SPI register after writing doesn't match the expected one. Enable debugging mode (both debug and verbose level), and it will show all the details in Serial monitor, post the output here.

@jgromes jgromes added the more information needed Further investigation is needed, not necessarily by the author label Jul 7, 2020
@DTronixs
Copy link
Author

DTronixs commented Jul 9, 2020

Thanks Jan,

Here's the output:

[RF69] Initializing ... Found RF69! (match by RF69_REG_VERSION == 0x24)

address: 0x7
bits: 7 0
value: 0b11011001
current: 0b11100100
mask: 0b11111111
new: 0b11011001
read: 0b11100100

address: 0x8
bits: 7 0
value: 0b0
current: 0b11000000
mask: 0b11111111
new: 0b0
read: 0b11000000

failed, code -16

@jgromes
Copy link
Owner

jgromes commented Jul 9, 2020

It looks like the module refuses SPI writes to RF69_REG_FRF_MSB and RF69_REG_FRF_MID. I've seen this on a couple RFM69 modules before, when I tried to set frequency other than 915 MHz. It looks like some RFM69 modules are "locked" into a particular frequency value (0xe4c000, which corresponds to 915 MHz).

Try setting the frequency in begin() method to 915 MHz. That will bypass the error, though you won't be able to change the frequency of that module.

@DTronixs
Copy link
Author

Hi Jan
Yes, thats seems to be the problem. Changed code to

radio.begin(915);

and the error messages goes away.

thanks for your help

@jgromes jgromes closed this as completed Jul 10, 2020
@jgromes jgromes added question Generic question about code or usage resolved Issue was resolved (e.g. bug fixed, or feature implemented) and removed more information needed Further investigation is needed, not necessarily by the author labels Jul 10, 2020
@phretor
Copy link
Contributor

phretor commented Jul 12, 2020

Weird. I've just found the exact same issue on the 433MHz version of this Adafruit module. I was getting the very same error when setting frequency other than 915MHz (yes, 915, no 433).

#include <SPI.h>
#include <RadioLib.h>

#define RFM69_SS 13
#define RFM69_IRQ 27
#define RFM69_RST 15

RF69 rf = new Module(RFM69_SS, RFM69_IRQ, RFM69_RST);

void setup()
{
  Serial.begin(115200);

  delay(5000);

  Serial.println(F("[RF69] Module is initializing..."));

  int state = rf.begin(915);

  if (state == ERR_NONE)
  {
    Serial.println(F("begin(915) success!"));
  }
  else
  {
    Serial.print(F("failed, code "));
    Serial.println(state);
    while (true)
      ;
  }

  delay(1000);

  state = rf.setFrequency(433.4);

  delay(1000);

  if (state == ERR_NONE)
  {
    Serial.println(F("setFrequency(433.4) success!"));
  }
  else
  {
    Serial.print(F("failed setFrequency(433.4), code "));
    Serial.println(state);
    while (true)
      ;
  }

  rf.setFrequency(433.4);
  rf.setBitRate(1.55);
  uint8_t sw[] = {0xAA, 0xD5};
  rf.setSyncWord(sw, sizeof(sw));
}

Output:

[RF69] Module is initializing...
Found RF69! (match by RF69_REG_VERSION == 0x24)
begin(915) success!

address:        0x7
bits:           7 0
value:          0b1101100
current:        0b11100100
mask:           0b11111111
new:            0b1101100
read:           0b11100100


address:        0x8
bits:           7 0
value:          0b1011001
current:        0b11000000
mask:           0b11111111
new:            0b1011001
read:           0b11000000

failed setFrequency(433.4), code -16

There has to be something else, because I'm able to use this 433 module with RadioHead.

I double checked with a 915 (green dot on the package) and 433 (red dot on the package) module and I get the same behavior from RadioLib.

@jgromes
Copy link
Owner

jgromes commented Jul 12, 2020

@phretor can you independently verify the RadioHead code actually transmits at 433 MHz (e.g. with an SDR)? RadioHead doesn't verify SPI writes, so if it failed the same way, the module would still be at 915 MHz, you just wouldn't know.

@phretor
Copy link
Contributor

phretor commented Jul 13, 2020

Please hold on; I'm working on a more thorough test.

@phretor
Copy link
Contributor

phretor commented Jul 14, 2020

I confirm the bug is not there for the 433 module I was testing. Was a glitch in the connections.

@jgromes
Copy link
Owner

jgromes commented Jul 14, 2020

So the module is transmitting at 433 MHz with RadioHead and returning SPI fails with RadioLib? Or is it working correctly with both?

@phretor
Copy link
Contributor

phretor commented Jul 14, 2020 via email

@jgromes
Copy link
Owner

jgromes commented Jul 14, 2020

OK, thanks - so I guess some of the modules really are "locked" into 915 MHz.

@phretor
Copy link
Contributor

phretor commented Jul 15, 2020 via email

@rifath-shaarook
Copy link

Hi, I'm having 2 Adafruit Feather 32u4 with RFM69. Both are 433 MHz versions and transmitting just fine with RadioHead Library in 433 MHz, I have checked with SDR, but I put 433 MHz in RadioLib it's showing error -16. When I put 915, the error goes away but the module is neither transmitting in 433 nor 915, again I've confirmed with SDR, but it's showing "successfully transmitted" in serial port... The board is having Red dot on it which means it is a 433 MHz module.

Here is the details when I set in 433 MHz.
address: 0x7
bits: 7 0
value: 0b1101100
current: 0b11100100
mask: 0b11111111
new: 0b1101100
read: 0b11100100

address: 0x8
bits: 7 0
value: 0b1000000
current: 0b11000000
mask: 0b11111111
new: 0b1000000
read: 0b11000000

failed, code -16

@jgromes
Copy link
Owner

jgromes commented Aug 11, 2020

This issue is popping up way too often to be just coincidence - maybe it's the verification mechanism itself that's causing the problem (though I'm not sure why or how).

@rifath-shaarook could you try if using just a simple register write will resolve this? Go to RadioLib/src/modules/RF69/RF69.cpp and change lines 385 - 389 from

  int16_t state = _mod->SPIsetRegValue(RF69_REG_FRF_MSB, (FRF & 0xFF0000) >> 16, 7, 0);
  state |= _mod->SPIsetRegValue(RF69_REG_FRF_MID, (FRF & 0x00FF00) >> 8, 7, 0);
  state |= _mod->SPIsetRegValue(RF69_REG_FRF_LSB, FRF & 0x0000FF, 7, 0);

  return(state);

to

  _mod->SPIwriteRegister(RF69_REG_FRF_MSB, (FRF & 0xFF0000) >> 16);
  _mod->SPIsetRegValue(RF69_REG_FRF_MID, (FRF & 0x00FF00) >> 8);
  _mod->SPIsetRegValue(RF69_REG_FRF_LSB, FRF & 0x0000FF);

  return(ERR_NONE);

@rifath-shaarook
Copy link

Thank you so much...

It just worked like a charm and transmitting at the correct frequency... i.e. 433 Mhz

@jgromes
Copy link
Owner

jgromes commented Aug 12, 2020

It indeed looks like some RF69 modules just don't like the RF frequency registers being read. As far as I can tell, the datasheet mentions nothing about this. Usually I would be hesitant about disabling a safety feature, but in this particular case I'm more than happy to make an exception - this issue was reported a couple of times already.

@jgromes jgromes added the bug Something isn't working label Aug 12, 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 question Generic question about code or usage resolved Issue was resolved (e.g. bug fixed, or feature implemented)
Projects
None yet
Development

No branches or pull requests

4 participants