Loading...
 
Skip to main content

System Workbench for STM32


SPI on Nucleo_STMH533RE

Hello, I am unfortunately a beginner in terms of Zephyr, installation compiling works, all no problem, but now I just wanted to configure the SPI as master. Here I break my neck.

I have already looked at many examples, but either the device tree can no longer be compiled or the SPI ends with an error.

Does anyone have a tip for me? Surely a piece of cake for an experienced user?

How do I create a devicetree where I can configure the pins for CS, MOSI, MISO and Clock?

Hi, you should first familiarize yourself with the devicetree concept and the Kconfig configuration system in Zephyr.
I recommend this video to understand how they work: Configure Zephyr: Kconfigs and Devicetree in Simple Words
For configuring SPI and other peripherals, start by reviewing the Zephyr SPI documentation, then explore existing examples.
For your specific board, check the generated build/primary/zephyr/zephyr.dts file to see the current configuration. In your application, create an overlay file (e.g., app.overlay) to reconfigure settings.
For example (theoretical):
&spi1 {
pinctrl-0 = < &spi1_sck_pa5 &spi1_miso_pa6 &spi1_mosi_pa7>;
pinctrl-names = "default";
cs-gpios = < &gpiob 0 GPIO_ACTIVE_LOW>;
status = "okay";
};
For more details, check existing Zephyr samples


I have just seen your reply, did you manage to find a way to set it up ? the error you are getting means that you need to give pinmux property in the pins you are setting to pinctrl-0, because it is set as required in the binding you also have an example in this file
You need to set it up like this for example:

Copy to clipboard
pinmux = < STM32_PINMUX('F', 7, ANALOG) >, /* SPI5_SCK */ < STM32_PINMUX('F', 8, ANALOG) >, /* SPI5_MISO */ < STM32_PINMUX('F', 9, ANALOG) >, /* SPI5_MOSI */ < STM32_PINMUX('F', 6, ANALOG) >; /* SPI5_NSS */