cancel
Showing results for 
Search instead for 
Did you mean: 

SPI communication between two STM32 Discovery

edxxgardo
Associate II
Posted on March 31, 2011 at 11:13

SPI communication between two STM32 Discovery

5 REPLIES 5
Posted on May 17, 2011 at 14:30

''I connected the Master GPIO pins 5,6,7 to the Slave GPIO 13,14,15''

 

Pin numbers are pretty meaningless  - what are the pin functions?

''Master seems to work because I can monitor it via the interrupt''

You haven't shown your interrupt handler, so it's impossible to know if that's a valid or meaningful test.

Anyhow, it tells you nothing about what's actually happening on the physical connection betwen the two boards.

Have you looked with an oscilloscope?

A complex system that works is invariably found to have evolved from a simple system that worked.
A complex system designed from scratch never works and cannot be patched up to make it work.
edxxgardo
Associate II
Posted on May 17, 2011 at 14:30

PA 5(SCK),6 (MISO),7(MOSI) from Master side

PB 13(SCK),14(MISO),15(MOSI) from Slave side.

You are right ...using the osciloscope is a good way to test it. I mentioned that apparently from the Master it works, but what works is just the triggering of the interrupt and the sending out the bytes. There is a buffer with a bunch of bytes and one by one are collected by the IRQ and I see it from the debugger:

void Slave_Buffer(void)

{

    /* Store SPI_SLAVE received data */

    Slave_Buffer[buffer_Index++] = SPI_I2S_ReceiveData(SPI_SLAVE);

}

this function is called from the IRQ in the Slave.

I'm going to check using the osciloscope, but in the mean time I wanted to know from somebody in the forum wether there is something wrong in the code. There are so many parameters in the setting that, even if I used the osciloscope, I can spend hours in trying one by one these parameters, then recompile, download, ecc.

Thanks anyway for the supprot,

regards,

Posted on May 17, 2011 at 14:30

With two separate devices both could use SPI1?

It's never made a whole lot of sense to me to have ALL the pins as AF_PP, but all the examples look that way.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on May 17, 2011 at 14:30

''PA 5(SCK),6 (MISO),7(MOSI) from Master side

 

PB 13(SCK),14(MISO),15(MOSI) from Slave side''

But how are they connected? What connects to what?

You're not using a Slave Select line...?

A complex system that works is invariably found to have evolved from a simple system that worked.
A complex system designed from scratch never works and cannot be patched up to make it work.
Posted on May 17, 2011 at 14:30

But how are they connected? What connects to what?

Probably one-to-one, which should work for full duplex modes, but the 1 line Tx/Rx modes it documented as :

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

 - Connect SPI2 MISO pin (PB.14) to SPI1 MOSI pin (PA.07)

When cut-n-pasting example code, it always helps to read the README.TXT file.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..