RFM69

patafix
Fri Nov 25, 2016 2:03 am
Hello, I am new here. I am using https://github.com/LowPowerLab/RFM69 on my current AVR solution, however, it proves to be hard to implement it on Maple mini. There is this library https://github.com/ahessling/RFM69-STM32 that was implemented in plain C++, however it is not particularly well documented.
Any chance anyone has one already ported or can give some tips as to where to start? I manage to compile it without errors, but once I upload it to Maple mini clone – it just stops responding, so I know I have messed up somewhere.

It is very simplistic library (the LowPowerLab one), but I have had no experience of ARM mcus, so any tips would me much appreciated.


RogerClark
Fri Nov 25, 2016 3:13 am
You could try using the HAL core for STM32 and the non Arduino library

https://github.com/ahessling/RFM69-STM32

But it looks like it may use the old Standard Peripheral Library rather than the new STM HAL, so porting it to the HAL may not be that straight forward.

INstructions for the HAL core – see, viewtopic.php?f=16&t=1553
But you’ll need to download the Work In Progress branch https://github.com/stm32duino/Arduino_C … 1/tree/WIP

Alternatively to stick with LibMaple, then about your only choice unless you have a way to use the GNU Debugger (GDB) using STLink etc, is just to comment out code until it works.

If merely including the files causes it to hang, then the problem is likely to be in the constructor, especially if it attempts store references to pins before setup() has been called


stevestrong
Fri Nov 25, 2016 8:34 am
patafix wrote:I manage to compile it without errors, but once I upload it to Maple mini clone – it just stops responding, so I know I have messed up somewhere.

patafix
Fri Nov 25, 2016 9:12 am
Thank you for your replies.

It hangs at constructor, since I cannot get Serial.begin(115200); Serial.print(“start”); to display anything @ setup().
I will give it a go once more over the weekend.

Couple more questions:
// select the RFM69 transceiver (save SPI settings, set CS low)
void RFM69::select() {
noInterrupts();
#if defined (SPCR) && defined (SPSR)
// save current SPI settings
_SPCR = SPCR;
_SPSR = SPSR;
#endif
// set RFM69 SPI settings
SPI.setDataMode(SPI_MODE0);
SPI.setBitOrder(MSBFIRST);
SPI.setClockDivider(SPI_CLOCK_DIV4); // decided to slow down from DIV2 after SPI stalling in some instances, especially visible on mega1284p when RFM69 and FLASH chip both present
digitalWrite(_slaveSelectPin, LOW);
}

// unselect the RFM69 transceiver (set CS high, restore SPI settings)
void RFM69::unselect() {
digitalWrite(_slaveSelectPin, HIGH);
// restore SPI settings to what they were before talking to RFM69
#if defined (SPCR) && defined (SPSR)
SPCR = _SPCR;
SPSR = _SPSR;
#endif
maybeInterrupts();
}


stevestrong
Fri Nov 25, 2016 10:29 am
I would recommend to wait a period of time after Serial.begin(); (lets say 6 seconds).
Or wait for serial connection:
Serial.begin();
while ( !Serial.isConnected() );
Serial.print("start");

patafix
Mon Nov 28, 2016 2:18 pm
Interesting discovery. Tried out something simple – read register values from RFM69HW.
Returns all 0 values if I use SPI1 port (Pins 4-7) on Baite Maple mini.
Returns expected values if I use SPI2 port (Pins 28-32) on Baite Maple mini.

Checked all connections and signals arrive to soldered pins, maybe it is a faulty pcb, will have to order another one to check. Code for reference.

Works:
#include <SPI.h>

byte data;
#define chipSelect 31
SPIClass spi(2);

void setup() {
spi.begin(); //Initialize the SPI_1 port.
spi.setBitOrder(MSBFIRST); // Set the SPI_1 bit order
spi.setDataMode(SPI_MODE0); //Set the SPI_2 data mode 0
spi.setClockDivider(SPI_CLOCK_DIV16); // Slow speed (72 / 16 = 4.5 MHz SPI_1 speed)
pinMode(chipSelect, OUTPUT);
Serial.println("aa");
}

void loop() {
readRegs();
delay(5000);
}

void readRegs()
{
byte regVal;

for (byte regAddr = 1; regAddr <= 0x4F; regAddr++)
{
digitalWrite(chipSelect, LOW); // manually take CSN low for SPI_1 transmission
spi.transfer(regAddr & 0x7f); // send address + r/w bit
regVal = spi.transfer(0);
digitalWrite(chipSelect, HIGH); // manually take CSN low for SPI_1 transmission

Serial.print(regAddr, HEX);
Serial.print(" - ");
Serial.print(regVal,HEX);
Serial.print(" - ");
Serial.println(regVal,BIN);
}
}


patafix
Mon Nov 28, 2016 5:10 pm
OK, quick update RFM69HW works fine on Baite Maple mini. Had to change SPIClass to use SPI2 as default and comment out
#if defined (SPCR) && defined (SPSR)
SPCR = _SPCR;
SPSR = _SPSR;
#endif

stevestrong
Tue Nov 29, 2016 9:20 am
In general, I would recommend you to use the PXy (ex. PA5) naming convention for defining GPIOs, not simple numbers.

stevestrong
Thu Feb 16, 2017 10:48 pm
@patafix,
Can you please post here the lib for RFM69 you ported for STM32F103?
I am asking this because I am currently also working with this chip and have some problems.

zmemw16
Sun Feb 19, 2017 12:52 am
spi1 v spi2 long, long thread … … …
no one going to mention clk source and dividers ?
try spi1 again with SPI_CLOCK_DIV32 ??
or have got the wrong idea from tha thread?

stephen


stevestrong
Sun Feb 19, 2017 11:55 am
My issue was not related to SPI.
The reception part did not work as expected, but now seems to work ok.

zmemw16
Sun Feb 19, 2017 6:14 pm
apols
the difference in the snippets was spi1 cf spi2, but they used the same divider.
clk into divider for spi1 and spi2 is?
stephen

stevestrong
Sun Feb 19, 2017 6:32 pm
I am mostly using beginTransaction mit settings:
// Start up
SPI.setModule(1); // nRF905
SPI.beginTransaction(SPISettings(9000000));
nRF905_Init();
Serial.println(F("-> nRF905 initialised."));

Serial.print("Initialise RFM69...");
SPI.setModule(2); // RFM69
SPI.beginTransaction(SPISettings(9000000));
if ( !rfm69.begin(RFM69_CS, RFM69_RST) ) {
...
}


zmemw16
Sun Feb 19, 2017 9:13 pm
well worth a mention :)

kylix
Sun Jul 16, 2017 8:13 am
I’m having problems too on a STM32L053R8 board. The sketch compiles OK and runs on the board but the gateway doesn’t receive any message.
I can read the registries and the temperature from the RFM69HW module.

stevestrong
Sun Jul 16, 2017 8:23 am
With a RTL SDR you could test whether the TX part is really working.

kylix
Sun Jul 16, 2017 10:15 am
I’m not sure about the IRQ settings. The library I’m trying to use is this: https://github.com/brainelectronics/RFM69-STM32

PS: I’ve just checked with SDRSharp software and … nothing goes out from the TX. (I have other 433Mhz nodes and I can clearly see when they transmit).


Leave a Reply

Your email address will not be published. Required fields are marked *