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.
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
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();
}
Or wait for serial connection:
Serial.begin();
while ( !Serial.isConnected() );
Serial.print("start"); 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);
}
}
#if defined (SPCR) && defined (SPSR)
SPCR = _SPCR;
SPSR = _SPSR;
#endifCan 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.
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
The reception part did not work as expected, but now seems to work ok.
the difference in the snippets was spi1 cf spi2, but they used the same divider.
clk into divider for spi1 and spi2 is?
stephen
// 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) ) {
...
}
I can read the registries and the temperature from the RFM69HW module.
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).

