2021-06-01 05:09 PM
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
2021-06-01 05:52 PM
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.
2021-06-01 06:42 PM
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.