Hang writing to RFM69HW from Arduino Mega 2560 [solved: bad RFM module]

Started by lennyg, October 21, 2018, 07:06:43 PM

lennyg

Hi. I have quite a few Arduino Unos running 3.3V with RFM69HW with no problem. For the first time, I'm trying to use a Mega 2560 (which is 5V). I've connected it to the RFM69HW through a logic level converter. Whenever I try to write to the RFM69HW, the sketch hangs.  I'm pretty sure I have some sort of wiring or hardware problem.  Can anyone give me any pointers on how to debug this?

Thanks

LukaQ

How did you implement level shifter?
Do you have 3.3v on RFM side? sometimes it is provided by level shifter itself, from 5v.
Do you have correct pins from RFM connected to correct pins (path) of level shifter? flow goes from output through level shifter to input on the other side (no matter if it is 5v or 3.3v side)
Do you have all pins go through level shifter, that need to go, in SPI that would be 4, SLK, MOSI, MISO and chip select (NSS I think). But in case of RFM also DIO0. GND is the same between both systems and 3.3v is most of the time derived from 5v.

But in this application, that is no enough. most of the time LDO or how ever 3.3v is made from 5v, they can't souce enough current for RFM, so it is best that you provide 3.3v power on the other side and you use level shifter only for signals

lennyg

Thanks LukaQ.  I hooked it up as described at https://cdn.sparkfun.com/assets/f/1/0/e/9/fritzing-redboard.png, which means that DID0 is not going through the level shifter. Do you think this should work?

perky

Quote from: lennyg on October 25, 2018, 09:29:28 PM
Thanks LukaQ.  I hooked it up as described at https://cdn.sparkfun.com/assets/f/1/0/e/9/fritzing-redboard.png, which means that DID0 is not going through the level shifter. Do you think this should work?
What radio module is that? The wiring diagram appears to only connect to DIO signals, the SPI are not connected at all (unless this is a different module with a different pinout).

Mark.

lennyg

I got to that diagram from https://learn.sparkfun.com/tutorials/rfm69hcw-hookup-guide/all, which explains how to wire an RFM69HCW. I'm not sure why you're saying that the SPI are not connected. They are connected through the level converter. For example, the yellow wire (labeled "I" on the diagram) is connected to LV3, which is converted to HV3, which is connected to pin 11 on the Arduino.

perky

#5
Quote from: lennyg on October 27, 2018, 04:07:58 PM
I got to that diagram from https://learn.sparkfun.com/tutorials/rfm69hcw-hookup-guide/all, which explains how to wire an RFM69HCW. I'm not sure why you're saying that the SPI are not connected. They are connected through the level converter. For example, the yellow wire (labeled "I" on the diagram) is connected to LV3, which is converted to HV3, which is connected to pin 11 on the Arduino.
OK, sorry. In your original post you said RFM69HW, that has a different pinout to the RFM69HCW but this is a module carrier. In which case the SPI looks OK assuming the logic shifter is one of these bidirectional types
https://learn.sparkfun.com/tutorials/bi-directional-logic-level-converter-hookup-guide/all

Technically putting a 3.3V buffer output into a 5V AVR input is not sufficient to guarantee a logic 1, in practice it'll probably be OK as the actual logic threshold of the 5V AVR is usually closer to 2.5V in reality. You could add a FET if you want to be sure.

Edit: I got confused again by the module pinout, I'm assuming the 0 is actually DIO0.

Mark.

lennyg

I found part of my problem.  I hadn't realized that the SPI on the Mega 2560 uses different pins from the Uno. The Uno uses NSS:10, MOSI:11, MISO:12: SCK:13, while the Mega uses NSS:53, MOSI:51, MISO:50, SCK:52. So I fixed that but I'm still having the same problem.

I forgot to mention that I'm using Felix's RFM69_LowPowerLab library.  I decided to put some print statements in RFM69.cpp to see if they would give me any clues.  The problem seems to be waiting for ModeReady.

void RFM69::sendFrame(uint8_t toAddress, const void* buffer, uint8_t bufferSize, bool requestACK, bool sendACK)
{
  setMode(RF69_MODE_STANDBY); // turn off receiver to prevent reception while filling fifo
  Serial.println("Waiting for modeReady");
  while ((readReg(REG_IRQFLAGS1) & RF_IRQFLAGS1_MODEREADY) == 0x00); // wait for ModeReady
  Serial.println("Back from waiting for modeReady");

When I do a send, the Waiting message gets printed, but it never gets to "Back from waiting for modeReady".

lennyg

The problem turned out to be a bad radio.  When I use a new RFM, everything started working.