cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F042F6 SPI1 clock polarity problem

pawelgradd
Associate
Posted on November 14, 2016 at 08:53

Hello,

On my currently developing device and I issued a problem. I'm using CubeMX 4.17, F0 package 1.6 and F4 package 1.13.1.

I developed the code for F4 - SPI1 communicating with NRF24L01+ module using HAL library and DMA and everything works. Then I created new project for F0 and ported some code from F4. I notice an issue. On first SPI transaction HAL_SPI_TransmitReceive_DMA() clock is HIGH when IDLE (CPOL is set to LOW). I tried changing CPOL to HIGH but situation is the same. Following transactions are OK.

First transaction:

http://i.imgur.com/nQJ3hTx.png

Second:

http://i.imgur.com/95UEBs8.png

SPI configuration:

http://i.imgur.com/yEPiFJZ.png

http://i.imgur.com/U8m4rXS.png

So I'm making first dummy transaction and then I'm palying with SPI the way I want. Do you know where the proble might be?

#!f0-!spi
2 REPLIES 2
Walid FTITI_O
Senior II
Posted on December 08, 2016 at 14:52

Hi 

It could be that the F0 SPI driver that you are using is a kind old and/ or the function '

HAL_SPI_TransmitReceive_DMA()' 

there is not the same as the one in F4 driver. You can open both F4 and F0 driver and compare the

HAL_SPI_TransmitReceive_DMA() 

function . Ensure to use the last versions.

-Walid F-

Seb
ST Employee
Posted on December 10, 2016 at 18:13

Could you try to write 0xFF on the SPI DR after the clock of the peripheral is enabled and before the SPI is enabled? So that the DR is not starting with a default value of 0x00?