What will the slave store at every clock signal? Answered

Thread Starter

John99407

Joined Jul 12, 2019
59
I have a doubt that I can't clear as shown in photoshop picture ADC reads the data from the sensor and sends it to the microcontroller. As can see, the data that the ADC sends to the master gets the same data back. Here master means any microcontroller and slave means ADC that work on SPI protocol. If this happens, how microcontroller read variable value of sensor


1580644135390.png

Can anyone help me to understand communication between three devices ?
 

Papabravo

Joined Feb 24, 2006
14,420
You need to dig deeper into the actual ADC part. The data going to the ADC can be either a "request" or can be a don't care. The data coming back can be actual data, or status, or a don't care depending on the context of what is going on. You have to read the datasheet very carefully.

Clock signals do not occur in isolation, they occur in groups of 8. It takes 8 clock signals to transfer one byte of data.
 

OBW0549

Joined Mar 2, 2015
3,551
Can anyone help me to understand communication between three devices ?
In your diagram the signals MISO, MOSI and SCLK are shown flowing in the wrong direction. MISO is an input to the master; MOSI is an output from the master; and SCLK is supplied by the master.
 

JohnInTX

Joined Jun 26, 2012
4,283
Adding to the excellent advice above:

First you should separate the SPI function from the ADC function. SPI communicates. ADC converts analog into digital. Those are separate and different functions. SPI can communicate with many different kinds of devices. Not all ADCs are SPI.

Next, study SPI until you completely understand how it works and how to use it to send and receive bytes of data to any slave, not just an ADC. Know the difference between bit-banging and using an SPI peripheral in the microcontroller and how to do your particular implementation.

Then, study the particular ADC you are using. Just saying it has an SPI interface is not enough. Some ADCs are simple, others have extensive setup requirements that require that you write data to several registers to configure it. Reading the converted data can be as simple as dropping CE/ and clocking the data in. Other ADCs require a command to be written to read the converted data.

Once you know how to read and write any data with SPI, AND also know what data required to operate the ADC, how to do it should become obvious.

Good Luck!
 

Thread Starter

John99407

Joined Jul 12, 2019
59
In your diagram the signals MISO, MOSI and SCLK are shown flowing in the wrong direction. MISO is an input to the master; MOSI is an output from the master; and SCLK is supplied by the master.
You are totally right. I made a mistake drawing. I am correcting my mistake

1580661050397.png
 

Thread Starter

John99407

Joined Jul 12, 2019
59
You have to read the datasheet very carefully.
I searched 8 bit ADC SPI on google. I am sharing the link of the first result http://www.ti.com/lit/ds/symlink/adc081s021.pdf I got here google.

ADC will read sensor output data and microcontroller will read ADC output data, according to the SPI, the data that is sent to the microcontroller same data will return to ADC back . This has become a big question for me
 

Papabravo

Joined Feb 24, 2006
14,420
The way it works is that the Master and the device exchange the contents of their respective registers. The registers are never empty, they always contain something. The register contents ONLY change when data is NOT being exchanged. Got it?
 
Top