RFM69 Wireless Module Register Dump

Started by NixHydra, July 15, 2017, 03:34:16 AM

NixHydra

Hi Felix,

   Have noticed that you are now supporting the RFM69HW and RFM69CW and moving away from
the RFM69HW and RFM69W modules, which you previously used. It occurred to me that not only
myself but probably all your readers would probably find useful a copy of the RFM69 register contents
which you are using when initialising these FOUR modules.

   Please see the attached  RFM69CW  register dump, something like this for the FOUR modules would
be pretty helpful.

                                                          many thanks,

                                                                      Matt.

Felix

#1
Hi Matt,
Thanks for the suggestion, I like the matrix register print!
Do you have code that does this already?

By the way the "FOUR" modules are only different in layout, the chip they are based on is the same Semtech SX1231h, so the registers are the same. The content of the registers is whatever you program them with obviously, so you have to do that based on the hardware layout configuration, which the library helps you with.
Mainly:

- W and CW are equivalent (13dBm power)
- HW and HCW are equivalent (20dBm power)

It's like the same base vehicle at a dealer, to which you have 2 engine options (W and H), and comes in convertible and regular (C and non-C). Simple enough?

ChemE

Quote from: Felix on July 17, 2017, 08:20:13 AM
Hi Matt,
Thanks for the suggestion, I like the matrix register print!
Do you have code that does this already?

Me too Felix, much easier to look at than scrolling through a long list!  I went ahead a whipped something up.  The code could be more compact by writing out the header row as a string, but that comes at a cost of 46 bytes of RAM which I deemed not worth it.

static inline void WriteRegsCompact(void) {
  // Print the header row and first register entry
  Serial.print("\n     ");
  for ( uint8_t reg = 0x00; reg<0x10; reg++ ) {
    Serial.print(reg, HEX);
    Serial.print("  ");
  }
  Serial.print("\n00: -- ");

  // Loop over the registers from 0x01 to 0x7F and print their values
  for ( uint8_t reg = 0x01; reg<0x80; reg++ ) {
    if ( reg % 16 == 0 ) {    // Print the header column entries
      Serial.print("\n");
      Serial.print( reg, HEX );
      Serial.print(": ");
    }

    // Print the actual register values
    uint8_t ret = readReg( reg );
    if ( ret < 0x10 ) Serial.print("0");  // Handle values less than 10
    Serial.print( ret, HEX);
    Serial.print(" ");
  }
}

Felix

Thanks ChemE!
Talking about compactness ... have you or anyone tried the Streaming and PString libs?
They are awesome :)

ChemE

#4
Quote from: Felix on July 24, 2017, 10:13:57 AM
Thanks ChemE!
Talking about compactness ... have you or anyone tried the Streaming and PString libs?
They are awesome :)

Nice, never heard of either.  Despite its claims to the contrary Streaming did make my sketch 270 bytes larger.  Not sure why that is the case.  It certainly does make the code more readable and compact though.  Below is the same routine rewritten to use Streaming.

static inline void WriteRegsCompact2(void) {
  // Print the header row and first register entry
  Serial << "\n     ";
  for ( uint8_t reg = 0x00; reg<0x10; reg++ ) Serial << _HEX(reg) << "  ";
  Serial << "\n00: -- ";

  // Loop over the registers from 0x01 to 0x7F and print their values
  for ( uint8_t reg = 0x01; reg<0x80; reg++ ) {
    if ( reg % 16 == 0 ) Serial << "\n" << _HEX(reg) << ": ";

    // Print the actual register values
    uint8_t ret = readReg( reg );
    if ( ret < 0x10 ) Serial << "0";  // Handle values less than 10
    Serial << _HEX(ret) << " ";
  }
}

Felix

Here's my final version, tweaked to ensure newlines in any OS/monitor:

void RFM69::readAllRegsCompact() {
  // Print the header row and first register entry
  Serial.println();Serial.print("     ");
  for ( uint8_t reg = 0x00; reg<0x10; reg++ ) {
    Serial.print(reg, HEX);
    Serial.print("  ");
  }
  Serial.println();
  Serial.print("00: -- ");

  // Loop over the registers from 0x01 to 0x7F and print their values
  for ( uint8_t reg = 0x01; reg<0x80; reg++ ) {
    if ( reg % 16 == 0 ) {    // Print the header column entries
      Serial.println();
      Serial.print( reg, HEX );
      Serial.print(": ");
    }

    // Print the actual register values
    uint8_t ret = readReg( reg );
    if ( ret < 0x10 ) Serial.print("0");  // Handle values less than 10
    Serial.print( ret, HEX);
    Serial.print(" ");
  }
}


WRT arduiniana, my recollection is this library made sketches smaller, and also code more compact - you might need to replace all Serial.prints with it (not sure though).
WRT Streaming.h - being used to streaming ops I tend to see the code quite readable, but that's personal preference.

ChemE

Nice, please feel free to add this routine to the RFM69 library Felix.  For that matter, you may add any code I share here to your library if you would like.

Felix


NixHydra

Hi Guys,

   A big thanks to ChemE & Felix for this little library addition. As I suggested earlier, I suspect that many besides myself will find this useful. I have been away for a while and only just returned home, was going to follow up on this but thanks to your good work this is no longer necessary ... thanks for the GREAT support!!

                                                     cheers,

                                                           Matt.


Felix

No problem, you're welcome, thank YOU for contributing and suggesting a better alternative way!