? Reading RFM12B SPI traffic

Added by sketchy 10 months ago

I captured the config traffic that happens upon start of RF12Demo using a logic analyzer.

I was able to figure out what was going on using JeeLab's RFM12B Command Calculator

However, I don't understand.
I would think I could figure this stuff out looking at the Hope data sheet but wasn't able to decode the bytes based on what I saw in the data sheet.

So my question:
can I decode the bytes and get the same results I got using the command calculator through the data sheet? If yes - could you please walk me through one reading?

i tried to google to get more info on RFM12B SPI traffic...but didn't find anything that was of great help (could have missed it..). Any recommendations?

Thanks very much.


Replies (22)

RE: ? Reading RFM12B SPI traffic - Added by martynj 10 months ago

@sketchy, the config traffic is pretty much what it says on the can (the defaults at the bottom of the command calculator)
Are there any knobs to twiddle on the logic analyzer for endian? You have CS hooked in?

RE: ? Reading RFM12B SPI traffic - Added by sketchy 10 months ago

Hey @martynj,
I am getting the bytes out correctly from the analyzer. It is reading great. I then take it to a .csv and import into a google spreadsheet. From there, it is easy for me to read the bytes because they map well to the command calculator.

MY CHALLENGE is I can't take the DATA SHEET and read the bytes I get from the SPI bus through the logic analyzer into anything meaningful. I assume this is because I am new to reading SPI traffic. I found the command calculator to be amazing. However, what would I do if I only had the data sheet? This is a learning exercise so that I can take a logic analyzer and apply it to other SPI traffic. (NOTE: my ultimate goal is one of the components - I believe the cc3000 802.11 one - is preventing the SPI traffic to go through when it is plugged in.

MY GOAL is to gain as much familiarity as needed with SPI traffic.

Any advice on how to proceed is greatly appreciated.

Thank you for your response!

RE: ? Reading RFM12B SPI traffic - Added by martynj 10 months ago

@sketchy,

Ok, just to make sure we are on the same page - if you send a test packet with obvious contents, the known payload is clearly visible? Track back to step over the header info, then a command to start transmitting should be there.  If that is copasetic, then take a peek at the RFM12 driver code and verify the order that the config registers are set.   

Referring to the goal of understanding the conflict with 802.11 card, does the clash occur when the card is physically on the bus, but not yet initialised? Or the moment its driver becomes active?

If your logic analyser has spare channels after hooking up all the signals you need for the SPI decode, a good debugging trick is to add a probe to a spare DI/O pin and then inline code to do a status flip on that pin at some meaningful point in the code ( sort of electronic version of a printf() ).

RE: ? Reading RFM12B SPI traffic - Added by sketchy 10 months ago

Hey @martynj (and of course any other folks!)
Any advice on solving this challenge of SPI traffic 'accident' would be GREATLY appreciated!

I took time before replying to figure stuff out regarding the Logic Analyzer results I receive when the RFM12B board shares the SPI bus with Adafruit's cc3000 wifi board. I am new to both logic analyzers and SPI traffic. Here is what I have learned/done so far:

This sketch works (both RFM12B and cc3000 are wired to Arduino Uno's SPI bus. RFM12B uses pin 9 for CS. cc3000 uses pin 8 for CS.

void setup(void)
{
  Serial.begin(57600);
  Serial.println("...Setting RFM12B CS to 9");
  rf12_set_cs(9);
  Serial.println("...initializing RFM12B - node 1, 915MHZ, group 33");
  rf12_initialize(1, RF12_915MHZ, 33);
}

void loop(void)
{
  if (rf12_recvDone() && rf12_crc == 0) {
    Serial.println(F("Receive data"));
    for (byte i = 0; i < rf12_len; ++i)
      Serial.print(rf12_data[i],HEX);
    Serial.println();
  }
  if (sendTimer.poll(3000) && rf12_canSend()) {
    Serial.println(F("Send data"));
    rf12_sendStart(0, payload, sizeof payload);
  }
}

An image of the serial monitor

Serial output when RFM12B TX/RX working

A snapshot of SPI packets that have the payload 'H' (0x48) 'e' (0x65)

Snapshop of SPI packets (working)

a PDF file that includes the MOSI/MISO SPI packets for both working and NOT working is included (SPI Tests - RFM12B and cc3000(1).pdf)

NOW - I ADD INITIALIZATION of the cc3000 to the sketch and the RFM12B keeps sending out 0xB000 -> RF_RX_FIFO_READ but MISO returns 0xFF 0xFF...
ARDUINO UNO NO LONGER RECEIVES DATA FROM THE RFM12B after cc3000.begin() completes (call from Adafruit's/TI's cc3000 library).

//..lines added to the sketch right after rf12_initialize()
    if (!cc3000.begin())
    {
      Serial.println(F("Unable to initialize the CC3000! Check your wiring?"));
      while(1);
    }

the PDF file shows the MOSI/MISO SPI packets when this sketch is run.

Here is a snapshot from the logic analyzer

Snapshop of SPI packets (not working)

SerialOut.png - Serial output when RFM12B TX/RX working (16.1 KB)

RFM12BTXRXWorks.jpeg - Snapshop of SPI packets (working) (652 KB)

SPI Tests - RFM12B and cc3000 (1).pdf - SPI MOSI/MISO packets from logic analyzer (98.4 KB)

RFM12BBroke.png - Snapshop of SPI packets (not working) (152 KB)

RE: ? Reading RFM12B SPI traffic - Added by martynj 10 months ago

@sketchy,

Does that nice logic analyser have a 'scope mode?  Need to see the raw voltage levels on MISO. It is stuck high after the cc3000.begin(). Since the SPI bus is inverted logic, that maps to the FF (falsely) decoded.

At a pinch, DVM readings should be enough…

Is there a schematic for the CC3000 breakout board? A quick scan of the site was in vain.

RE: ? Reading RFM12B SPI traffic - Added by sketchy 10 months ago

THANK YOU @martynj.

I asked about the cc3000 SPI implementation and received this info on the Adafruit forum: the breakout version of the cc3000 needs something to buffer MISO as it is not tristated

According to [[http://learn.adafruit.com/adafruit-cc3000-wifi/connections]]

On the breakout, be aware that the MISO (data out from module) pin does not go 'high impedance' when CS is driven low. Check the shield for how we use a 74AHC125 to manually tri-state this pin when it's shared with an SD card.

Assuming this is the challenge (and I assume it would show up in a logic analyzer trace as you saw?) what would you advise I add to the circuit to fix this? I thought perhaps a pull up resistor? Again - I apologize - I am new but I would like to fix this and am hoping if you provide some guidance I will try very hard to figure out the rest.

(thank you for pointing out MISO stuck on high. I kept looking at the two images and did not see that until you pointed it out. It is exciting for me to learn this. Again - thank you).

RE: ? Reading RFM12B SPI traffic - Added by martynj 10 months ago

Hmm, there is more to this story than meets the eye.  The RFM12B is nicely behaved, floating that pin when not selected. The CC3000 has a different approach - floating at reset time, then a permanent  pull up to its Vcc after internal initialisation.  Not very SPI sharing friendly, but just about ok.

Here is the crux of the matter.  You need to make a decision about the choice of system Vcc supply value.  The early Arduino world is 5V (now increasingly 3.3V or sometimes mixable).  The JeeNode world is 3.3V - as are many devices that end up on plugs/shields.

Why decide?  Shuffling around between a 5V v. 3.3V world is inefficient (power, real estate etc) and has traps as illustrated by this interworking failure.  I'm biased towards 3.3V (pun intended), partly because of the interest in lower power operation (which often maps to whatever the power source can give, heading down to 2V or lower).

RIght now you have a 3V RFM12B module with a simple level shifter to cope with 5V SPI bus signals, an AtMega running on 5V and a CC3000 module which is not 5V Vin tolerant (so more converters lurking on that breakout board - where IS the schematic hiding BTW?)

Can this combination be made to work?  Sure. Add more glue logic (hmm..) Get the stylo knife out and "improve" the breakout board.  I guess it depends where you want this journey to take you…

RE: ? Reading RFM12B SPI traffic - Added by sketchy 10 months ago

I found the cc3000 schematic of Adafruit's breakout board.

I noted there is a 74AHC125 on the shield as noted in Adafruit's forum reply: "Check the shield for how we use a 74AHC125 to manually tri-state this pin when it's shared with an SD card." There is also a level shifter on the breakout board?

Re 5V v. 3.3V. Decision: what works best. Seems 3.3V. I do not wish to shuffle. So 3.3V

Re: where I want this journey to take me:
1) (LEARN) get better with electronics. I come from a sw background. The best learning has come when I am persistent about getting to the bottom of why something doesn't work. An example of this is when you made important insight on my soldering job. I took your comments, worked on fixing the soldering challenges you noted, and the board actually worked. If the board worked was less important than me just giving up and ordering one that was soldered together. Because I was able to increase my soldering skills as well as boost my confidence.

2) (BUILD) Implementation of a "Base System" that receives data from sensor nodes, data logs locally, and sends data to a web service for viewing from the web and mobile device. Right now I have the RFM12B board, cc3000 breakout board, Adafruit's SD Shield and the Arduino Uno. I am agnostic to the components/RF used as long as I can get to the functionality.

So right now there are two paths in my journey: 1) I really want to get to the bottom (and fix?) the component combination I have 2) I must get a "Base System" built.

Any advice on next steps - GREATLY APPRECIATED..

RE: ? Reading RFM12B SPI traffic - Added by sketchy 10 months ago

Hey @martynj (or anyone else who would like to offer advice?)

If possible, I'd like to keep trying to get the SPI between cc3000 breakout board and RFM12B to work. Based on what we have learned so far, could you please give me advice as to what you would try next?

I could be being pushy. If that is the case, please let me know.

You (and others on this forum) have always been tremendously helpful. I do not wish to abuse your kindness.

Thank you.

RE: ? Reading RFM12B SPI traffic - Added by martynj 10 months ago

@sketchy,

The cc3000 breakout board has shall we say a "glitch". If I can read that fuzzy schematic properly, the SPI bus can't be shared unmodified.
Fixable? Yes, but this has to be done at the raw hardware level. The cleanest is probably to mod the PCB - exacto knife and delicate soldering time!

RE: ? Reading RFM12B SPI traffic - Added by sketchy 10 months ago

@martynj,
Thanks so much for the clarification. I can't fix this - I will notify/ask for comment from TI as well as vendors using this chip within their boards.
You've been very helpful.

RE: ? Reading RFM12B SPI traffic - Added by martynj 10 months ago

@sketchy, the CC3000 behaviour - floating at reset time, then a permanent  pull up to its Vcc after internal initialisation is reasonable.  It's the (lack of) thinking when adding on the 3v - 5v conversion on the breakout board.

As I mentioned, moving to a 3v only implementation removes the need for these tricky logic level conversions.

RE: ? Reading RFM12B SPI traffic - Added by sketchy 10 months ago

@martynj - again, thank you. I will move to a 3V only implementation. I apologize for you having to repeat this advice.

RE: ? Reading RFM12B SPI traffic - Added by martynj 10 months ago

@sketchy,

No problem.  The 3V/5V choice is not clearcut - depends what parts on hand, sensor availability in 3V etc.

Ok, so what could be salvaged?   The RFM12B board is dual, just needs the 6 resistors removing along with the LDO (shame after all that soldering !) and three bridging blobs made.  Diagonal wire snips are your friend. Don't bother with the wire stumps left in the PCB unless you have a solder sucker and/or solder wick.

The Uno gets assigned to some other project.

The CC3000 breakout board.  Hmm - the module is already dual 3.3V/5.5V I/O capable, but it sits in a sea of conversions. Some judicious surgery could float its boat, but that puts you back in the business of significant board hacking.

Could you handle a little kludge circuit on a small piece of breakout board to mount one tiny PMOS FET and terminate a few linking wires?

RE: ? Reading RFM12B SPI traffic - Added by sketchy 10 months ago

@mertynj,
Based on what you said, I'd like to recap to make sure my understanding is correct. The reason I wish to do this is I am quite sure there are things I am wrong about due to my "Electronics as a Second Language."
1. The arduino uno operates its digital i/o at 5v
2. The cc3000 operates its digital i/o at 3v
3. the cc3000 breakout board includes a level shifter to allow i/o to go between the Arduino and the cc3000.
4. After cc3000 initializes, it permanently sets the digital i/o at 3v. Although the "details" section of Adafruit's listing of this product notes it can work equally well at 5v, that doesn't seem to be the case.
5. Thus, the "ideal" situation would be for the cc3000 not to permanently pull up its Vcc. Then the RFM12B - operating at 5v - could communicate with the Uno since they are both sending / receiving "on" "offs" at 5v.
6. I have the RFM12B board's digital i/o operating at 5v. I could get it to operate at 3v by doing what you say above (i.e.: remove the level shifter "stuff")
7. Now the cc3000 and RFM12B board's digital i/o operates at 3v. But there is still the Uno at 5v....
8. Why isn't the change to replace the Arduino Uno with at ATmega "Arduino" that operates its digital i/o at 3v? (or is that what you are saying - I apologize again for my "Electronics as a Second Language").

thank you.

RE: ? Reading RFM12B SPI traffic - Added by martynj 10 months ago

@sketchy,

1. The arduino uno operates its digital i/o at 5v ... Yes
2. The cc3000 operates its digital i/o at 3v ... It can handle 3V or 5V I/O directly
3. the cc3000 breakout board includes a level shifter ... Yes
4. After cc3000 initializes, it permanently sets the digital i/o at 3v... Sort of, it connects a pull up to Vio.

Let's take it from this far.

  • The signal taken high through probably a weak pullup. This is fine if the signal was going direct to the SPI bus, and in fact is a requirement when operating SPI over more than a few inches.
  • The breakout board level converter sees the 3V high as an input and drives a 5V high hard independent of CC3000 selected
  • The poor RFM12B working at 3V through a resistor divider doesn't stand a chance to pull this signal down.
  • Minimal solution is to only allow the breakout board version of the signal onto the SPI bus when the CC3000 is selected

This will take some glue logic as mentioned above.

Disclaimer: This is based on going cross-eyed over a fuzzy pdf schematic. YMMV

RE: ? Reading RFM12B SPI traffic - Added by sketchy 10 months ago

Hey @martynj,
I got it to work in software by wrapping the calls to the cc3000 in wlan_start(0) and wlan_stop() ...stop resets = so I guess this puts the MISO line into float?

I detail what I learned and what I did here:[[http://bitknitting.wordpress.com/2013/12/02/debugging-the-spi-bus-when-components-wont-share/]]

I am hopeful I gave you the credit you deserve. I will continue bumbling around my learning of electronics and try out a level shifter solution.

Thank you for all your insights.

RE: ? Reading RFM12B SPI traffic - Added by martynj 10 months ago

@sketchy,  ingenious!  That will do it - and staves off the day you get the soldering iron out  ;-)

RE: ? Reading RFM12B SPI traffic - Added by sketchy 10 months ago

@martynj - high praise coming from you. Actually, it is best for me to get the soldering iron out. I very much want to improve my practical knowledge of electronics. I wish there was someone local to my area that I could spend an hour a week getting hands on mentoring. I'd pay for it. I'd go off and do these projects and a mentor would meet with me and go over/suggest/explain. I could make faster progress this way. If you (or anyone) knows of someone in the Seattle area...

Thank you for your patient help. I would not have been able to get this far without it.

RE: ? Reading RFM12B SPI traffic - Added by martynj 10 months ago

@sketchy, certainly a good idea to bootstrap your understanding with some direct mentoring. Try googling 'Seattle Hackerspace' and see if there is a workshop within reach.

RE: ? Reading RFM12B SPI traffic - Added by sketchy 10 months ago

There is indeed a hackerspace in Seattle. I have been there several times. I really wanted to like it. The service and quality of folks working there for the most part was not high. For example, I went to try out a logic analyzer. The employee that "volunteered" to help me set up the lines hooked the outer plastic to the logic analyzer clip. He didn't understand how the logic analyzer's software navigated. There was one guy there who seemed really good. But he quit. I took a few courses (arduino, kicad) and did not get much out of it. A specific example: I brought a mac w/ kicad. ANyone who has tried kicad on a mac knows it is impossible to use. This wasn't mentioned and the guy teaching had no idea. All he did was walk us through the UI. There are better videos on youtube than what I sat through....

Sadly.

RE: ? Reading RFM12B SPI traffic - Added by martynj 10 months ago

@sketchy, you could also try the Amateur Radio community (beware the term 'Ham Radio' - considered pejorative by many).

(1-22/22)