How To Write An STM32 SPI Driver (Full-Duplex Master Mode)

Поділитися
Вставка
  • Опубліковано 27 лип 2024
  • This tutorial demonstrates how to write a full-duplex SPI driver for an STM32 microcontroller without any hardware abstraction layers (bare metal) to communicate over the Serial Peripheral Interface (SPI) with other SPI devices with the microcontroller being the master on the bus. The tutorial covers the necessary SPI theory, STM32 SPI registers required and includes a coded example developed throughout the tutorial. After the code is fully developed, the SPI driver is tested by getting the microcontroller to communicate with the MPU9250 and reading data from its registers.
    The microcontroller used is the STM32L432KC but the registers, programming, and configuration are the same (or similar) across the stm32 boards. The tutorial covers the MPU9250 IMU to provide context for configuration choices of the SPI peripheral in the microcontroller.
    Source code for this tutorial is available at:
    github.com/Z-The-Programmer/S...)
    Timestamps:
    00:00 - Introduction
    00:31 - SPI Theory
    02:57 - Picking SPI Pins
    03:13 - Peripheral Clocks
    04:06 - SPI Pin Configuration
    05:35 - SPI Peripheral Configuration: Control Register 1
    12:19 - SPI Peripheral Configuration: Control Register 1 Code
    13:01 - SPI Peripheral Configuration: Control Register 2
    15:58 - SPI Peripheral Configuration: Control Register 2 Code
    17:08 - SPI Transfer Function
    23:09 - SPI Communication Test
    24:23 - SPI Reconfiguration (V2)
    27:04 - SPI Communication Test (V2)
    27:22 - End

КОМЕНТАРІ • 26

  • @lohikarhu734
    @lohikarhu734 2 місяці тому +3

    Thanks for showing monitor screen big enough to see on my tablet, since I'm stuck in a hospital bed...

  • @johnfrancis923
    @johnfrancis923 7 місяців тому

    Absolutely fantastic! I've scoured countless resources in search of a comprehensive guide on configuring and initializing hardware from scratch, steering clear of manufacturer libraries. Your content is a gem-thank you for simplifying what seemed like a daunting task!

  • @sudharanilashkare2361
    @sudharanilashkare2361 8 місяців тому

    My spi driver search is finally successfull now, Thankyou so much Z- The-Programmer

  • @aishaal-noori9496
    @aishaal-noori9496 2 роки тому +7

    Great explanation 👍🏼 hope you post more stm32 bare metal programming examples.

    • @z-the-programmer4584
      @z-the-programmer4584  2 роки тому +3

      Already working on the next one. Should be out in the coming weeks.

  • @arunraj4608
    @arunraj4608 3 місяці тому

    Such a useful video and such a nice presentation!! Thankyou so much... hats off to the efforts taken for making this video

  • @MohamedAli-ih3kx
    @MohamedAli-ih3kx Рік тому +1

    Such an insightful video, i hope u keep making more videos about writing device drivers for Microcontrollers like STM32 for different peripherals such as UART DMA I2C I2S ADC, i really hope that man, keep up the good work 👌

  • @jeremywolfe9378
    @jeremywolfe9378 2 роки тому +8

    Great video! One recommendation is that it is best practice to use the CMSIS library and all the defines that come with it. It is almost impossible for someone to tell what (0x1

  • @MoleRat94
    @MoleRat94 Рік тому +3

    Very Informative!

  • @wilgaced
    @wilgaced 2 роки тому +1

    Great, good work!

  • @LeftoverRice99
    @LeftoverRice99 2 роки тому

    Good explanation! Thanks you

  • @chemtechleague4128
    @chemtechleague4128 2 роки тому +2

    Amazing!! keep it up

  • @anilsuha5301
    @anilsuha5301 2 роки тому

    Superb 👌keep continuing

  • @imk8729
    @imk8729 2 роки тому +1

    Thanks for your nice tutorial 👍

  • @intjengineering
    @intjengineering 2 роки тому

    Thank you very much!!!

  • @Wuetr
    @Wuetr 2 роки тому

    lovely!

  • @rick_er2481
    @rick_er2481 2 роки тому

    Thank you (Y)

  • @lohikarhu734
    @lohikarhu734 2 місяці тому

    Your typing is a bit too fast for me to follow, but, that's why they pay you the big bucks.
    It's a good thing that this controller is not too complex!
    Actually, it's a good example of the "double-edged sword" oh having incredible flexibility in a small device, but requiring quite a bit of internal configuration to get through the flexible pathways... I started with XC6801, 1978, which was a kind of beginning of the trend, with 2 or 3 functions on port pins, and a few registers to get the desired results.

  • @manojsuryawanshi1334
    @manojsuryawanshi1334 Рік тому

    i am not able to read more than 256 bytes in externnal spi

  • @pedrovaaz7942
    @pedrovaaz7942 Рік тому

    Hello, this is a great example. Can you please correct the github link. It shows 404 error.

  • @mahmoodraeisi9803
    @mahmoodraeisi9803 2 роки тому

    Hello, how can I contact you?

    • @z-the-programmer4584
      @z-the-programmer4584  2 роки тому +1

      Hey, what problem are you having? :) If the question is not too complex maybe I can answer here, otherwise you could give me your email or something and I can message you?

    • @mahmoodraeisi9803
      @mahmoodraeisi9803 2 роки тому

      hormozbazar(Atsine)Gmail