EmbDev.net

Forum: µC & Digital Electronics Single Master-Multiple slaves implementation of SPI


von Aditya K. (stadkama)


Rate this post
useful
not useful
Hello,

Im trying to implement single master(atsam4e8c) and multiple 
slave(sensors-all are same) Spi. I have few questions regarding this.
I have initialized the master in my code. I took reference of 
initializing master in of the forums here.

1.However,Do I need to initialize the sensors(slaves) in my code?
2.How do I call 6 slaves one by one in the code?
Thank you for your inputs. Please let me know for any information do I 
need to provide.

von Chriss (Guest)


Rate this post
useful
not useful
-CS (Chip Select) signals

OR

-Daisy Chain Slaves

von Aditya K. (stadkama)


Rate this post
useful
not useful
Hello Chriss
 It is based on chip select signals.

von Aditya K. (stadkama)


Rate this post
useful
not useful
I have seen the post from Jörg Wunsch regarding this. However I have few 
questions.

von doppelschwarz (Guest)


Rate this post
useful
not useful
The slaves are all on the same MOSI line, but they listen only if their 
SS is low. So you have to set the SS_Slave0 pin low and send the data, 
read on MISO_Slave1 (or MISO if it is only one line). Then start slave1 
and so on.
Initializing slaves is normally done by sending some messages to them, I 
think displays work this way (send settings first, then data to show). 
If your sensor needs it is shown in its datasheet. Don't mix it with SPI 
slave initiliazing of your controller.

von Lothar M. (Company: Titel) (lkmiller) (Moderator)


Rate this post
useful
not useful
Aditya K. wrote:
> 2.How do I call 6 slaves one by one in the code?
You can't.
SPI simply are 2 concatenated shift registers: one in the master and one 
in the slave. So you cannot select 6 slaves at the same time. You must 
select one after the other.
Or you must connect them in a daisy chain (if the sensors are able to 
handle that).

> multiple slave(sensors-all are same)
Which ones? Type? Datasheet?

> Do I need to initialize the sensors(slaves) in my code?
That information can be found in the sensors datasheet only...

von Aditya K. (stadkama)


Rate this post
useful
not useful
those are inertial sensors.I need to read the values from those 
sensors.If i need to initialize all the 6 sensors, is it to be done when 
I select the particular chip select?

: Edited by User
von karl heinz (Guest)


Rate this post
useful
not useful
As a guideline:
to communicate with one of the sensors you need to pull the chip select 
wire for that sensor low. Otherwise the sensor will ignore everything 
happening one the MOSI Line.

If you need to give some initialiszation to the sensor can be found in 
the datasheet of that sensor. There is no difference between one sensor 
and a bunch of them. Each sensor ignores the SPI bus unless its Chip 
Select Input is pulled low.

You need to differntiate between the communication on a technical level 
(the SPI bus) and what needs to be sent on that bus. The former is a 
technical thing how the SPI bus works in principle. The later is 
dependend on the client and can be found in its datasheet.

von Aditya K. (stadkama)


Rate this post
useful
not useful
>> multiple slave(sensors-all are same)
> Which ones? Type? Datasheet?
bmi160 inertial sensors

Please log in before posting. Registration is free and takes only a minute.
Existing account
Do you have a Google/GoogleMail account? No registration required!
Log in with Google account
No account? Register here.