cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F4 SPI-DMA data is shifted

gcntrk
Associate II
Posted on December 11, 2013 at 08:19

The original post was too long to process during our migration. Please click on the attachment to read the original post.
6 REPLIES 6
frankmeyer9
Associate II
Posted on December 11, 2013 at 10:50

Unlike I2C or RS232, SPI is not a 'fixed' protocol. There exist several variants that differ especially on clock polarity and trigger edge (i.e. the clock edge that triggers the read/write of data on MISO/MOSI).

Check the requirements of your undisclosed slave, and compare with the settings of the MCU (which is presumably the master). I guess there is a mismatch.

gcntrk
Associate II
Posted on December 11, 2013 at 16:10

I've tried all possible combinations of clock polarity and trigger edge, that is right it can save 1 bit, but not another. What I mean is that combinations provide me 1 bit shift best, and two bits worst. I cannot save one bit with changing that combinations.

santa
Associate
Posted on May 05, 2014 at 11:23

Hi Canturk,

Some months have passed since your last post, but now I have a similar problem with a STM32F103. If I use SPI1 without DMA, everything is ok, but when I enable DMA, I receive the same data shifted right by one bit. Did you find any solution?

Thanks.
Posted on May 05, 2014 at 12:32

From RM0008, ch.25.3.2:

Note:

 

It is recommended to enable the SPI slave before the master sends the clock. If not,

 

undesired data transmission might occur. The data register of the slave needs to be ready

 

before the first edge of the communication clock or before the end of the ongoing

 

communication. It is mandatory to have the polarity of the communication clock set to the

 

steady state value before the slave and the master are enabled.

 

JW
santa
Associate
Posted on May 05, 2014 at 14:22

Jan, thanks for your response. Unfortunately, the note refers to SPI in slave mode, and my STM32 is the master. The slave is a TI ADS7843 resistive touch controler, its nCS signal is grounded in this prototype, and NSS is managed by software.

By the way, I have read the controler datasheet, and I have taken into account the protocol used, it works flawless without DMA.

Thanks.

Posted on May 05, 2014 at 14:57

Then, as the original poster had problems with SPI in slave mode, start a new thread, post a minimal but complete compilable code exhibiting the problem, a description of the relevant portions of hardware, and post what are your findings and how do they fall short of your expectations.

JW