cancel
Showing results for 
Search instead for 
Did you mean: 

stm32f4 discovery board spi dma example

felipe2
Associate III
Posted on June 02, 2014 at 10:34

 

 

The original post was too long to process during our migration. Please click on the attachment to read the original post.
8 REPLIES 8
Posted on June 02, 2014 at 10:52

> I have 2 stm32f4 discovery boards connected as per instructions in readme file inside example folder

Namely?

JW

felipe2
Associate III
Posted on June 02, 2014 at 12:13

Hi,

I'm not sure what you asked exactly but if it is regarding the example it is from:

stm32f4_dsp_stdperiph_lib\STM32F4xx_StdPeriph_Examples\SPI\SPI_TwoBoards\SPI_DataExchangeDMA

thanks.

Posted on June 02, 2014 at 12:26

OK, so, how did you connect those two boards?

JW
felipe2
Associate III
Posted on June 02, 2014 at 13:08

the readme file says to connect both board as:

GND-GND;

PA5(clk)-PA5(clk);

PA6(MISO)-PA6(MISO);

PA7(MOSI)-PA7(MOSI);

 

but I also tried:

GND-GND; 

PA5(clk)-PA5(clk);

PA6(MISO)-PA7(MOSI);

PA7(MOSI)-PA6(MISO);

either way it didn't work.

I'm aware that these examples are sort of guidelines only but I can't see any problems with the example or why it wouldn't work.

Could it be that it is not working properly because it is not using a chip select line?

Btw, spi data exchange using interrupt also didn't work but I'm still debugging it further to figure out why.

thanks.

Posted on June 02, 2014 at 14:55

Well, my copy of  STM32F4xx_DSP_StdPeriph_Lib_V1.3.0\Project\STM32F4xx_StdPeriph_Examples\SPI\SPI_TwoBoards\SPI_DataExchangeDMA\readme.txt says something different:

    - Connect BoardA SPI2 SCK pin  (PI.01) to BoardB SPI2 SCK pin  (PI.01)

    - Connect BoardA SPI2 MOSI pin (PI.03) to BoardB SPI2 MOSI pin (PI.03)

    - Connect BoardA SPI2 MISO pin (PI.02) to BoardB SPI2 MOSI pin (PI.02)

JW

felipe2
Associate III
Posted on June 02, 2014 at 16:39

Hi,

Apologies for not being so clear on my issue but I did mention that I changed the code so that it uses SPI1 (not 2) on port A.

Anyways, I found out that changing 

SPI_InitStructure.SPI_CPHA = SPI_CPHA_1Edge;

to

SPI_InitStructure.SPI_CPHA = SPI_CPHA_2Edge;

makes things work.

looking at the memory registers with the data values received and comparing with what should have been received I noticed that the values were shifted by 1bit so I decided to change the edge in which data is sampled.

I hope this can be of help for others and thanks for all the help.

FdC

Posted on June 02, 2014 at 19:07

> Apologies for not being so clear on my issue but I did mention that I changed the code so that it uses SPI1 (not 2) on port A.

You *did* mention it in your initial post.

What I wanted to point out was that you used a different board than the one for which the software was written,  thus you might have made error in the ''conversion'' process. But one error you probably still did not remove is that on the DISCOVERY board, the pins you used are connected to the on-board accelerometer, which pulls them up.

So, I believe the root of the problem still persists and that you succeeded is just some coincidence. I see no reason why wouldn't the example work with both CPHA settings (of course the two boards have to use the same setting).

JW

Posted on June 02, 2014 at 19:16

The ''Cube'' example is for 2 discovery boards (and those, who paid $$$ for the EVAL board are left with cold feet in ''Cube'', as far as SPI examples go, btw.), and it says:

/* Definition for SPIx Pins */

#define SPIx_SCK_PIN                     GPIO_PIN_13

#define SPIx_SCK_GPIO_PORT               GPIOB

#define SPIx_SCK_AF                      GPIO_AF5_SPI2

#define SPIx_MISO_PIN                    GPIO_PIN_14

#define SPIx_MISO_GPIO_PORT              GPIOB

#define SPIx_MISO_AF                     GPIO_AF5_SPI2

#define SPIx_MOSI_PIN                    GPIO_PIN_15

#define SPIx_MOSI_GPIO_PORT              GPIOB

#define SPIx_MOSI_AF                     GPIO_AF5_SPI2

If I understand properly the ''Cube'' goobledygook, it uses CPHA=0 (''1edge'') and, interestingly, CPOL=1... (but it really should not matter).

JW