cancel
Showing results for 
Search instead for 
Did you mean: 

Communication between 2 STM32 via SPI

rndeli
Associate II
Posted on March 26, 2010 at 07:33

Communication between 2 STM32 via SPI

7 REPLIES 7
jpeacock23
Associate III
Posted on May 17, 2011 at 13:44

Remember that SPI is not like a full duplex asynchronous UART.  The slave (B) device doesn't have an independent data clock for its transmitter.  In order for the (B) STM32 to send data the master (A) device must send dummy data to generate the data clocks to shift bits out of the SPI buffer on (B).

The alternative is that (A) and (B) use some kind of protocol to reverse roles, where the (B) STM32 reconfigures for master and (A) as slave, expecting data from (B).

  Jack Peacock

rndeli
Associate II
Posted on May 17, 2011 at 13:44

Thanks for reply,

                 I had allready try to send data from slave to master while master sending data. But in this case only slave can receive data from master but master can't receive data from slave. And whatever data slave receive from master is save in Address + 1. so, data not save in proper lacation.

    I had also try to send and receive data using DMA.I had configure SPI on DMA. But in this case also same problem.

Can anyone help me what to write in Master and what to write in slave for data Exchanging between 2 Controllers(STM32F103)?

Andrew Neil
Evangelist III
Posted on May 17, 2011 at 13:44

Alternatively, the slave can use the clock while it's receiving to be transmitting at the same time...

Andrew Neil
Evangelist III
Posted on May 17, 2011 at 13:44

I think you are trying to do too many things all at once here!

I suggest that you start by just getting an SPI master working and talking to some standard SPI slave chip.

Once you know that you have a working master, then move on to making the slave.

What test equipment do you have?

You really need a storage oscilloscope at the very least.

Some 'scopes & logic analysers have built-in SPI decoding.

Or get a specific SPI analyser; eg: 

http://www.totalphase.com/products/beagle_ism/

rndeli
Associate II
Posted on May 17, 2011 at 13:44

No i am not doing much thing at a time.

I am just sending a array of 20 bytes from master to slave and want to receive 20 bytes from slave.I am receiving 20 bytes from master to slave but i can't receive bytes from slave to master.I had also check the Waveform on Oscilloscope it shows data flow towards slave from master but i can't see data flow from slave to master.

I don't know how data can be send to Slave.

I had check SPI as a master with ADC,DAC and EEPROM it is working OK.

rndeli
Associate II
Posted on May 17, 2011 at 13:44

Hello 

    I had solved problem. Now, i can read and write from/to master/slave. But now one probelm occure during reading slave. Data from slave not comes continously. It receive data for 1 cycle and for next 4-5 cycles it sends 0's.

Please tell me the solution.

I am doing this by making one pin Low in master and this low pin, interrupt slave and slave starts sending and receiving data.

From: panchal.jayesh

Posted: Saturday, March 27, 2010 12:09 PM

Subject: Communication between 2 STM32 via SPI

No i am not doing much thing at a time.

I am just sending a array of 20 bytes from master to slave and want to receive 20 bytes from slave.I am receiving 20 bytes from master to slave but i can't receive bytes from slave to master.I had also check the Waveform on Oscilloscope it shows data flow towards slave from master but i can't see data flow from slave to master.

I don't know how data can be send to Slave.

I had check SPI as a master with ADC,DAC and EEPROM it is working OK.

rndeli
Associate II
Posted on May 17, 2011 at 13:44