Can't set LoRa mode - RFM95 with MSP430


(Tibbe) #1

Hi!

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;
    }

I don’t know what is going wrong here?

Thanks in advance!


(LoRaTracker) #2

I dont know the answer to your specific question, but what is the reason for such a long delay after setting sleep mode ?


(Tibbe) #3

The delay is to make sure the device is in sleep mode, however I know that 100ms is too much and 1ms should be enough, but I wanted to be sure.


(LoRaTracker) #4

Do you know if there is a reference to a required delay (after setting sleep mode) in the device data sheet ?


(Tibbe) #5

Yes, it says 10ms, which did not work either. Data-sheet.
52


(LoRaTracker) #6

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)”

But no indication I can see of timings.


(tlu) #7

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.


(Tibbe) #8

Okay thanks for the info. So do I need to set the ModeReady flag by pulling DIO5 high?


(Tibbe) #9

I did try that already without any luck…

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).


(LoRaTracker) #10

No, the flag set internally by the LoRa device, when the device decides it is ready.


(Tibbe) #11

I don’t know where to debug now, electronics or software… The RFM95 just keeps getting stuck in either SLEEP_MODE or ACCESS_SHARED mode.

Any more help/tips would be grateful!


(LoRaTracker) #12

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.


(Tibbe) #13

I solved the problem by changing the SPI CLK frequency to 6Mhz (was at 12Mhz) as the RFM95 handles max 10Mhz.

Thank you anyway for your help!