Ethernet share SPI

Status
Not open for further replies.

muggins

Well-known member
Can someone please guide me. I have a Wiznet module attached to the teensy using SPI. It uses pin 10 as CS. I want to also use SPI for a rotary encoder using CS on pin 5. My question is, does the ethernet continuously hold it's CS low so as to monitor traffic and if so how do I get to use SPI for the encoder. Sorry for my inexperience.
John
 
The Ethernet library already uses SPI transactions. No need to dig into its code. Same for SD and many (but not all) others.
 
I'm really out of my depth here not understanding how SPI transactions work. The other library that I want to use is:
https://github.com/ZoetropeLabs/AS5048A-Arduino/blob/master/lib/AS5048A/AS5048A.cpp

It is for a rotational magnetic encoder and uses SPI. I notice in the coding that it seems to also use transactions.
Could some kind person give me some guidance on how to get this device and the network adapter to co-exist using transactions.
thanks
John
 
That library is also using transactions. These 2 really should work together.

Maybe you're doing something else wrong? Perhaps show us how you've actually connected everything (photos) and a complete program which demonstrates the problem?
 
This lib uses transactions, too... seen after 3.4 seconds when scrolling through the code..:D

Edit: oops, Paul was faster. Sry.
 
I have to say I haven't tried them together as I had never heard of transactional "sharing" until now and assumed that network communication needed to be "always on"
I will breadboard it up and try running both together now.
John
 
Ah, maybe what happened here is the case of asking a narrowly focused technical question without context to understand where you're at and what you really need, and then the complex technical answers are correct on a technical level, but not at all addressing what you really needed to know?

I believe we all saw your message and assumed you were already using these libs and having trouble. But now it looks like this was really asking "how do I wire things up" before even getting started... which is a perfectly valid question. That part wasn't clear (at least to me) and the question seemed to be about technical matters, so deeply technical answers came forth. ;)

Really, what you need to know is with these 2 libs, you just wire up the MOSI, MISO and SCK lines pins 11, 12, 13. Those 3 are shared. Each chip's CS goes to a separate pin. These libraries are designed to work together when you connect the hardware this way. So are almost all other libs using SPI.
 
Thank you Paul for that and yes maybe my query wasn't comprehensive enough. Before hearing of transactions I assumed that in programming you had to "release" one CS before selecting another. Because Ethernet is in constant use I didn't think it possible.
 
... had to "release" one CS before selecting another.

Both these libraries and virtually all others do that automatically. Other much more difficult to understand problems are also automatically taken care of by the SPI transaction functions, which both these libraries and most (but not all) others are already designed to use.

Those of us who develop these libraries and the SPI libraries they in turn use have put a lot of work over the years into compatibility. :)
 
Status
Not open for further replies.
Back
Top