EmbDev.net

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


Author: Aditya K. (stadkama)
Posted on:

Rate this post
0 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.

Author: Chriss (Guest)
Posted on:

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

OR

-Daisy Chain Slaves

Author: Aditya K. (stadkama)
Posted on:

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

Author: Aditya K. (stadkama)
Posted on:

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

Author: doppelschwarz (Guest)
Posted on:

Rate this post
0 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.

Author: Lothar Miller (lkmiller) (Moderator)
Posted on:

Rate this post
0 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...

Author: Aditya K. (stadkama)
Posted on:

Rate this post
0 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
Author: karl heinz (Guest)
Posted on:

Rate this post
0 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.

Author: Aditya K. (stadkama)
Posted on:

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

Reply

Entering an e-mail address is optional. If you want to receive reply notifications by e-mail, please log in.

Rules — please read before posting

  • Post long source code as attachment, not in the text
  • Posting advertisements is forbidden.

Formatting options

  • [c]C code[/c]
  • [avrasm]AVR assembler code[/avrasm]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]




Bild automatisch verkleinern, falls nötig
Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.