Loop() not Executing on Photon with multiple SPI devices


#1

I have added the NCD Ethernet shield to a Photon (I realize that it does not permit access to the cloud). I know it is working because the Photon does access my server.

However, the loop() routine now is not executing. I read that according to @rickkas7, to prevent this, one needs to put the Photon in Manual Mode.

My Photon is in manual mode. I know because it is flashing white and I also cannot reach it through the cloud.

I am sure the loop is not executing because my LCD should display a variable in the loop().

What is causing that? I would appreciate the community’s input.


Ethernet FeatherWing with Xenon - Serial 2
#2

I have an SD card in addition to the Ethernet shield.

I noticed that:

  1. If I start the SD card first, and the Ethernet next, both start but loop() does not run.

  2. If I start the Ethernet shield first, the SD card will not run with SPI_FULL_SPEED, or SPI_HALF_SPEED

  3. If I start the Ethernet shield first, the SD card will run with SPI_QUARTER_SPEED but then the loop() never starts.

I would appreciate the community’s help with this issue as I need to have both an SD card and Ethernet. I am considering switching to Xenons but it is not practical at the moment as I have a custom board.


Photon to Ethernet Device Server?
#3

That’s no proof. There are other possible causes to that :wink:

That’s also not a proof again. Your loop() may be misbehaving or you got some blocking code during STARTUP() and/or setup().

No code to look at means not much more to say :wink:


#4

@Jimmie Without code share and from what you have described as @ScruffR has said it is not easy to help.
I would suggest you confirm/try/investigate the following:

  1. Use or confirm you are using the latest SDfat library?
  2. Confirm which Device OS you have on the Photon?
  3. Confirm if your LCD display is running on SPI and how this is initiated?
  4. Look at the Ethernet shield driver software and see what speed it is running the SPI and how this is initiated?

I would guess that there is an error condition with one of the device drivers which ends with while(1);

It would appear that you are running 3 SPI bus devices? off the Photon. They may need to be setup in a specific sequence due to the controller ICs’ restart timing requirements and they will surely all need to be using the SPI bus at the same speed and settings SPI.beginTransmission() and you are not calling SPI.begin() multiple times with incompatible settings and/or SS pins. I remember that initially getting an SD card reader and TFT working together took a bit of time. Personally, I skipped using the Ethernet shield with the Photon for the reason it cannot communicate with the Particle Cloud and have picked up the Xenon with the Ethernet FeatherWing which works out of the box and reliably.


#5

Thank you @Scruffr. I will share the code.


#6

Thank you @armor. My LCD is i2C so I am only using 2 SPI devices, the Ethernet Overlay and the Sd card reader.

In my case, the Ethernet Overlay uses the standard SPI connections. The SD card in my case is using

SPI_CONFIGURATION 1
SCK => D4, MISO => D3, MOSI => D2, SS => D5

===============================
If it looks like the Ethernet FeatherWing is the way to go. I was wondering if you have it working with an SD card and what the SD settings are? I am asking because I will need to build a board that has other stuff on it.

Thanks again.


#7

Which SD card library are you using and why do you need to use SPI1 - the Slave Select (SS) Pin allows you to share the bus? I guess using hardware SPI and software SPI might be the cause of the problem.

I have an Adafruit data logger featherwing but had not yet tried it out so I can’t report, in fact, I am not sure how it communicates with the Xenon?


#8

Thank you @armor. I am planning to use SDFat but have no preference as long as it works …

Do SPI devices have to have their own SS? Do they all have to have the same speed?


#9

Thank you @ScruffR.

While I am still having the same problems with the SD card, indeed the loop was blocked by waiting for a sensor.