2014-06-02 01:34 AM
2014-06-02 01:52 AM
> I have 2 stm32f4 discovery boards connected as per instructions in readme file inside example folder
Namely? JW2014-06-02 03:13 AM
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_DataExchangeDMAthanks.2014-06-02 03:26 AM
OK, so, how did you connect those two boards?
JW2014-06-02 04:08 AM
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.2014-06-02 05:55 AM
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) JW2014-06-02 07:39 AM
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;toSPI_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.FdC2014-06-02 10:07 AM
> 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). JW2014-06-02 10:16 AM
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