Skip to main content
DAkka
Visitor II
June 2, 2021
Question

STM32F0 CubeMx SPI HAL Driver Initial Pin Level

  • June 2, 2021
  • 2 replies
  • 723 views

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

This topic has been closed for replies.

2 replies

Pavel A.
June 2, 2021

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
June 2, 2021

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""."