[Solved] Photon Blocking w/RF24 Lib

OK, I need one of you super smartguys to take a look and tell me why this puts the photon into blocking and never returns. I verified yesterday that the radio basically works with printDetails can listen using the testCarrier function but if I attempt to do anything that calls for a read or write register…blocks and that is it until a hard reset and tinker reflash.
Wired up like so w/100uF cap between VCC and GND.

  SPARK Photon    NRF24L01+
  GND                  1 (GND)
  3V3 (3.3V)          2 (3V3)
  D6 (CSN)           3 (CE)
  A2 (SS)             4 (CSN)
  A3 (SCK)           5 (SCK)
  A5 (MOSI)         6 (MOSI)
  A4 (MISO)         7 (MISO)

Everything halts when I call this

    radio.enableDynamicPayloads();

Which is defined like this.

void RF24::enableDynamicPayloads(void)
{
  // Enable dynamic payload throughout the system
  write_register(FEATURE,read_register(FEATURE) | _BV(EN_DPL) );

  // If it didn't work, the features are not enabled
  if ( ! read_register(FEATURE) )
  {
    // So enable them and try again
    toggle_features();
    write_register(FEATURE,read_register(FEATURE) | _BV(EN_DPL) );
  }

  ////Serial.print(printf("FEATURE=%i\r\n",read_register(FEATURE)));

  // Enable dynamic payload on all pipes
  //
  // Not sure the use case of only having dynamic payload on certain
  // pipes, so the library does not support it.
  write_register(DYNPD,read_register(DYNPD) | _BV(DPL_P5) | _BV(DPL_P4) | _BV(DPL_P3) | _BV(DPL_P2) | _BV(DPL_P1) | _BV(DPL_P0));

  dynamic_payloads_enabled = true;
}

I’m not sure and I haven’t really dug into the library very deep, but since the library was originally written/ported for the Spark Core it might be a SPI speed issue.

The library sets this

  // Was 4Mhz on Arduino
  SPI.setClockDivider(SPI_CLOCK_DIV16); // 4.5Mhz (if using <= 2mbps data rate)
  //SPI.setClockDivider(SPI_CLOCK_DIV32); // 2.25Mhz (if using <= 1mbps data rate)

which would work out as almost 7MHz on the Photon.


You could fork the library and add some serial debug lines to norrow down a bit more where exactly the lib stalls (and try to change SPI speed).

CLOCK_DIV16 is the key here…and I put my radio.begin() behind trying to modify a register…Working now and onto the Sensebender Micro to establish some radio comms!