cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F401 Nucleo SPI Clock problem, using STM32CubeF4

ishmeetsinghis
Associate II
Posted on July 02, 2014 at 06:16

I am using SPI1 with HAL low level drivers, STM32CubeF4.

I have used the following SPI configuration:-

    

SPI_HandleTypeDef hspi;

hspi.Instance=SPI1;

hspi.Init.Mode=SPI_MODE_MASTER;

hspi.Init.Direction=SPI_DIRECTION_2LINES;

hspi.Init.DataSize=SPI_DATASIZE_8BIT;

hspi.Init.CLKPolarity=SPI_POLARITY_HIGH;

hspi.Init.CLKPhase=SPI_PHASE_1EDGE;

hspi.Init.NSS=SPI_NSS_SOFT;

hspi.Init.BaudRatePrescaler=SPI_BAUDRATEPRESCALER_256;

hspi.Init.FirstBit=SPI_FIRSTBIT_MSB;

hspi.Init.TIMode=SPI_TIMODE_ENABLED;

hspi.Init.CRCCalculation=SPI_CRCCALCULATION_DISABLED;

hspi.Init.CRCPolynomial=0;

HAL_SPI_Init(&hspi);

After sending some bytes on MOSI. On logic analyzer, I see clock and MOSI data are mismatched. 

This is a very zoomed in pic, If required I can send the whole logic analyzer file.

0690X00000605f8QAA.png

If any more code is required, let me know I'll send it. 

For read and write, I am using 

HAL_spi_transmit(&hspi, Byte, 1, 5);

HAL_spi_Receive(&hspi, Byte, 1, 5);

I did the almost same spi configuration with stm32l151rct6a, using std periph library and it is working. 

Question: Why is the clock not synchronised with MOSI. 

1 REPLY 1
Posted on September 11, 2014 at 16:20

Hi singh.ishmeet,

Can you provide the HAL_SPI_MspInit() API and the snapshot of the first SPI transmitted byte ?  That would help more easily figure out where a problem could be.

In fact, what we see on  the logic analyzer is just the SPI GPIO configuration, and not “the clock not synchronized with MOSIâ€�, this is just the SLK I/O already configured before the MOSI I/O (the clock for data is not yet generated on SLK I/O).

Regards.