Unstable time to transmit a message on RFM69HCW when there is another SPI

Started by ITman496, August 03, 2022, 04:59:30 PM

ITman496

EDIT:  Upon further testing, I've found a solution.  For anyone who comes across this:  Call radio.receiveDone(); and then have a small delay, such as 1 millisecond.  This gives the radio a chance to 'wake up' from being off SPI and actually listen.  My TX's are now always within 4-5ms instead of varying wildly between 5 and 200+ms.  Sometimes (1 in every 1-300 xmits) it will shoot up to 10-15ms.  But that's fine.

Hello!

I am making a robot handheld controller with a screen on it that will use an RFM69HCW on each side to communicate.  I'd like it to transmit/receive as fast as possible.  My target right now is a whole cycle every 50ms or so.

The issue I am running into is with bidirectional communication.  But only when I am also talking to another SPI device between reads and writes.

It takes an unpredictable time for this transmission, and I am unsure why.  Sometimes it takes a few milliseconds, sometimes it takes over a hundred.

I can't really post my whole code since it's tied hopelessly in with a lot of other parts, but I'll put the gist of what I'm doing here.

915mhz RFM69HCW, no acks, no encryption.

I call a receive routine which is just the example one.

I then do about 9ms worth of other work, mostly display driver stuff.  This is a different SPI device.

Then I call a transmit, which assembles a 40ish byte packet of data and sends it off.

Then I call radio.receiveDone(); to put it into RX mode again.

Then I finish doing another 20ms worth of other functions, mostly display, again.  This is again to another SPI device.

And then it repeats.

On the other side I have a test node which simply receives the data, does a 10ms delay by flashing the light, and then transmits a test packet out, and repeats.

What can be causing this unpredictable delay?  if I comment out radio.receiveDone(); I no longer pick up the packets from the test node, but the delay for transmission becomes a consistent 5ms always with no randomness.  So something is causing a huge delay for the transmission.

Also, I just wrote a test program that only talks to the radio, and now its perfect.  So if I am only talking to the radio and no other devices, but have delays in the system instead of other devices, it switches just fine.  I am utterly confused, haha..  Something about coming in and out of SPI for the RFM69HCW causes it to take a huge amount of time to transmit, sometimes.

Is there any solution?  Let me know if any more info is needed.  I am trying to replicate with example code that can run on anything and post here.. but it continues to elude me.