cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F0 CubeMx SPI HAL Driver Initial Pin Level

DAkka
Associate

Hi there,

I created a project with STM32F042G6 chip using CubeMX. I am interfacing this IC to another chip using SPI. When I set the SPI1 and try to send a command, just before sending a command I have SCLK, MOSI, and MISO levels are high. After sending byte/bytes these pins stays low. After sending the first transmission IC that I am interfacing can understand all the data I sent. However, this initial high state creates a confusion on the IC I am interfacing.

Is there a way to set the SCLK and MISO Pin levels right after initilize the SPI Hal driver?

Note that I don't want to push dummy byte to SPI bus. I would like to configure it in the way that once SPI is configured

SCLK: Low

MOSI: Low

MISO: Low

Thank you so much!

Deniz

2 REPLIES 2
Pavel A.
Evangelist III

You're forgetting about the Chip Select output to the other chip. Until this is set to active state, the other chip should not react to MOSI and CLK lines.

TDK
Guru

Assuming the STM32 is the master:

MISO isn't controlled by the STM32.

SCLK can be set to its idle level by enabling the peripheral.

__HAL_SPI_ENABLE(&hspi1);

You can't control MOSI directly.

If you feel a post has answered your question, please click "Accept as Solution".