2013-12-10 11:19 PM
2013-12-11 01:50 AM
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.2013-12-11 07:10 AM
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.
2014-05-05 02:23 AM
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.2014-05-05 03:32 AM
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
2014-05-05 05:22 AM
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.2014-05-05 05:57 AM
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