Author Topic: Can't change SPI clock speed any more Moteino M0?  (Read 1029 times)

jdheinzmann

  • NewMember
  • *
  • Posts: 40
  • Country: us
Can't change SPI clock speed any more Moteino M0?
« on: September 10, 2020, 07:21:48 PM »
Hi, Felix,

I've updated my RFM69 library to 1.4.1 and can compile my sketches using it (after changing promiscuous -> spyMode).  But I can't change the SPI clock frequency by modifying RFM69.cpp like I used to (like this):

Code: [Select]
  #ifdef defined(__SAMD51__)
    //_spi->setClockDivider(SPI_CLOCK_DIV16);
    _spi->setClockDivider(SPI_CLOCK_DIV2); // JD - speed up SPI clock for Moteino M0
  #else
    _spi->setClockDivider(SPI_CLOCK_DIV2);
  #endif
No matter what I setClockDivider to the scope always displays an 8 Mhz SCK.

It turns out that 8 MHz is what I want but, why can't I change it any more?

If I ever need to adjust the SPI clock in the future, I would prefer to do it from my sketch instead of by editing the RFM69 library.  If this is possible, would you please tell me how to do it?

Thanks!
JD

Felix

  • Administrator
  • Hero Member
  • *****
  • Posts: 6866
  • Country: us
    • LowPowerLab
Re: Can't change SPI clock speed any more Moteino M0?
« Reply #1 on: September 11, 2020, 11:59:55 AM »
Look at the broader scope and this will start to make sense. The clock is set to 8mhz for SPI_TRANSACTIONS. You have to do other things if you want it faster.
But I am sure you have read the datasheet and fully understand that RFM69 takes only up to 10mhz SCK, right?  :o

Code: [Select]
#ifdef SPI_HAS_TRANSACTION
  _spi->beginTransaction(_settings);
#else
  // set RFM69 SPI settings explicitly
  _spi->setDataMode(SPI_MODE0);
  _spi->setBitOrder(MSBFIRST);
  #if defined(__STM32F1__)
    _spi->setClockDivider(SPI_CLOCK_DIV8);
  #elif defined(__arm__)
    _spi->setClockDivider(SPI_CLOCK_DIV16);
  #else
    _spi->setClockDivider(SPI_CLOCK_DIV2);
  #endif
#endif

redmond

  • NewMember
  • *
  • Posts: 1
Re: Can't change SPI clock speed any more Moteino M0?
« Reply #2 on: November 22, 2020, 05:38:02 PM »
Hello
I am trying to use the MOTEINO RFM69 fast packet code from jdheinzmann as suggested by Felix in private emails on RFM69 lowest short packet latency <= 1 millisecond.
Although I have written over 1/2 million lines of of C/C++ in the embedded world this is my first encounter with the Arduino world.

I am getting Arduino compiler errors that imply I have somehow included other similar RFM69 files from other RFM69 projects I downloaded earlier.
Can someone please supply me a complete working (no errors) ZIP of all the jdheinzmann RFM69 current files?

I will delete then all my previous Arduino RFM69 projects and do a clean install with the new zip and do a new build.
Thanks in advance Len

Felix

  • Administrator
  • Hero Member
  • *****
  • Posts: 6866
  • Country: us
    • LowPowerLab
Re: Can't change SPI clock speed any more Moteino M0?
« Reply #3 on: November 23, 2020, 10:20:47 AM »
Hi Len,
I will let jdheinzmann respond to that request if he is willing and able and watching this thread. Meanwhile, the gist of it all is shared in this thread:
https://lowpowerlab.com/forum/moteino-m0/best-way-to-speed-up-rfm69hcw-data-throughput-on-moteino-m0/

The first thing to do is getting Arduino, installing the Moteino SAMD package and RFM69 library as explained here, and compiling known working example sketches from the RFM69 library.

Once that is done the thread above will help you add/modify the relevant code to speed up SPI transfers and SPI_select routines to achieve faster packet transfers.