cancel
Showing results for 
Search instead for 
Did you mean: 

SPI-SPI

jki79ros81
Associate II
Posted on January 20, 2009 at 11:30

SPI-SPI

6 REPLIES 6
jki79ros81
Associate II
Posted on May 17, 2011 at 13:00

Hi, everyone!

I am working with communication between two stm32 SPIs.( A-SPI1 <-> B-SPI2).

The A send a command to the B , the B process the command then send response to the A.

Communication is asynchronous.

The A send a command-1 and coninuously can send cancel command for command-1.

I think that this is impossible by using fullduflex mode.

My hardware configuration.

- Connect A-SPI1 SCK pin (PA.05) to B-SPI2 SCK pin (PB.13)

- Connect A-SPI1 MISO pin (PA.06) to B-SPI2 MISO pin (PB.14)

- Connect A-SPI1 MOSI pin (PA.07) to B-SPI2 MOSI pin (PB.15)

For this how must I do?

Thank for you help and advice.

jj
Associate II
Posted on May 17, 2011 at 13:00

Hi back-

Assume that you really want to ''talk'' between 2 STM32s - not 2 SPI ports on the same uC. SPI by its nature is full-duplex - the SPI clock tranfers both Send & Receive Data - at the same time. (but perhaps not on the same clock edge)

Appears that your master SPI is ''A'' - with ''B'' its slave. Your connection looked ''reversed'' to me - but now I believe that you've got it right.

Keep in mind that as you ''clock'' a command out to the slave the slave is returning ''previous'' data to you. (via MISO) This implies that your slave will always be one ''tranfer'' behind the master - with its response.

Due to the high speed of STM32's SPI - I believe that you will find the ''command processing'' and 1 transfer delayed ''response'' - adequate for most applications.

jj
Associate II
Posted on May 17, 2011 at 13:00

A ''master'' can receive a response from a ''slave'' without becoming a slave, itself. As proof - think of your STM32 ''master'' talking to an SPI memory ''slave.'' Clearly - the STM32 is in charge - is generating all of the clocks - and can receive data from its slave.

Your processing time within the STM32 designated as ''slave'' depends upon complexity and size of your data stream. I would suspect that you could accomplish your processing much faster than the time you state - just keep in mind that each ''slave'' response is one data transfer ''behind'' the ''master's'' issued command.

jki79ros81
Associate II
Posted on May 17, 2011 at 13:00

Hi, jj.sprague!

Thank you very much.

There is following satuation.

A-SPI(Master) send to B_SPI(Slave).

After the B process , the A must be slave to receive response?

And if time for processing commnad1 is about 5s, how must?

Thank you for your help.

jki79ros81
Associate II
Posted on May 17, 2011 at 13:00

Thank you, jj.

I work with fingerprint sensor. Timeout that user sweep finger is 5s.

Only when master generate clock, slave can receive response.

Then after master send command, it must generate clock to receive until response come?

Thank you.

jj
Associate II
Posted on May 17, 2011 at 13:00

Be careful - earlier you described STM32''A'' (the master) exchanging with STM32''B'' (the slave) via 4 wire SPI. Now we learn of fingerprint sensor - unclear now is the function of STM32''B.'' ''B'' either ''talks/exchanges'' with your fingerprint sensor (believe most of these use USB) OR STM32''B'' is ''within'' the fingerprint sensor.

Here's the ''gotcha/trick'' - believe the fingerprint sensor to always be a slave. So STM32''B'' (if it is NOT part of fingerprint sensor) must serve as ''both'' Master (to talk to sensor) and as Slave - to exchange with STM32''A''.

Separate from the above - you CAN eliminate the ''one transfer cycle'' delay in response between STM32''A'' and STM32''B.'' You achieve this by enabling the ''B'' to continuously ''challenge->read'' for a fingerprint. STM32''B'' then will (most of the time) have the current ''recognized fingerprint'' data READY - simply awaiting the master's clock.