I am using a RFM95W dragon Shield for Arduino, but I am bypassing the Arduino and connecting everything directly to a MSP430 MCU via the SPI-pins, DIO0, GND and NSS.
I seem to be able to read/write RH_RF95_REG_01_OP_MODE correctly into sleep mode(0x00), however when I set to RH_RF95_LONG_RANGE_MODE (0x80) it always goes go to RH_RF95_ACCESS_SHARED_REG (0x40) mode.
I have made sure enough current is fed and that a delay of 100ms is set after the sleep mode SPI write.
Code in C:
uint8_t init_RH_RF95()
{
RFM95W_SPISetup(); // using pin P5.0 as channel select
// Set sleep mode, so we can also set LORA mode:
RFM95W_SPIByteWriteReg(RH_RF95_REG_01_OP_MODE, RH_RF95_MODE_SLEEP | RH_RF95_LONG_RANGE_MODE);
__delay_cycles(2400000); // Wait 100ms for sleep mode to take over from say, CAD
// Check we are in sleep mode, with LORA set
if (RFM95W_SPIByteReadReg(RH_RF95_REG_01_OP_MODE) != (RH_RF95_MODE_SLEEP | RH_RF95_LONG_RANGE_MODE))
{
sprintf((char *)outString, "REG_01_OP_MODE: 0x%x \n",RFM95W_SPIByteReadReg(RH_RF95_REG_01_OP_MODE));
putsUART((unsigned char *)outString,strlen((char *)outString));
return 0; // No device present?
}else return 1;
}
That relates to power up specifically, in circumstances where you are controlling the NReset pin manually. After the SX127x has gone through it own power on reset sequence, and when you subsequently control NReset to manually clear the device, the required delay is 5mS.
There is a mention of other sleep mode issues in the datasheet;
“When switching to Sleep mode, the FIFO can only be used once the ModeReady flag is set (quasi immediate from all modes except from Tx)”
Try putting the device in to Sleep mode, then make a separate call to set it to LoRa mode. I think the problem is that you cannot combine the two in to the one call.
I also tried to write other types of modes to it, but it does always stay in sleep mode (0x00). So something happens when I write RH_RF95_LONG_RANGE_MODE(0x80) as it then goes to RH_RF95_ACCESS_SHARED_REG(0x40) for some reason?
Note: When the device starts the register reads 0x40 (RH_RF95_ACCESS_SHARED_REG ).
Understand that the library you appear to be using (Radiohead ?) is for point to point LoRa communication, so wont be used by the majority of TTN guys that watch this forum.