[Logo] Anarduino and HopeRF Community Forum
  [Search] Search   [Recent Topics] Recent Topics   [Hottest Topics] Hottest Topics     [Groups] Back to home page 
[Register] Register / 
[Login] Login 
SPI Conflict?  XML
Forum Index » Anarduino
Author Message
athtest800



Joined: 06/11/2014 01:24:40
Messages: 4
Offline

Hello!
I use the RFM69HW Mini wireless.
I added an ST7735 LCD by using either the UTFT either the adafruit ST7735 library https://github.com/adafruit/Adafruit-ST7735-Library.
The result is 3-5 white(?) pixels that are shown on LCD. This is very ugly.
The problem appears with this function
with the LowPowerLabs https://github.com/LowPowerLab/RFM69 and
with the RadioHead http://www.airspayce.com/mikem/arduino/RadioHead/.

What can i do to solve it?
Thank you.
Rick



Joined: 30/05/2014 22:08:56
Messages: 93
Offline

Greetings,
I've not seen this type of problem, and I have shared the SPI bus with many devices on quite a few projects.
Unfortunately I don't have one of those displays, and thus not in a position to reproduce the problem.
Not having seen the schematic or code involved, I can't really see the whole picture, but here are a few thoughts:---
Is the SPI mode and clock within specification for the display?
Is there an SPI device select overlap?
Is operational voltage within spec on devices involved?
When you're done with one device, what do you do with the spi select for that device? is it deasserted or left floating?
Does the problem go away if you insert a delay between bus usage?
Of course my assumption here is that the library for the display is bug free?
Do you happen to have a scope and/or logic analyzer to view SPI bus activity during operation?
Not sure if this helps, but there has been some buzz about SPI, perhaps check out the post concerning simultaneous SPI usage.
http://forum.anarduino.com/posts/list/18.page
Also there is a hackaday blurb:
http://hackaday.com/2014/08/01/arduino-spi-library-gains-transaction-support/
perhaps this along with a few searches can lead to an elegant solution.

Please let us know how things work out, as this insight could be useful for others.
Thank you.

Best Regards,
Rick
stevech



Joined: 07/07/2014 18:07:27
Messages: 91
Offline

athtest800 wrote:Hello!
I use the RFM69HW Mini wireless.
I added an ST7735 LCD by using either the UTFT either the adafruit ST7735 library https://github.com/adafruit/Adafruit-ST7735-Library.
The result is 3-5 white(?) pixels that are shown on LCD. This is very ugly.
The problem appears with this function
with the LowPowerLabs https://github.com/LowPowerLab/RFM69 and
with the RadioHead http://www.airspayce.com/mikem/arduino/RadioHead/.

What can i do to solve it?
Thank you.
The RadioHead driver, and probably also LowPowerLab's driver (independent software suites), the interrupt service routine (ISR) for the radio uses the SPI port. The ISR makes the assumption that it can use the SPI port at any time. When your LCD is using the SPI port, it can get interrupted by the radio's ISR and now we have a mess. The radio's ISR runs at the end of a transmitted or received packet.

The LCD software can disable interrupts while using the SPI port - that's brute force.
The LCD software can set the external interrupt mask bit for the radio's IRQ bit, while the LCD is using the SPI.
The LCD software can force the radio into its idle state (not receiving or transmitting cannot interrupt) - use the SPI port, then reenable the radio with a call to available()

ALso, there's an issue if the LCD and the radio want the SPI to be in different configurations, such as SPI clock frequency. Each device might initialize SPI at startup but do so differently.

This overall issue of SPI port-sharing, in the Arduino community, is known issue that arises because people develop drivers without think of SPI port sharing.

Paul at PJRC.com (teensy 3) has a library to manage SPI port sharing. But SPI-based devices have to use that library instead of the generic SPI library. The new library "SPI Transactions" is availble but slow to be adopted. It brings problems, too, such as: If some SPI-based device uses SPI Transactions to "own the SPI port" for a while, real-time devices like the data radios can on occasion miss an incoming message - if the port is "Hogged" too long. This happens at low SPI clock frequencies and/or large SPI transfer loops such as in an SD card.

So the 3 hacks, above, are all I can suggest.
This presumes that you do have a conflict with the radio's ISR as described above. If the LCD driver is already disabling interrupts while using the SPI, every time, everywhere, then there could be an issue with the two devices wanting the SPI bit rate or byte format to differ, and they don't reestablish the SPI port prior to each use. RadioHead only configures once.

This message was edited 1 time. Last update was at 07/11/2014 21:55:52

athtest800



Joined: 06/11/2014 01:24:40
Messages: 4
Offline

Thanks for the responses.
Forgive me for any errors i make as long as i am new to arduino.

When your LCD is using the SPI port, it can get interrupted by the radio's ISR


At the time of the experiments, i get strange white pixel dots only when i use "if (radio.receiveDone())".
Firstly i fill the screen with black "tft.fillScreen(ST7735_BLACK);" and then i add a delay(5000). But when radio.receiveDone executes first in loop(), the only function in loop, i get white pixels on top-left of lcd. So i think interrupt has no rule for now because i have finished writing to LCD (am i correct?).

Looking in the libraries i see that RF69 unselects SPI. The LCD (*csport |= cspinmask; ) does the same thing after writing to SPI.


The strange i discovered is that when i set LCD pin slave select to HIGH the lcd still responds to commands.

ex. in fillRectangle




Sorry again if i cannot explain it so to understand it.
athtest800



Joined: 06/11/2014 01:24:40
Messages: 4
Offline

I would also like to comment, after trial and error, that the problems starts with the "receiveBegin" of RFM69 Library. After commenting some code i think that "setMode" is the function that gives me trouble.


And more accurate the below inside "setMode":



My knowledge stops here. I cannot go ahead.
Is there any suggestion?

Thank you
 
Forum Index » Anarduino
Go to:   
Powered by JForum 2.1.9 © JForum Team